diff --git a/AUTHORS b/AUTHORS index 56543af92a..6beee8bf55 100644 --- a/AUTHORS +++ b/AUTHORS @@ -716,6 +716,7 @@ Developers: kicktheken (Kenneth Chan) Fixed a bug that the setBlendFunc method of some classes wasn't exposed to LUA. Fix lua project template crash on iOS5.1 device + Fix layout constant syntax error in lua-binding andyque Fixed a bug that missing to check self assignment of Vector, Map, Value and String. @@ -830,6 +831,7 @@ Developers: Fixed incompatible pointer conversion in external/chipmunk/src/cpArray.c Fixed memory leak in 'Image' Fixed loosing precision when using 'recv' in 'Console' + Fixed link error with Xcode 6 when building with 32-bit architecture ololomax Fixed a potential crash in SceneReader::createNodeWithSceneFile @@ -869,6 +871,16 @@ Developers: uqtimes Fix NSNotificationCenter and NSTimer leaks + + ntotani + fix building error in lua-binding in release mode + + kezhuw + AutoReleasePool manager improvement + + zhouxiaoxiaoxujian + Added TextField::getStringLength() + Add shadow, outline, glow filter support for UIText Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 9d5ef50db0..9b745809d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,40 @@ cocos2d-x-3.2 ??? + [NEW] Console: add a command to show engine version + [NEW] Node: added setter/getter for NormalizedPosition(). Allows to set positions in normalized values (between 0 and 1) + [NEW] Scene: Added createWithSize() method + [NEW] TextField: added getStringLength() [NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync() + [NEW] utils: added captureScreen() + [NEW] UIText: added shadow, outline, glow filter support - [FIX] Application.mk: not output debug message in releae mode on Android + [FIX] Application.mk: not output debug message in release mode on Android + [FIX] Android: 3d model will be black when coming from background + [FIX] Android: don't trigger EVENT_COME_TO_BACKGROUND event when go to background [FIX] Cocos2dxGLSurfaceView.java: prevent flickering when opening another activity + [FIX] GLProgramState: sampler can not be changed [FIX] Image: Set jpeg save quality to 90 + [FIX] Image: premultiply alpha when loading png file to resolve black border issue [FIX] Label: label is unsharp if it's created by smaller font + [FIX] Label: Label's display may go bonkers if invoking Label::setString() with outline feature enabled + [FIX] Lua-binding: compiling error on release mode + [FIX] Lua-binding: Add xxtea encrypt support + [FIX] Node: setPhysicsBody() can not work correctly if it is added to a Node + [FIX] Node: state of _transformUpdated, _transformDirty and _inverseDirty are wrong in setParent() + [FIX] Node: _orderOfArrival is set to 0 after visit + [FIX] Other: link error with Xcode 6 when building with 32-bit architecture [FIX] Repeat: will run one more over in rare situations + [FIX] Scale9Sprite: support culling + [FIX] Schedule: schedulePerFrame() can not be called twice + [FIX] SpriteFrameCache: fix memory leak + [FIX] Texture2D: use image's pixel format to create texture + [FIX] WP8: will restart if app goes to background, then touches icon to go to foreground + [FIX] WP8: will be black if: 1. 3rd pops up a view; 2. go to background; 3. come to foreground + [FIX] WP8: project name of new project created by console is wrong + + [3RD] curl: will crash if use https request on iOS simulator + +cocos2d-x-3.1.1 May.31 2014 + [FIX] GLProgramState: restores states after coming from background cocos2d-x-3.1 May.24 2014 [FIX] EventKeyboard::KeyCode: key code for back button changed from KEY_BACKSPACE to KEY_ESCAPE diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d1bbc43d..fd1ccfbf39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash + ${CMAKE_CURRENT_SOURCE_DIR}/external/xxtea ) if(WIN32 AND NOT MINGW) @@ -258,6 +259,9 @@ add_subdirectory(external/lua/tolua) # luabinding add_subdirectory(cocos/scripting/lua-bindings) + +# xxtea +add_subdirectory(external/xxtea) endif(BUILD_LIBS_LUA) # build tests diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 5d52f008de..d4eededf95 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -40,8 +40,6 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; }; - 06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; }; 06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; }; 06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; }; 06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; }; @@ -54,8 +52,6 @@ 06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABD186AD63B0012A414 /* TriggerBase.h */; }; 06CAAACF186AD7FC0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; }; 06CAAAD0186AD7FE0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; }; - 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; }; - 06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; }; 1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; }; 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; }; 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A01C67718F57BE800EFE3A6 /* CCArray.h */; }; @@ -973,12 +969,14 @@ 2905FA8E18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; }; 2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; }; 2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; }; + 299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; + 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; }; + 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; + 299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; }; 29CB8F4C1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; }; 29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; }; 29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; }; 29CB8F4F1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; }; - 29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; }; - 29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; }; 2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; }; 2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; }; 2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; }; @@ -1887,8 +1885,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFactory.cpp; sourceTree = ""; }; - 06CAAABB186AD63B0012A414 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFactory.h; sourceTree = ""; }; 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerBase.cpp; sourceTree = ""; }; 06CAAABD186AD63B0012A414 /* TriggerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerBase.h; sourceTree = ""; }; 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerMng.cpp; sourceTree = ""; }; @@ -2274,9 +2270,10 @@ 29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = ""; }; 2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; 2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; + 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = ""; }; + 299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = ""; }; 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = ""; }; 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = ""; }; - 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollInterface.h; sourceTree = ""; }; 2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundingBoxAttachment.cpp; sourceTree = ""; }; 2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundingBoxAttachment.h; sourceTree = ""; }; 2AC795D51862867D005EC8E1 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = ""; }; @@ -3071,6 +3068,8 @@ 1A5700A2180BC5E60088DEC7 /* base */ = { isa = PBXGroup; children = ( + 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */, + 299754F3193EC95400A54AC3 /* ObjectFactory.h */, 50ABBDC11925AB6E00A911A9 /* atitc.cpp */, 50ABBDC21925AB6E00A911A9 /* atitc.h */, 50ABBDC31925AB6E00A911A9 /* base64.cpp */, @@ -3590,8 +3589,6 @@ children = ( 50FCEB6818C72017004AD434 /* WidgetReader */, 06CAAAC1186AD63B0012A414 /* TriggerObj.h */, - 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */, - 06CAAABB186AD63B0012A414 /* ObjectFactory.h */, 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */, 06CAAABD186AD63B0012A414 /* TriggerBase.h */, 06CAAABE186AD63B0012A414 /* TriggerMng.cpp */, @@ -4003,7 +4000,6 @@ 2905FA0518CF08D000240AA3 /* UIRichText.h */, 2905FA0718CF08D000240AA3 /* UIScrollView.cpp */, 2905FA0818CF08D000240AA3 /* UIScrollView.h */, - 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */, 2905FA0918CF08D000240AA3 /* UISlider.cpp */, 2905FA0A18CF08D100240AA3 /* UISlider.h */, 2905FA0B18CF08D100240AA3 /* UIText.cpp */, @@ -4921,7 +4917,6 @@ 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 50FCEBB518C72017004AD434 /* SliderReader.h in Headers */, 5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */, - 06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, @@ -5007,6 +5002,7 @@ 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */, 2905FA6418CF08D100240AA3 /* UIListView.h in Headers */, + 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */, 50FCEBB918C72017004AD434 /* TextAtlasReader.h in Headers */, 50ABBD991925AB4100A911A9 /* CCGLProgramStateCache.h in Headers */, 5034CA3D191D591100CE6051 /* ccShader_PositionColor.frag in Headers */, @@ -5153,7 +5149,6 @@ 50ABBD9D1925AB4100A911A9 /* ccGLStateCache.h in Headers */, 50ABBEB91925AB6F00A911A9 /* ccUTF8.h in Headers */, 1AAF536E180E3374000584C8 /* HttpRequest.h in Headers */, - 29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */, 1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */, 50ABBE671925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */, 1AAF5374180E3374000584C8 /* SocketIO.h in Headers */, @@ -5440,6 +5435,7 @@ 2905FA7118CF08D100240AA3 /* UIRichText.h in Headers */, 503DD8E41926736A00CD74DD /* CCDirectorCaller.h in Headers */, 50ABBD8A1925AB4100A911A9 /* CCCustomCommand.h in Headers */, + 299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */, 2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */, 50ABBE881925AB6F00A911A9 /* ccMacros.h in Headers */, 50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */, @@ -5523,7 +5519,6 @@ 50ABBDB81925AB4100A911A9 /* CCTexture2D.h in Headers */, 50ABBE341925AB6F00A911A9 /* CCConfiguration.h in Headers */, 1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, - 06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */, 50ABBEAA1925AB6F00A911A9 /* CCTouch.h in Headers */, 2905FA6918CF08D100240AA3 /* UILoadingBar.h in Headers */, 50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */, @@ -5611,7 +5606,6 @@ 50ABBD921925AB4100A911A9 /* CCGLProgramCache.h in Headers */, 1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */, B29594C91926D61F003EEF37 /* CCObjLoader.h in Headers */, - 29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */, 1AD71E98180E26E600808F54 /* Animation.h in Headers */, 1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */, 50ABBE961925AB6F00A911A9 /* CCProfiling.h in Headers */, @@ -6153,7 +6147,6 @@ 1A57011B180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, 1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */, 50FCEBA718C72017004AD434 /* LoadingBarReader.cpp in Sources */, - 06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */, 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */, 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, @@ -6345,6 +6338,7 @@ 2905FA5218CF08D100240AA3 /* UIImageView.cpp in Sources */, 50ABBDBD1925AB4100A911A9 /* CCTextureCache.cpp in Sources */, B29594CE1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */, + 299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */, 2905FA7C18CF08D100240AA3 /* UIText.cpp in Sources */, 50FCEB9F18C72017004AD434 /* LayoutReader.cpp in Sources */, 50ABC0211926664800A911A9 /* CCGLView.cpp in Sources */, @@ -6598,7 +6592,6 @@ 1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, 1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, 1A570120180BC90D0088DEC7 /* CCGrid.cpp in Sources */, - 06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */, 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, 503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */, 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, @@ -6616,6 +6609,7 @@ B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */, 1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, 1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, + 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */, 1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, 50ABBDBE1925AB4100A911A9 /* CCTextureCache.cpp in Sources */, 1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */, @@ -7117,6 +7111,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -7143,6 +7138,7 @@ CC_KEYBOARD_SUPPORT, CC_TARGET_OS_MAC, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -7235,6 +7231,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac"; }; @@ -7245,6 +7242,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac"; }; @@ -7259,6 +7257,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac"; @@ -7274,6 +7273,7 @@ CC_TARGET_OS_MAC, CC_KEYBOARD_SUPPORT, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; LIBRARY_SEARCH_PATHS = "$(inherited)"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac"; @@ -7291,6 +7291,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -7329,6 +7330,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -7385,6 +7387,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -7403,6 +7406,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; LIBRARY_SEARCH_PATHS = "$(inherited)"; @@ -7481,6 +7485,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; SDKROOT = iphoneos; @@ -7498,6 +7503,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_TREAT_WARNINGS_AS_ERRORS = NO; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; SDKROOT = iphoneos; diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 31ff531727..856c5e741d 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -570,8 +570,6 @@ 1AC35CD718CED84500F37B72 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */; }; 1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */; }; 1AC35CD918CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */; }; - 1AC35CDC18CED84500F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; }; - 1AC35CDD18CED84500F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; }; 1AC35CDE18CED84500F37B72 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB318CED84500F37B72 /* components */; }; 1AC35CDF18CED84500F37B72 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB318CED84500F37B72 /* components */; }; 1AC35CE018CED84500F37B72 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB418CED84500F37B72 /* configs */; }; @@ -697,7 +695,6 @@ 1AC35DE318CEE65900F37B72 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB918CED84500F37B72 /* fileLookup.plist */; }; 1AC35DE518CEE65900F37B72 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CBD18CED84500F37B72 /* Hello.png */; }; 1AC35DE618CEE65900F37B72 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB518CED84500F37B72 /* effect1.raw */; }; - 1AC35DE718CEE65900F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; }; 1AC35DE918CEE65900F37B72 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB618CED84500F37B72 /* effect1.wav */; }; 1AC35DEA18CEE65900F37B72 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */; }; 1AC35DEB18CEE65B00F37B72 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */; }; @@ -709,7 +706,6 @@ 1AC35DF118CEE65B00F37B72 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB918CED84500F37B72 /* fileLookup.plist */; }; 1AC35DF318CEE65B00F37B72 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CBD18CED84500F37B72 /* Hello.png */; }; 1AC35DF418CEE65B00F37B72 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB518CED84500F37B72 /* effect1.raw */; }; - 1AC35DF518CEE65B00F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; }; 1AC35DF718CEE65B00F37B72 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB618CED84500F37B72 /* effect1.wav */; }; 1AC35DF818CEE65B00F37B72 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */; }; 1AF152D918FD252A00A52F3D /* PerformanceCallbackTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF152D718FD252A00A52F3D /* PerformanceCallbackTest.cpp */; }; @@ -1668,7 +1664,6 @@ 1AC35CAE18CED84500F37B72 /* ccb */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ccb; path = "../tests/cpp-tests/Resources/ccb"; sourceTree = ""; }; 1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = CocosBuilderExample.ccbproj; path = "../tests/cpp-tests/Resources/CocosBuilderExample.ccbproj"; sourceTree = ""; }; 1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocosBuilderExample.ccbresourcelog; path = "../tests/cpp-tests/Resources/CocosBuilderExample.ccbresourcelog"; sourceTree = ""; }; - 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = commonly_used_words.txt; path = "../tests/cpp-tests/Resources/commonly_used_words.txt"; sourceTree = ""; }; 1AC35CB318CED84500F37B72 /* components */ = {isa = PBXFileReference; lastKnownFileType = folder; name = components; path = "../tests/cpp-tests/Resources/components"; sourceTree = ""; }; 1AC35CB418CED84500F37B72 /* configs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = configs; path = "../tests/cpp-tests/Resources/configs"; sourceTree = ""; }; 1AC35CB518CED84500F37B72 /* effect1.raw */ = {isa = PBXFileReference; lastKnownFileType = file; name = effect1.raw; path = "../tests/cpp-tests/Resources/effect1.raw"; sourceTree = ""; }; @@ -3273,7 +3268,6 @@ 1AC35CB918CED84500F37B72 /* fileLookup.plist */, 1AC35CBD18CED84500F37B72 /* Hello.png */, 1AC35CB518CED84500F37B72 /* effect1.raw */, - 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */, 1AC35CB618CED84500F37B72 /* effect1.wav */, 1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */, ); @@ -4262,7 +4256,6 @@ 1ABCA38818CD9E180087CE3A /* DeprecatedOpenglEnum.lua in Resources */, 1AC35DE118CEE65900F37B72 /* background.ogg in Resources */, 15C90B4B18E66C2F00D69802 /* url.lua in Resources */, - 1AC35DE718CEE65900F37B72 /* commonly_used_words.txt in Resources */, 1ABCA37A18CD9E180087CE3A /* CCBReaderLoad.lua in Resources */, 1AC35DDF18CEE65900F37B72 /* music.mid in Resources */, 1AC35D7518CEE58500F37B72 /* src in Resources */, @@ -4352,7 +4345,6 @@ 1ABCA39B18CD9E180087CE3A /* StudioConstants.lua in Resources */, 1ABCA38D18CD9E180087CE3A /* extern.lua in Resources */, 1AC35DEB18CEE65B00F37B72 /* CocosBuilderExample.ccbproj in Resources */, - 1AC35DF518CEE65B00F37B72 /* commonly_used_words.txt in Resources */, 1AC35DCA18CEE65200F37B72 /* animations in Resources */, 1A1645A9191B6283008C7C7F /* ccs-res in Resources */, 1AC35DA118CEE5D100F37B72 /* Icon-72.png in Resources */, @@ -4393,7 +4385,6 @@ 1AC35CFA18CED84500F37B72 /* Misc in Resources */, 1AC35D0418CED84500F37B72 /* Shaders in Resources */, 1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */, - 1AC35CDC18CED84500F37B72 /* commonly_used_words.txt in Resources */, B2507B6B192589AF00FA4972 /* Shaders3D in Resources */, 1AC35D0618CED84500F37B72 /* spine in Resources */, 1AC35CE818CED84500F37B72 /* extensions in Resources */, @@ -4471,7 +4462,6 @@ B2507B6C192589AF00FA4972 /* Shaders3D in Resources */, 1AC35CED18CED84500F37B72 /* fonts in Resources */, 1AC35CD718CED84500F37B72 /* CocosBuilderExample.ccbproj in Resources */, - 1AC35CDD18CED84500F37B72 /* commonly_used_words.txt in Resources */, 1AC35C8918CECF1400F37B72 /* Default.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5514,6 +5504,7 @@ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; + MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -5540,6 +5531,7 @@ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; + MACOSX_DEPLOYMENT_TARGET = 10.7; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk"; diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index cc750ff187..397729445a 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues() } // AtlasNode - draw -void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _quadCommand.init( _globalZOrder, diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index 9fa995488d..5162a69b18 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -69,7 +69,7 @@ public: // Overrides - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual Texture2D* getTexture() const override; virtual void setTexture(Texture2D *texture) override; virtual bool isOpacityModifyRGB() const override; diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 41d3c971d8..15fb64a923 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -203,15 +203,12 @@ void ClippingNode::drawFullScreenQuadClearStencil() } -void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if(!_visible) return; - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, @@ -249,7 +246,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p #endif } - _stencil->visit(renderer, _modelViewTransform, dirty); + _stencil->visit(renderer, _modelViewTransform, flags); _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); @@ -266,19 +263,19 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } // self draw - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); } else { - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); } _afterVisitCmd.init(_globalZOrder); diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index 3ca5ab911c..6fde2fe9b7 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -95,7 +95,7 @@ public: * @lua NA */ virtual void onExit() override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; CC_CONSTRUCTOR_ACCESS: ClippingNode(); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 108c2eb7cc..5462b7f6ce 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -205,14 +205,14 @@ bool DrawNode::init() return true; } -void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void DrawNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated) +void DrawNode::onDraw(const Mat4 &transform, uint32_t flags) { auto glProgram = getGLProgram(); glProgram->use(); diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 264a1ad78a..7a1a10b9bf 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -89,10 +89,10 @@ public: */ void setBlendFunc(const BlendFunc &blendFunc); - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); // Overrides - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; CC_CONSTRUCTOR_ACCESS: DrawNode(); diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index 18153676af..f9f6df7db1 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -264,8 +264,16 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String) _currentPageOrigY += _commonLineHeight; _currentPageOrigX = 0; if(_currentPageOrigY + _commonLineHeight >= CacheTextureHeight) - { - auto data = _currentPageData + CacheTextureWidth * (int)startY; + { + unsigned char *data = nullptr; + if(pixelFormat == Texture2D::PixelFormat::AI88) + { + data = _currentPageData + CacheTextureWidth * (int)startY * 2; + } + else + { + data = _currentPageData + CacheTextureWidth * (int)startY; + } _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, CacheTextureHeight - startY); @@ -325,7 +333,15 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String) if(existNewLetter) { - auto data = _currentPageData + CacheTextureWidth * (int)startY; + unsigned char *data = nullptr; + if(pixelFormat == Texture2D::PixelFormat::AI88) + { + data = _currentPageData + CacheTextureWidth * (int)startY * 2; + } + else + { + data = _currentPageData + CacheTextureWidth * (int)startY; + } _atlasTextures[_currentPage]->updateWithData(data, 0, startY, CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight); } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 9372b247fd..39ef02f014 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -877,14 +877,14 @@ void Label::drawShadowWithoutBlur() setColor(oldColor); } -void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // Don't do calculate the culling if the transform was not updated - _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; + _insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; if(_insideBounds) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } } @@ -1019,7 +1019,7 @@ void Label::updateFont() _systemFontDirty = false; } -void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated) +void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags) { if (_fontDefinition._fontFillColor != _textColor) { @@ -1044,12 +1044,12 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated) } if (_shadowNode) { - _shadowNode->visit(renderer, _modelViewTransform, parentTransformUpdated); + _shadowNode->visit(renderer, _modelViewTransform, parentFlags); } - _textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated); + _textSprite->visit(renderer, _modelViewTransform, parentFlags); } -void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (! _visible || _originalUTF8String.empty()) { @@ -1064,9 +1064,9 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr updateContent(); } - bool dirty = parentTransformUpdated || _transformUpdated; + uint32_t flags = processParentFlags(parentTransform, parentFlags); - if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty)) + if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || (flags & FLAGS_DIRTY_MASK))) { _position.x += _shadowOffset.width; _position.y += _shadowOffset.height; @@ -1081,12 +1081,6 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr _shadowDirty = false; } - if(dirty) - { - _modelViewTransform = transform(parentTransform); - } - _transformUpdated = false; - // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it @@ -1099,11 +1093,11 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr if (_textSprite) { - drawTextSprite(renderer,dirty); + drawTextSprite(renderer, flags); } else { - draw(renderer, _modelViewTransform, dirty); + draw(renderer, _modelViewTransform, flags); } director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 7af8134507..7cad6af323 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -237,8 +237,8 @@ public: virtual Rect getBoundingBox() const override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize, const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT, @@ -298,7 +298,7 @@ protected: void drawShadowWithoutBlur(); - void drawTextSprite(Renderer *renderer, bool parentTransformUpdated); + void drawTextSprite(Renderer *renderer, uint32_t parentFlags); void createSpriteWithFontDefinition(); diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index f051917c84..be8c324ed2 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -249,7 +249,7 @@ void LabelAtlas::updateColor() //CCLabelAtlas - draw #if CC_LABELATLAS_DEBUG_DRAW -void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { AtlasNode::draw(renderer, transform, transformUpdated); diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index 1ef43bec2a..2c373fe76e 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -84,7 +84,7 @@ public: virtual std::string getDescription() const override; #if CC_LABELATLAS_DEBUG_DRAW - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; #endif protected: diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index e81d57a2dc..e62cb35e33 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const return _label->getBoundingBox(); } #if CC_LABELBMFONT_DEBUG_DRAW -void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { Node::draw(renderer, transform, transformUpdated); diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 595ce7cbb2..cc22e5b79c 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -124,7 +124,7 @@ public: virtual std::string getDescription() const override; #if CC_LABELBMFONT_DEBUG_DRAW - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; #endif private: diff --git a/cocos/2d/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp index adf94e8f3e..63acc40e11 100644 --- a/cocos/2d/CCLabelTTF.cpp +++ b/cocos/2d/CCLabelTTF.cpp @@ -262,14 +262,14 @@ void LabelTTF::setFlippedY(bool flippedY) } } -void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (_contentDirty) { this->setContentSize(_renderLabel->getContentSize()); _contentDirty = false; } - Node::visit(renderer,parentTransform,parentTransformUpdated); + Node::visit(renderer,parentTransform, parentFlags); } const Size& LabelTTF::getContentSize() const diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index f65992fa99..8c0dea3f19 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -150,7 +150,7 @@ public: * @lua NA */ virtual std::string getDescription() const override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; virtual const Size& getContentSize() const override; protected: Label* _renderLabel; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 6777dd4c05..558cbdde19 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -75,16 +75,9 @@ Layer::~Layer() bool Layer::init() { - bool ret = false; - do - { - Director * director; - CC_BREAK_IF(!(director = Director::getInstance())); - this->setContentSize(director->getWinSize()); - // success - ret = true; - } while(0); - return ret; + Director * director = Director::getInstance(); + setContentSize(director->getWinSize()); + return true; } Layer *Layer::create() @@ -584,10 +577,10 @@ void LayerColor::updateColor() } } -void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LayerColor::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); for(int i = 0; i < 4; ++i) @@ -600,7 +593,7 @@ void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformU } } -void LayerColor::onDraw(const Mat4& transform, bool transformUpdated) +void LayerColor::onDraw(const Mat4& transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index 4f8bdb3046..b6f985aa72 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -270,7 +270,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void setContentSize(const Size & var) override; /** BlendFunction. Conforms to BlendProtocol protocol */ @@ -299,7 +299,7 @@ CC_CONSTRUCTOR_ACCESS: bool initWithColor(const Color4B& color); protected: - void onDraw(const Mat4& transform, bool transformUpdated); + void onDraw(const Mat4& transform, uint32_t flags); virtual void updateColor() override; diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 585ef38cdc..2b1bf8e511 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -374,7 +374,7 @@ void MotionStreak::reset() _nuPoints = 0; } -void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated) +void MotionStreak::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -404,12 +404,12 @@ void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated) CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2); } -void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if(_nuPoints <= 1) return; _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } diff --git a/cocos/2d/CCMotionStreak.h b/cocos/2d/CCMotionStreak.h index d4c5a1c47c..951c4def21 100644 --- a/cocos/2d/CCMotionStreak.h +++ b/cocos/2d/CCMotionStreak.h @@ -85,7 +85,7 @@ public: * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; /** * @js NA * @lua NA @@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS: protected: //renderer callback - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); bool _fastMode; bool _startingPositionInitialized; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index ca9c48729b..07d28e4455 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -121,6 +121,7 @@ Node::Node(void) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) +, _usingNormalizedPosition(false) { // set default scheduler and actionManager Director *director = Director::getInstance(); @@ -423,6 +424,7 @@ void Node::setPosition(const Vec2& position) _position = position; _transformUpdated = _transformDirty = _inverseDirty = true; + _usingNormalizedPosition = false; #if CC_USE_PHYSICS if (_physicsBody != nullptr && !_physicsBody->_positionResetTag) @@ -498,6 +500,23 @@ void Node::setPositionZ(float positionZ) setGlobalZOrder(positionZ); } +/// position getter +const Vec2& Node::getNormalizedPosition() const +{ + return _normalizedPosition; +} + +/// position setter +void Node::setNormalizedPosition(const Vec2& position) +{ + if (_normalizedPosition.equals(position)) + return; + + _normalizedPosition = position; + _usingNormalizedPosition = true; + _transformUpdated = _transformDirty = _inverseDirty = true; +} + ssize_t Node::getChildrenCount() const { return _children.size(); @@ -561,7 +580,7 @@ void Node::setContentSize(const Size & size) _contentSize = size; _anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y ); - _transformUpdated = _transformDirty = _inverseDirty = true; + _transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true; } } @@ -575,6 +594,7 @@ bool Node::isRunning() const void Node::setParent(Node * parent) { _parent = parent; + _transformUpdated = _transformDirty = _inverseDirty = true; } /// isRelativeAnchorPoint getter @@ -943,7 +963,7 @@ void Node::draw() draw(renderer, _modelViewTransform, true); } -void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated) +void Node::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags) { } @@ -954,7 +974,30 @@ void Node::visit() visit(renderer, parentTransform, true); } -void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags) +{ + uint32_t flags = parentFlags; + flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0); + flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0); + + if(_usingNormalizedPosition && (flags & FLAGS_CONTENT_SIZE_DIRTY)) { + CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); + auto s = _parent->getContentSize(); + _position.x = _normalizedPosition.x * s.width; + _position.y = _normalizedPosition.y * s.height; + _transformUpdated = _transformDirty = _inverseDirty = true; + } + + if(flags & FLAGS_DIRTY_MASK) + _modelViewTransform = this->transform(parentTransform); + + _transformUpdated = false; + _contentSizeDirty = false; + + return flags; +} + +void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -962,17 +1005,12 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra return; } - bool dirty = _transformUpdated || parentTransformUpdated; - if(dirty) - _modelViewTransform = this->transform(parentTransform); - _transformUpdated = false; - + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); @@ -987,24 +1025,21 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra auto node = _children.at(i); if ( node && node->_localZOrder < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } // self draw - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); } else { - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); } - // reset for next frame - _orderOfArrival = 0; - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } @@ -1640,8 +1675,18 @@ void Node::updatePhysicsBodyRotation(Scene* scene) void Node::setPhysicsBody(PhysicsBody* body) { + if (_physicsBody == body) + { + return; + } + if (body != nullptr) { + if (body->getNode() != nullptr) + { + body->getNode()->setPhysicsBody(nullptr); + } + body->_node = this; body->retain(); @@ -1683,6 +1728,11 @@ void Node::setPhysicsBody(PhysicsBody* body) } } + if (scene != nullptr) + { + scene->getPhysicsWorld()->addBody(body); + } + updatePhysicsBodyPosition(scene); updatePhysicsBodyRotation(scene); } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 9a36591a19..84d0973693 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -107,6 +107,12 @@ public: /// Default tag used for all the nodes static const int INVALID_TAG = -1; + enum { + FLAGS_TRANSFORM_DIRTY = (1 << 0), + FLAGS_CONTENT_SIZE_DIRTY = (1 << 1), + + FLAGS_DIRTY_MASK = (FLAGS_TRANSFORM_DIRTY | FLAGS_CONTENT_SIZE_DIRTY), + }; /// @{ /// @name Constructor, Destructor and Initializers @@ -283,6 +289,19 @@ public: * @param position The position (x,y) of the node in OpenGL coordinates */ virtual void setPosition(const Vec2 &position); + + /** Sets the position (x,y) using values between 0 and 1. + The positions in pixels is calculated like the following: + @code + // pseudo code + void setNormalizedPosition(Vec2 pos) { + Size s = getParent()->getContentSize(); + _position = pos * s; + } + @endcode + */ + virtual void setNormalizedPosition(const Vec2 &position); + /** * Gets the position (x,y) of the node in its parent's coordinate system. * @@ -294,6 +313,10 @@ public: * @endcode */ virtual const Vec2& getPosition() const; + + /** returns the normalized position */ + virtual const Vec2& getNormalizedPosition() const; + /** * Sets the position (x,y) of the node in its parent's coordinate system. * @@ -923,13 +946,13 @@ public: * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * But if you enable any other GL state, you should disable it after drawing your node. */ - virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags); virtual void draw() final; /** * Visits this node's children and draw them recursively. */ - virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); + virtual void visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags); virtual void visit() final; @@ -1362,6 +1385,7 @@ protected: Vec2 convertToWindowSpace(const Vec2& nodePoint) const; Mat4 transform(const Mat4 &parentTransform); + uint32_t processParentFlags(const Mat4& parentTransform, uint32_t parentFlags); virtual void updateCascadeOpacity(); virtual void disableCascadeOpacity(); @@ -1387,6 +1411,8 @@ protected: Vec2 _position; ///< position of the node float _positionZ; ///< OpenGL real Z position + Vec2 _normalizedPosition; + bool _usingNormalizedPosition; float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis @@ -1395,6 +1421,7 @@ protected: Vec2 _anchorPoint; ///< anchor point normalized (NOT in points) Size _contentSize; ///< untransformed size of the node + bool _contentSizeDirty; ///< whether or not the contentSize is dirty Mat4 _modelViewTransform; ///< ModelView transform of the Node. diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 7d4fbf9385..b2ed64a5c7 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw() } } -void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -94,7 +94,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool paren renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - bool dirty = parentTransformUpdated || _transformUpdated; + bool dirty = (parentFlags & FLAGS_TRANSFORM_DIRTY) || _transformUpdated; if(dirty) _modelViewTransform = this->transform(parentTransform); _transformUpdated = false; diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index d36f39ca7d..0444c4b707 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -54,7 +54,7 @@ public: void setTarget(Node *target); // overrides - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; protected: NodeGrid(); diff --git a/cocos/2d/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp index 89c1480d0d..d84a7eabf8 100644 --- a/cocos/2d/CCParallaxNode.cpp +++ b/cocos/2d/CCParallaxNode.cpp @@ -145,7 +145,7 @@ The positions are updated at visit because: - using a timer is not guaranteed that it will called after all the positions were updated - overriding "draw" will only precise if the children have a z > 0 */ -void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // Vec2 pos = position_; // Vec2 pos = [self convertToWorldSpace:Vec2::ZERO]; @@ -161,7 +161,7 @@ void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p } _lastPosition = pos; } - Node::visit(renderer, parentTransform, parentTransformUpdated); + Node::visit(renderer, parentTransform, parentFlags); } NS_CC_END diff --git a/cocos/2d/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h index 66e92b078b..a2e80a7f78 100644 --- a/cocos/2d/CCParallaxNode.h +++ b/cocos/2d/CCParallaxNode.h @@ -67,7 +67,7 @@ public: virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; protected: /** Adds a child to the container with a z-order, a parallax ratio and a position offset diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 6b19d4457e..ffcf9eba3a 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -121,7 +121,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity) // override visit. // Don't call visit on it's children -void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // CAREFUL: // This visit is almost identical to Node#visit @@ -135,20 +135,16 @@ void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, b return; } - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); - draw(renderer, _modelViewTransform, dirty); + draw(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } @@ -383,7 +379,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup) _textureAtlas->removeAllQuads(); } -void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { CC_PROFILER_START("CCParticleBatchNode - draw"); diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index a967425fca..7318f5d138 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -91,13 +91,13 @@ public: inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }; // Overrides - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; virtual void removeChild(Node* child, bool cleanup) override; virtual void reorderChild(Node * child, int zOrder) override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual Texture2D* getTexture(void) const override; virtual void setTexture(Texture2D *texture) override; /** diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 02d02dfe36..70143fe75f 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep() } // overriding draw method -void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad"); //quad command diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index 6bd6d4e04f..b3a701c1ba 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -106,7 +106,7 @@ public: * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; /** * @js NA diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index d0cbabdf87..c90b1d8c21 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -500,7 +500,7 @@ Vec2 ProgressTimer::boundaryTexCoord(char index) return Vec2::ZERO; } -void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated) +void ProgressTimer::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); @@ -551,13 +551,13 @@ void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated) } } -void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if( ! _vertexData || ! _sprite) return; _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } diff --git a/cocos/2d/CCProgressTimer.h b/cocos/2d/CCProgressTimer.h index 84a4da05b3..a687c396f8 100644 --- a/cocos/2d/CCProgressTimer.h +++ b/cocos/2d/CCProgressTimer.h @@ -111,7 +111,7 @@ public: inline Vec2 getBarChangeRate() const { return _barChangeRate; } // Overrides - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void setAnchorPoint(const Vec2& anchorPoint) override; virtual void setColor(const Color3B &color) override; virtual const Color3B& getColor() const override; @@ -133,7 +133,7 @@ CC_CONSTRUCTOR_ACCESS: bool initWithSprite(Sprite* sp); protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); Tex2F textureCoordFromAlphaPoint(Vec2 alpha); Vec2 vertexFromAlphaPoint(Vec2 alpha); diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index f11364a019..f8d08d3185 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue) glClearStencil(stencilClearValue); } -void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // override visit. // Don't call visit on its children @@ -392,22 +392,17 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool return; } - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; - - Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + uint32_t flags = processParentFlags(parentTransform, parentFlags); + Director* director = Director::getInstance(); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); - _sprite->visit(renderer, _modelViewTransform, dirty); - draw(renderer, _modelViewTransform, dirty); + _sprite->visit(renderer, _modelViewTransform, flags); + draw(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -654,7 +649,7 @@ void RenderTexture::onClearDepth() glClearDepth(depthClearValue); } -void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (_autoDraw) { @@ -672,7 +667,7 @@ void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transfo for(const auto &child: _children) { if (child != _sprite) - child->visit(renderer, transform, transformUpdated); + child->visit(renderer, transform, flags); } //End will pop the current render group diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index 47f2c506df..09ba451df7 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -153,8 +153,8 @@ public: }; // Overrides - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; //flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix void setKeepMatrix(bool keepMatrix); diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index e4e4c58a4c..c59d8439f6 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -53,19 +53,17 @@ Scene::~Scene() bool Scene::init() { - bool ret = false; - do - { - Director * director; - CC_BREAK_IF( ! (director = Director::getInstance()) ); - this->setContentSize(director->getWinSize()); - // success - ret = true; - } while (0); - return ret; + auto size = Director::getInstance()->getWinSize(); + return initWithSize(size); } -Scene *Scene::create() +bool Scene::initWithSize(const Size& size) +{ + setContentSize(size); + return true; +} + +Scene* Scene::create() { Scene *ret = new Scene(); if (ret && ret->init()) @@ -80,6 +78,21 @@ Scene *Scene::create() } } +Scene* Scene::createWithSize(const Size& size) +{ + Scene *ret = new Scene(); + if (ret && ret->initWithSize(size)) + { + ret->autorelease(); + return ret; + } + else + { + CC_SAFE_DELETE(ret); + return nullptr; + } +} + std::string Scene::getDescription() const { return StringUtils::format("", _tag); @@ -106,7 +119,7 @@ void Scene::update(float delta) } } -Scene *Scene::createWithPhysics() +Scene* Scene::createWithPhysics() { Scene *ret = new Scene(); if (ret && ret->initWithPhysics()) diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index c4fc057e25..4d30cbd76e 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -54,6 +54,9 @@ public: /** creates a new Scene object */ static Scene *create(); + /** creates a new Scene object with a predefined Size */ + static Scene *createWithSize(const Size& size); + // Overrides virtual Scene *getScene() override; @@ -64,7 +67,8 @@ CC_CONSTRUCTOR_ACCESS: Scene(); virtual ~Scene(); - virtual bool init() override; + bool init(); + bool initWithSize(const Size& size); protected: friend class Node; diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index b922554d18..cc04c47c47 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -585,10 +585,10 @@ void Sprite::updateTransform(void) // draw -void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // Don't do calculate the culling if the transform was not updated - _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; + _insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; if(_insideBounds) { diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 29935d7404..9fa880f369 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -420,7 +420,7 @@ public: virtual void setAnchorPoint(const Vec2& anchor) override; virtual void ignoreAnchorPointForPosition(bool value) override; virtual void setVisible(bool bVisible) override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void setOpacityModifyRGB(bool modify) override; virtual bool isOpacityModifyRGB(void) const override; /// @} diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 474704247c..e208725a49 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode() // override visit // don't call visit on it's children -void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); @@ -150,20 +150,16 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, boo sortAllChildren(); - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); - draw(renderer, _modelViewTransform, dirty); + draw(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); setOrderOfArrival(0); @@ -356,7 +352,7 @@ void SpriteBatchNode::reorderBatch(bool reorder) _reorderChildDirty=reorder; } -void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // Optimization: Fast Dispatch if( _textureAtlas->getTotalQuads() == 0 ) diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 6bdbac905d..8f9118baec 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -134,7 +134,7 @@ public: */ virtual const BlendFunc& getBlendFunc() const override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; @@ -143,7 +143,7 @@ public: virtual void removeChild(Node *child, bool cleanup) override; virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void sortAllChildren() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string getDescription() const override; /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. diff --git a/cocos/2d/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp index 51d02c4d73..f52c56e48c 100644 --- a/cocos/2d/CCSpriteFrame.cpp +++ b/cocos/2d/CCSpriteFrame.cpp @@ -69,6 +69,13 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, return spriteFrame; } +SpriteFrame::SpriteFrame(void) +: _rotated(false) +, _texture(nullptr) +{ + +} + bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect) { Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect); diff --git a/cocos/2d/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h index 9a534fbcdc..bf214ff653 100644 --- a/cocos/2d/CCSpriteFrame.h +++ b/cocos/2d/CCSpriteFrame.h @@ -75,34 +75,6 @@ public: The originalSize is the size in points of the frame before being trimmed. */ static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); - /** - * @js NA - * @lua NA - */ - virtual ~SpriteFrame(void); - - /** Initializes a SpriteFrame with a texture, rect in points. - It is assumed that the frame was not trimmed. - */ - bool initWithTexture(Texture2D* pobTexture, const Rect& rect); - - /** Initializes a SpriteFrame with a texture filename, rect in points; - It is assumed that the frame was not trimmed. - */ - bool initWithTextureFilename(const std::string& filename, const Rect& rect); - - /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. - The originalSize is the size in points of the frame before being trimmed. - */ - bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); - - /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. - The originalSize is the size in pixels of the frame before being trimmed. - - @since v1.1 - */ - bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); - // attributes inline const Rect& getRectInPixels() const { return _rectInPixels; } @@ -141,6 +113,39 @@ public: // Overrides virtual SpriteFrame *clone() const override; + +CC_CONSTRUCTOR_ACCESS: + /** + * @lua NA + */ + SpriteFrame(void); + + /** + * @lua NA + */ + virtual ~SpriteFrame(void); + + /** Initializes a SpriteFrame with a texture, rect in points. + It is assumed that the frame was not trimmed. + */ + bool initWithTexture(Texture2D* pobTexture, const Rect& rect); + + /** Initializes a SpriteFrame with a texture filename, rect in points; + It is assumed that the frame was not trimmed. + */ + bool initWithTextureFilename(const std::string& filename, const Rect& rect); + + /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. + The originalSize is the size in points of the frame before being trimmed. + */ + bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); + + /** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. + The originalSize is the size in pixels of the frame before being trimmed. + + @since v1.1 + */ + bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize); protected: Vec2 _offset; diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index 2bd0dcc782..94fc0fe559 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -65,7 +65,7 @@ void SpriteFrameCache::destroyInstance() CC_SAFE_RELEASE_NULL(_sharedSpriteFrameCache); } -bool SpriteFrameCache::init(void) +bool SpriteFrameCache::init() { _spriteFrames.reserve(20); _spriteFramesAliases.reserve(20); @@ -73,7 +73,7 @@ bool SpriteFrameCache::init(void) return true; } -SpriteFrameCache::~SpriteFrameCache(void) +SpriteFrameCache::~SpriteFrameCache() { CC_SAFE_DELETE(_loadedFileNames); } @@ -132,13 +132,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu ow = abs(ow); oh = abs(oh); // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - Rect(x, y, w, h), - false, - Vec2(ox, oy), - Size((float)ow, (float)oh) - ); + spriteFrame = SpriteFrame::createWithTexture(texture, + Rect(x, y, w, h), + false, + Vec2(ox, oy), + Size((float)ow, (float)oh) + ); } else if(format == 1 || format == 2) { @@ -155,13 +154,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu Size sourceSize = SizeFromString(frameDict["sourceSize"].asString()); // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - frame, - rotated, - offset, - sourceSize - ); + spriteFrame = SpriteFrame::createWithTexture(texture, + frame, + rotated, + offset, + sourceSize + ); } else if (format == 3) { @@ -186,26 +184,30 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu } // create frame - spriteFrame = new SpriteFrame(); - spriteFrame->initWithTexture(texture, - Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), - textureRotated, - spriteOffset, - spriteSourceSize); + spriteFrame = SpriteFrame::createWithTexture(texture, + Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height), + textureRotated, + spriteOffset, + spriteSourceSize); } // add sprite frame _spriteFrames.insert(spriteFrameName, spriteFrame); - spriteFrame->release(); } } -void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture) +void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, Texture2D *texture) { - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist); + if (_loadedFileNames->find(plist) != _loadedFileNames->end()) + { + return; // We already added it + } + + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); - addSpriteFramesWithDictionary(dict, pobTexture); + addSpriteFramesWithDictionary(dict, texture); + _loadedFileNames->insert(plist); } void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) @@ -223,13 +225,13 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const s } } -void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist) +void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist) { - CCASSERT(pszPlist.size()>0, "plist filename should not be nullptr"); + CCASSERT(plist.size()>0, "plist filename should not be nullptr"); - if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end()) + if (_loadedFileNames->find(plist) == _loadedFileNames->end()) { - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist); + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); string texturePath(""); @@ -244,12 +246,12 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist) if (!texturePath.empty()) { // build texture path relative to plist file - texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), pszPlist); + texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), plist); } else { // build texture path by replacing file extension - texturePath = pszPlist; + texturePath = plist; // remove .xxx size_t startPos = texturePath.find_last_of("."); @@ -266,7 +268,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist) if (texture) { addSpriteFramesWithDictionary(dict, texture); - _loadedFileNames->insert(pszPlist); + _loadedFileNames->insert(plist); } else { diff --git a/cocos/2d/CCSpriteFrameCache.h b/cocos/2d/CCSpriteFrameCache.h index 7e01d33e7d..b9eaa2973c 100644 --- a/cocos/2d/CCSpriteFrameCache.h +++ b/cocos/2d/CCSpriteFrameCache.h @@ -61,7 +61,7 @@ class CC_DLL SpriteFrameCache : public Ref { public: /** Returns the shared instance of the Sprite Frame cache */ - static SpriteFrameCache* getInstance(void); + static SpriteFrameCache* getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static SpriteFrameCache* sharedSpriteFrameCache() { return SpriteFrameCache::getInstance(); } @@ -82,7 +82,7 @@ public: * @lua NA */ virtual ~SpriteFrameCache(); - bool init(void); + bool init(); public: /** Adds multiple Sprite Frames from a plist file. diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 9a49232431..fb2b1171ac 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -263,13 +263,13 @@ void TextFieldTTF::setTextColor(const Color4B &color) Label::setTextColor(_colorText); } -void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { - if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated)) + if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentFlags)) { return; } - Label::visit(renderer,parentTransform,parentTransformUpdated); + Label::visit(renderer,parentTransform,parentFlags); } const Color4B& TextFieldTTF::getColorSpaceHolder() diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 5c4eb4f54d..ee2f36ef5e 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -86,7 +86,7 @@ public: /** @brief If the sender doesn't want to draw, return true. */ - virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, bool transformUpdated) + virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, uint32_t flags) { CC_UNUSED_PARAM(sender); return false; @@ -165,7 +165,7 @@ public: virtual void setSecureTextEntry(bool value); virtual bool isSecureTextEntry(); - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; protected: ////////////////////////////////////////////////////////////////////////// diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 492a820ca0..7546bd9a34 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -103,16 +103,16 @@ void TransitionScene::sceneOrder() _isInSceneOnTop = true; } -void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Scene::draw(renderer, transform, transformUpdated); + Scene::draw(renderer, transform, flags); if( _isInSceneOnTop ) { - _outScene->visit(renderer, transform, transformUpdated); - _inScene->visit(renderer, transform, transformUpdated); + _outScene->visit(renderer, transform, flags); + _inScene->visit(renderer, transform, flags); } else { - _inScene->visit(renderer, transform, transformUpdated); - _outScene->visit(renderer, transform, transformUpdated); + _inScene->visit(renderer, transform, flags); + _outScene->visit(renderer, transform, flags); } } @@ -1261,7 +1261,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene) return nullptr; } -void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // override draw since both scenes (textures) are rendered in 1 scene } @@ -1410,19 +1410,19 @@ void TransitionTurnOffTiles::onExit() TransitionScene::onExit(); } -void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Scene::draw(renderer, transform, transformUpdated); + Scene::draw(renderer, transform, flags); if( _isInSceneOnTop ) { - _outSceneProxy->visit(renderer, transform, transformUpdated); - _inScene->visit(renderer, transform, transformUpdated); + _outSceneProxy->visit(renderer, transform, flags); + _inScene->visit(renderer, transform, flags); } else { - _inScene->visit(renderer, transform, transformUpdated); - _outSceneProxy->visit(renderer, transform, transformUpdated); + _inScene->visit(renderer, transform, flags); + _outSceneProxy->visit(renderer, transform, flags); } } @@ -1490,10 +1490,10 @@ void TransitionSplitCols::switchTargetToInscene() _gridProxy->setTarget(_inScene); } -void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Scene::draw(renderer, transform, transformUpdated); - _gridProxy->visit(renderer, transform, transformUpdated); + Scene::draw(renderer, transform, flags); + _gridProxy->visit(renderer, transform, flags); } void TransitionSplitCols::onExit() @@ -1606,19 +1606,19 @@ void TransitionFadeTR::onExit() TransitionScene::onExit(); } -void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Scene::draw(renderer, transform, transformUpdated); + Scene::draw(renderer, transform, flags); if( _isInSceneOnTop ) { - _outSceneProxy->visit(renderer, transform, transformUpdated); - _inScene->visit(renderer, transform, transformUpdated); + _outSceneProxy->visit(renderer, transform, flags); + _inScene->visit(renderer, transform, flags); } else { - _inScene->visit(renderer, transform, transformUpdated); - _outSceneProxy->visit(renderer, transform, transformUpdated); + _inScene->visit(renderer, transform, flags); + _outSceneProxy->visit(renderer, transform, flags); } } diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 1d8cd84eb0..a065dfc419 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -91,7 +91,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void onEnter() override; virtual void onExit() override; virtual void cleanup() override; @@ -613,7 +613,7 @@ public : * @js NA * @lua NA */ - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; /** * @js NA * @lua NA @@ -651,7 +651,7 @@ public : virtual void onEnter() override; virtual void onExit() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: TransitionTurnOffTiles(); @@ -684,7 +684,7 @@ public: virtual void onEnter() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: TransitionSplitCols(); virtual ~TransitionSplitCols(); @@ -735,7 +735,7 @@ public: virtual void onEnter() override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; virtual void onExit() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: TransitionFadeTR(); virtual ~TransitionFadeTR(); diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 5fc9f40311..83264a2a4a 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -92,27 +92,27 @@ void TransitionPageTurn::onDisablePolygonOffset() glPolygonOffset(0, 0); } -void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Scene::draw(renderer, transform, transformUpdated); + Scene::draw(renderer, transform, flags); if( _isInSceneOnTop ) { - _outSceneProxy->visit(renderer, transform, transformUpdated); + _outSceneProxy->visit(renderer, transform, flags); _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); renderer->addCommand(&_enableOffsetCmd); - _inSceneProxy->visit(renderer, transform, transformUpdated); + _inSceneProxy->visit(renderer, transform, flags); _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); renderer->addCommand(&_disableOffsetCmd); } else { - _inSceneProxy->visit(renderer, transform, transformUpdated); + _inSceneProxy->visit(renderer, transform, flags); _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); renderer->addCommand(&_enableOffsetCmd); - _outSceneProxy->visit(renderer, transform, transformUpdated); + _outSceneProxy->visit(renderer, transform, flags); _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index c12339418a..a34fc19946 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -72,7 +72,7 @@ public: // // Overrides // - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; /** * Creates a base transition with duration and incoming scene. diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 08ffc2fc9e..f632b40d24 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -218,6 +218,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -399,6 +400,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 8b792ef611..2755aa6244 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -565,6 +565,9 @@ 3d + + base + @@ -1144,6 +1147,9 @@ 3d + + base + diff --git a/cocos/3d/CCObjLoader.cpp b/cocos/3d/CCObjLoader.cpp index 939de77984..4c5da0d89e 100644 --- a/cocos/3d/CCObjLoader.cpp +++ b/cocos/3d/CCObjLoader.cpp @@ -603,7 +603,8 @@ std::string ObjLoader::LoadObj(shapes_t& shapes, const char* filename, const cha std::vector face; while (!isNewLine(token[0])) { - vertex_index vi = parseTriple(token, v.size() / 3, vn.size() / 3, vt.size() / 2); + // fix warning, cast to int, i think int is enough + vertex_index vi = parseTriple(token, (int)v.size() / 3, (int)vn.size() / 3, (int)vt.size() / 2); face.push_back(vi); auto n = strspn(token, " \t\r"); token += n; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index c59a00f980..1d94bf74cb 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -279,7 +279,7 @@ void Sprite3D::setTexture(Texture2D* texture) } } -void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { GLProgramState* programstate = getGLProgramState(); Color4F color(getDisplayedColor()); diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index cfbbf96a4b..3f5e72c009 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -73,7 +73,7 @@ protected: //load from .c3b or .c3t bool loadFromC3x(const std::string& path); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual GLProgram* getDefaultGLProgram(bool textured = true); diff --git a/cocos/Android.mk b/cocos/Android.mk index 70603cfd6a..1112b4abd9 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -132,6 +132,7 @@ base/ccUTF8.cpp \ base/ccUtils.cpp \ base/etc1.cpp \ base/s3tc.cpp \ +base/ObjectFactory.cpp \ renderer/CCBatchCommand.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCGLProgram.cpp \ diff --git a/cocos/base/CCAutoreleasePool.cpp b/cocos/base/CCAutoreleasePool.cpp index d5e35a01c4..06bedcd948 100644 --- a/cocos/base/CCAutoreleasePool.cpp +++ b/cocos/base/CCAutoreleasePool.cpp @@ -111,8 +111,7 @@ PoolManager* PoolManager::getInstance() { s_singleInstance = new PoolManager(); // Add the first auto release pool - s_singleInstance->_curReleasePool = new AutoreleasePool("cocos2d autorelease pool"); - s_singleInstance->_releasePoolStack.push_back(s_singleInstance->_curReleasePool); + new AutoreleasePool("cocos2d autorelease pool"); } return s_singleInstance; } @@ -125,6 +124,7 @@ void PoolManager::destroyInstance() PoolManager::PoolManager() { + _releasePoolStack.reserve(10); } PoolManager::~PoolManager() @@ -134,7 +134,6 @@ PoolManager::~PoolManager() while (!_releasePoolStack.empty()) { AutoreleasePool* pool = _releasePoolStack.back(); - _releasePoolStack.pop_back(); delete pool; } @@ -143,7 +142,7 @@ PoolManager::~PoolManager() AutoreleasePool* PoolManager::getCurrentPool() const { - return _curReleasePool; + return _releasePoolStack.back(); } bool PoolManager::isObjectInPools(Ref* obj) const @@ -159,21 +158,12 @@ bool PoolManager::isObjectInPools(Ref* obj) const void PoolManager::push(AutoreleasePool *pool) { _releasePoolStack.push_back(pool); - _curReleasePool = pool; } void PoolManager::pop() { - // Can not pop the pool that created by engine - CC_ASSERT(_releasePoolStack.size() >= 1); - + CC_ASSERT(!_releasePoolStack.empty()); _releasePoolStack.pop_back(); - - // Should update _curReleasePool if a temple pool is released - if (_releasePoolStack.size() > 1) - { - _curReleasePool = _releasePoolStack.back(); - } } NS_CC_END diff --git a/cocos/base/CCAutoreleasePool.h b/cocos/base/CCAutoreleasePool.h index 8ceaa5c879..6d1134a77e 100644 --- a/cocos/base/CCAutoreleasePool.h +++ b/cocos/base/CCAutoreleasePool.h @@ -163,8 +163,7 @@ private: static PoolManager* s_singleInstance; - std::deque _releasePoolStack; - AutoreleasePool *_curReleasePool; + std::vector _releasePoolStack; }; // end of base_nodes group diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index d289c6669e..744d31ac80 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -65,6 +65,7 @@ #include "base/base64.h" NS_CC_BEGIN +extern const char* cocos2dVersion(void); //TODO: these general utils should be in a seperate class // // Trimming functions were taken from: http://stackoverflow.com/a/217605 @@ -295,6 +296,9 @@ Console::Console() { "director", "director commands, type -h or [director help] to list supported directives", std::bind(&Console::commandDirector, this, std::placeholders::_1, std::placeholders::_2) }, { "touch", "simulate touch event via console, type -h or [touch help] to list supported directives", std::bind(&Console::commandTouch, this, std::placeholders::_1, std::placeholders::_2) }, { "upload", "upload file. Args: [filename base64_encoded_data]", std::bind(&Console::commandUpload, this, std::placeholders::_1) }, + { "version", "print version string ", [](int fd, const std::string& args) { + mydprintf(fd, "%s\n", cocos2dVersion()); + } }, }; ; diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 791482c1b8..9d1e02f187 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -92,7 +92,8 @@ Director* Director::getInstance() { if (!s_SharedDirector) { - s_SharedDirector = new DisplayLinkDirector(); + s_SharedDirector = new (std::nothrow) DisplayLinkDirector(); + CCASSERT(s_SharedDirector, "FATAL: Not enough memory"); s_SharedDirector->init(); } @@ -1091,9 +1092,9 @@ void Director::showStats() Mat4 identity = Mat4::IDENTITY; - _drawnVerticesLabel->visit(_renderer, identity, false); - _drawnBatchesLabel->visit(_renderer, identity, false); - _FPSLabel->visit(_renderer, identity, false); + _drawnVerticesLabel->visit(_renderer, identity, 0); + _drawnBatchesLabel->visit(_renderer, identity, 0); + _FPSLabel->visit(_renderer, identity, 0); } } diff --git a/cocos/base/CCScheduler.cpp b/cocos/base/CCScheduler.cpp index 3688f74a3c..9edbaa6c0e 100644 --- a/cocos/base/CCScheduler.cpp +++ b/cocos/base/CCScheduler.cpp @@ -465,13 +465,28 @@ void Scheduler::schedulePerFrame(const ccSchedulerFunc& callback, void *target, HASH_FIND_PTR(_hashForUpdates, &target, hashElement); if (hashElement) { -#if COCOS2D_DEBUG >= 1 - CCASSERT(hashElement->entry->markedForDeletion,""); -#endif - // TODO: check if priority has changed! - - hashElement->entry->markedForDeletion = false; - return; + // check if priority has changed + if ((*hashElement->list)->priority != priority) + { + if (_updateHashLocked) + { + CCLOG("warning: you CANNOT change update priority in scheduled function"); + hashElement->entry->markedForDeletion = false; + hashElement->entry->paused = paused; + return; + } + else + { + // will be added again outside if (hashElement). + unscheduleUpdate(target); + } + } + else + { + hashElement->entry->markedForDeletion = false; + hashElement->entry->paused = paused; + return; + } } // most of the updates are going to be 0, that's way there diff --git a/cocos/base/CCUserDefault.cpp b/cocos/base/CCUserDefault.cpp index 884e383171..2c19feb45c 100644 --- a/cocos/base/CCUserDefault.cpp +++ b/cocos/base/CCUserDefault.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "tinyxml2.h" #include "base/base64.h" -#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) // root name of xml #define USERDEFAULT_ROOT_NAME "userDefaultRoot" diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index 0b628db4ac..701c8ba5a6 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -41,4 +41,5 @@ set(COCOS_BASE_SRC base/ccUtils.cpp base/etc1.cpp base/s3tc.cpp + base/ObjectFactory.cpp ) diff --git a/cocos/base/ObjectFactory.cpp b/cocos/base/ObjectFactory.cpp new file mode 100644 index 0000000000..3179b5f1f6 --- /dev/null +++ b/cocos/base/ObjectFactory.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +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 "ObjectFactory.h" + + +NS_CC_BEGIN + +ObjectFactory::TInfo::TInfo(void) +:_class("") +,_fun(nullptr) +{ +} + +ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins) +:_class(type) +,_fun(ins) +{ + ObjectFactory::getInstance()->registerType(*this); +} + +ObjectFactory::TInfo::TInfo(const TInfo &t) +{ + _class = t._class; + _fun = t._fun; +} + +ObjectFactory::TInfo::~TInfo(void) +{ + _class = ""; + _fun = nullptr; +} + +ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t) +{ + _class = t._class; + _fun = t._fun; + return *this; +} + + +ObjectFactory* ObjectFactory::_sharedFactory = nullptr; + +ObjectFactory::ObjectFactory(void) +{ + +} + +ObjectFactory::~ObjectFactory(void) +{ + _typeMap.clear(); +} + +ObjectFactory* ObjectFactory::getInstance() +{ + if ( nullptr == _sharedFactory) + { + _sharedFactory = new ObjectFactory(); + } + return _sharedFactory; +} + +void ObjectFactory::destroyInstance() +{ + CC_SAFE_DELETE(_sharedFactory); +} + +Ref* ObjectFactory::createObject(const std::string &name) +{ + Ref *o = nullptr; + do + { + const TInfo t = _typeMap[name]; + CC_BREAK_IF(t._fun == nullptr); + o = t._fun(); + } while (0); + + return o; +} + +void ObjectFactory::registerType(const TInfo &t) +{ + _typeMap.insert(std::make_pair(t._class, t)); +} + +NS_CC_END diff --git a/cocos/ui/UIScrollInterface.h b/cocos/base/ObjectFactory.h similarity index 59% rename from cocos/ui/UIScrollInterface.h rename to cocos/base/ObjectFactory.h index a1cbdf484d..4d5e537e2f 100644 --- a/cocos/ui/UIScrollInterface.h +++ b/cocos/base/ObjectFactory.h @@ -22,27 +22,47 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __UISCROLLDELEGATE_H__ -#define __UISCROLLDELEGATE_H__ +#ifndef __TRIGGERFACTORY_H__ +#define __TRIGGERFACTORY_H__ -#include "ui/UIWidget.h" +#include +#include +#include "base/CCRef.h" +#include "base/CCPlatformMacros.h" NS_CC_BEGIN -namespace ui { - -class ScrollViewProtocol +class ObjectFactory { public: - virtual ~ScrollViewProtocol() {} + typedef cocos2d::Ref* (*Instance)(void); + struct TInfo + { + TInfo(void); + TInfo(const std::string& type, Instance ins = NULL); + TInfo(const TInfo &t); + ~TInfo(void); + TInfo& operator= (const TInfo &t); + std::string _class; + Instance _fun; + }; + typedef std::unordered_map FactoryMap; + + static ObjectFactory* getInstance(); + static void destroyInstance(); + cocos2d::Ref* createObject(const std::string &name); + + void registerType(const TInfo &t); + void removeAll(); protected: - virtual void handlePressLogic(const Vec2 &touchPoint) = 0; - virtual void handleMoveLogic(const Vec2 &touchPoint) = 0; - virtual void handleReleaseLogic(const Vec2 &touchPoint) = 0; + ObjectFactory(void); + virtual ~ObjectFactory(void); +private: + static ObjectFactory *_sharedFactory; + FactoryMap _typeMap; }; -} NS_CC_END -#endif /* defined(__UIScrollDelegate__) */ +#endif diff --git a/cocos/base/ccTypes.h b/cocos/base/ccTypes.h index f447c4de5b..a8d5f62d96 100644 --- a/cocos/base/ccTypes.h +++ b/cocos/base/ccTypes.h @@ -328,7 +328,7 @@ struct BlendFunc bool operator<(const BlendFunc &a) const { - return src < a.src || (src < a.src && dst < a.dst); + return src < a.src || (src == a.src && dst < a.dst); } }; diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 98cb708b91..1e795488b2 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -29,8 +29,8 @@ THE SOFTWARE. #define __COCOS2D_H__ // 0x00 HI ME LO -// 00 03 01 00 -#define COCOS2D_VERSION 0x00030100 +// 00 03 02 00 +#define COCOS2D_VERSION 0x00030200 // // all cocos2d include files diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index c124991a0d..cfddcb1d99 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -36,7 +36,6 @@ CCInputDelegate.cpp \ DictionaryHelper.cpp \ CCSGUIReader.cpp \ CCSSceneReader.cpp \ -ObjectFactory.cpp \ TriggerBase.cpp \ TriggerMng.cpp \ TriggerObj.cpp \ diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 6177661b38..aa7b32335b 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -378,7 +378,7 @@ void Armature::update(float dt) _armatureTransformDirty = false; } -void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (_parentBone == nullptr && _batchNode == nullptr) { @@ -408,17 +408,17 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra { skin->setBlendFunc(bone->getBlendFunc()); } - skin->draw(renderer, transform, transformUpdated); + skin->draw(renderer, transform, flags); } break; case CS_DISPLAY_ARMATURE: { - node->draw(renderer, transform, transformUpdated); + node->draw(renderer, transform, flags); } break; default: { - node->visit(renderer, transform, transformUpdated); + node->visit(renderer, transform, flags); // CC_NODE_DRAW_SETUP(); } break; @@ -426,7 +426,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra } else if(Node *node = dynamic_cast(object)) { - node->visit(renderer, transform, transformUpdated); + node->visit(renderer, transform, flags); // CC_NODE_DRAW_SETUP(); } } @@ -445,7 +445,7 @@ void Armature::onExit() } -void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -453,10 +453,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b return; } - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, @@ -468,7 +465,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b sortAllChildren(); - draw(renderer, _modelViewTransform, dirty); + draw(renderer, _modelViewTransform, flags); // reset for next frame _orderOfArrival = 0; diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index 53286c873f..b151868753 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -157,8 +157,8 @@ public: * @js NA * @lua NA */ - virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; virtual void update(float dt) override; virtual void onEnter() override; diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 78129398c5..6844a43d69 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -101,7 +101,7 @@ void BatchNode::removeChild(Node* child, bool cleanup) Node::removeChild(child, cleanup); } -void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -109,21 +109,17 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare return; } - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, // but it is deprecated and your code should not rely on it Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); sortAllChildren(); - draw(renderer, _modelViewTransform, dirty); + draw(renderer, _modelViewTransform, flags); // reset for next frame _orderOfArrival = 0; @@ -131,7 +127,7 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void BatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (_children.empty()) { @@ -152,14 +148,14 @@ void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUp pushed = true; } - armature->visit(renderer, transform, transformUpdated); + armature->visit(renderer, transform, flags); } else { renderer->popGroup(); pushed = false; - ((Node *)object)->visit(renderer, transform, transformUpdated); + ((Node *)object)->visit(renderer, transform, flags); } } } diff --git a/cocos/editor-support/cocostudio/CCBatchNode.h b/cocos/editor-support/cocostudio/CCBatchNode.h index 8288506201..a49e23f36d 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.h +++ b/cocos/editor-support/cocostudio/CCBatchNode.h @@ -56,8 +56,8 @@ public: virtual void addChild(cocos2d::Node *pChild, int zOrder) override; virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override; virtual void removeChild(cocos2d::Node* child, bool cleanup) override; - virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; protected: void generateGroupCommand(); diff --git a/cocos/editor-support/cocostudio/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index b2fe13fbfd..2c4311690b 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.cpp +++ b/cocos/editor-support/cocostudio/CCComAttribute.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComAttribute.h" +#include "platform/CCFileUtils.h" using namespace cocos2d; @@ -166,7 +167,7 @@ bool ComAttribute::serialize(void* r) std::string filePath; if (file != nullptr) { - filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); + filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); } int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); CC_BREAK_IF(resType != 0); diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index 3919d6ca56..5feecf2595 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -26,6 +26,8 @@ THE SOFTWARE. #define __CC_EXTENTIONS_CCCOMATTRIBUTE_H__ #include "CCComBase.h" +#include "2d/CCComponent.h" +#include "base/CCValue.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCComAudio.cpp b/cocos/editor-support/cocostudio/CCComAudio.cpp index eef5f62325..8fedf09c0e 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.cpp +++ b/cocos/editor-support/cocostudio/CCComAudio.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "cocostudio/CCComAudio.h" #include "audio/include/SimpleAudioEngine.h" +#include "platform/CCFileUtils.h" namespace cocostudio { @@ -91,7 +92,7 @@ bool ComAudio::serialize(void* r) std::string filePath; if (file != nullptr) { - filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); + filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); } int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); CC_BREAK_IF(resType != 0); diff --git a/cocos/editor-support/cocostudio/CCComAudio.h b/cocos/editor-support/cocostudio/CCComAudio.h index 4bbb97bb47..1643082307 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.h +++ b/cocos/editor-support/cocostudio/CCComAudio.h @@ -26,6 +26,7 @@ THE SOFTWARE. #define __CC_EXTENTIONS_CCCOMAUDIO_H__ #include "CCComBase.h" +#include "2d/CCComponent.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCComBase.h b/cocos/editor-support/cocostudio/CCComBase.h index 050d275848..461a5a4b8e 100644 --- a/cocos/editor-support/cocostudio/CCComBase.h +++ b/cocos/editor-support/cocostudio/CCComBase.h @@ -25,14 +25,14 @@ THE SOFTWARE. #ifndef __CC_EXTENTIONS_CCCOMBASE_H__ #define __CC_EXTENTIONS_CCCOMBASE_H__ -#include "ObjectFactory.h" -#include "DictionaryHelper.h" #include +#include "DictionaryHelper.h" +#include "base/ObjectFactory.h" #define DECLARE_CLASS_COMPONENT_INFO \ public: \ - static cocostudio::ObjectFactory::TInfo Type; \ + static cocos2d::ObjectFactory::TInfo Type; \ static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_COMPONENT_INFO(className) \ @@ -40,10 +40,10 @@ THE SOFTWARE. { \ return className::create(); \ } \ - cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ + cocos2d::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ #define CREATE_CLASS_COMPONENT_INFO(className) \ - cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) + cocos2d::ObjectFactory::TInfo(#className, &className::createInstance) #endif diff --git a/cocos/editor-support/cocostudio/CCComController.cpp b/cocos/editor-support/cocostudio/CCComController.cpp index c69ca0e314..3164eab3fd 100644 --- a/cocos/editor-support/cocostudio/CCComController.cpp +++ b/cocos/editor-support/cocostudio/CCComController.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComController.h" +#include "2d/CCNode.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCComController.h b/cocos/editor-support/cocostudio/CCComController.h index d68b25559c..4428d93f89 100644 --- a/cocos/editor-support/cocostudio/CCComController.h +++ b/cocos/editor-support/cocostudio/CCComController.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include "CCComBase.h" #include "cocostudio/CCInputDelegate.h" +#include "2d/CCComponent.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCComRender.h b/cocos/editor-support/cocostudio/CCComRender.h index b2b94f3305..9598ec57ab 100644 --- a/cocos/editor-support/cocostudio/CCComRender.h +++ b/cocos/editor-support/cocostudio/CCComRender.h @@ -26,6 +26,7 @@ THE SOFTWARE. #define __CC_EXTENTIONS_CCCOMRENDER_H__ #include "CCComBase.h" +#include "2d/CCComponent.h" namespace cocostudio { diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index abb8396d19..b0f9ec53ee 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -216,6 +216,58 @@ Widget* GUIReader::widgetFromJsonFile(const char *fileName) CC_SAFE_DELETE(pReader); return widget; } + + + +std::string WidgetPropertiesReader::getGUIClassName(const std::string &name) +{ + std::string convertedClassName = name; + if (name == "Panel") + { + convertedClassName = "Layout"; + } + else if (name == "TextArea") + { + convertedClassName = "Text"; + } + else if (name == "TextButton") + { + convertedClassName = "Button"; + } + else if (name == "Label") + { + convertedClassName = "Text"; + } + else if (name == "LabelAtlas") + { + convertedClassName = "TextAtlas"; + } + else if (name == "LabelBMFont") + { + convertedClassName = "TextBMFont"; + } + + + return convertedClassName; +} + +cocos2d::ui::Widget* WidgetPropertiesReader::createGUI(const std::string &classname) +{ + std::string name = this->getGUIClassName(classname); + + Ref* object = ObjectFactory::getInstance()->createObject(name); + + return dynamic_cast(object); +} + +WidgetReaderProtocol* WidgetPropertiesReader::createWidgetReaderProtocol(const std::string &classname) +{ + Ref* object = ObjectFactory::getInstance()->createObject(classname); + + return dynamic_cast(object); +} + + void WidgetPropertiesReader::setAnchorPointForWidget(cocos2d::ui::Widget *widget, const rapidjson::Value &options) @@ -1001,7 +1053,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va { const char* classname = DICTOOL->getStringValue_json(data, "classname"); const rapidjson::Value& uiOptions = DICTOOL->getSubDictionary_json(data, "options"); - Widget* widget = ObjectFactory::getInstance()->createGUI(classname); + Widget* widget = this->createGUI(classname); // create widget reader to parse properties of widget std::string readerName = classname; @@ -1030,7 +1082,8 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va readerName = "TextBMFont"; } readerName.append("Reader"); - WidgetReaderProtocol* reader = ObjectFactory::getInstance()->createWidgetReaderProtocol(readerName); + + WidgetReaderProtocol* reader = this->createWidgetReaderProtocol(readerName); if (reader) { @@ -1096,7 +1149,9 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va { readerName = "WidgetReader"; } - reader = ObjectFactory::getInstance()->createWidgetReaderProtocol(readerName); + + reader = dynamic_cast(ObjectFactory::getInstance()->createObject(readerName)); + setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); // 2nd., custom widget parse with custom reader diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 17b8fa16af..999e9435fa 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -28,10 +28,12 @@ THE SOFTWARE. #include "ui/UIWidget.h" #include "cocostudio/DictionaryHelper.h" #include "WidgetReader/WidgetReaderProtocol.h" -#include "ObjectFactory.h" +#include "base/ObjectFactory.h" + namespace cocostudio { + #define kCCSVersion 1.0 typedef void (cocos2d::Ref::*SEL_ParseEvent)(const std::string&, cocos2d::Ref*, const rapidjson::Value&); @@ -59,7 +61,7 @@ public: const std::string& getFilePath() const { return m_strFilePath; }; void registerTypeAndCallBack(const std::string& classType, - ObjectFactory::Instance ins, + cocos2d::ObjectFactory::Instance ins, Ref* object, SEL_ParseEvent callBack); @@ -94,6 +96,10 @@ public: protected: void setAnchorPointForWidget(cocos2d::ui::Widget* widget, const rapidjson::Value&options); + std::string getGUIClassName(const std::string& name); + cocos2d::ui::Widget *createGUI(const std::string& classname); + WidgetReaderProtocol* createWidgetReaderProtocol(const std::string& classname); + protected: std::string m_strFilePath; }; diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 52adc3e656..02c2b21020 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -110,7 +110,44 @@ Node* SceneReader::nodeByTag(Node *parent, int tag) } return _retNode; } - + +cocos2d::Component* SceneReader::createComponent(const std::string classname) +{ + std::string name = this->getComponentClassName(classname); + Ref *object = ObjectFactory::getInstance()->createObject(name); + + return dynamic_cast(object); +} +std::string SceneReader::getComponentClassName(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!"); + } + + return comName; +} Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent, AttachComponentType attachComponent) { @@ -134,7 +171,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par break; } const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); - Component *com = ObjectFactory::getInstance()->createComponent(comName); + Component *com = this->createComponent(comName); if (com != nullptr) { if (com->serialize((void*)(&subDict))) diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index e61ffff3c0..d80fa1b2d5 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -68,6 +68,10 @@ public: private: SceneReader(void); virtual ~SceneReader(void); + std::string getComponentClassName(const std::string& name); + + cocos2d::Component* createComponent(const std::string classname); + cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent, AttachComponentType attachComponent); void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index e1ff9f2521..d7d7a3feab 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -219,7 +219,7 @@ Mat4 Skin::getNodeToWorldTransformAR() const return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform); } -void Skin::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Skin::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { Mat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index 9bd22850ad..67f409274c 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -54,7 +54,7 @@ public: cocos2d::Mat4 getNodeToWorldTransform() const override; cocos2d::Mat4 getNodeToWorldTransformAR() const; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; /** * @js NA diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index 7af96e4bbe..aeb1b0a265 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -30,7 +30,6 @@ set(CS_SRC DictionaryHelper.cpp CCSGUIReader.cpp CCSSceneReader.cpp - ObjectFactory.cpp TriggerBase.cpp TriggerMng.cpp TriggerObj.cpp diff --git a/cocos/editor-support/cocostudio/TriggerBase.h b/cocos/editor-support/cocostudio/TriggerBase.h index 27e5ae0dcc..c5c6fe5c6f 100755 --- a/cocos/editor-support/cocostudio/TriggerBase.h +++ b/cocos/editor-support/cocostudio/TriggerBase.h @@ -27,14 +27,14 @@ THE SOFTWARE. #include "cocos2d.h" #include "cocostudio/CocoStudio.h" -#include "ObjectFactory.h" +#include "base/ObjectFactory.h" #include "TriggerObj.h" #include "TriggerMng.h" #define DECLARE_CLASS_INFO \ public: \ - static cocostudio::ObjectFactory::TInfo Type; \ + static cocos2d::ObjectFactory::TInfo Type; \ static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_INFO(className) \ @@ -44,7 +44,7 @@ THE SOFTWARE. ret->autorelease(); \ return ret; \ } \ - cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ + cocos2d::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ void sendEvent(unsigned int event); diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj index f87a9f3f36..bcd24723d6 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj @@ -42,7 +42,6 @@ - @@ -207,4 +206,4 @@ - \ No newline at end of file + diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters index 9172a7e571..655cb64627 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters @@ -177,9 +177,6 @@ action - - trigger - trigger @@ -417,4 +414,4 @@ reader\WidgetReader\PageViewReader - \ No newline at end of file + diff --git a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj index 7b156dd888..8c3b1e5b08 100644 --- a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj @@ -194,7 +194,6 @@ - @@ -283,4 +282,4 @@ - \ No newline at end of file + diff --git a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj.filters b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj.filters index cba46f39b9..18070a5586 100644 --- a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj.filters +++ b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj.filters @@ -177,9 +177,6 @@ action - - trigger - trigger @@ -419,4 +416,4 @@ - \ No newline at end of file + diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 16d9c4b8c6..ec8ed6b9ff 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -125,15 +125,15 @@ void Skeleton::update (float deltaTime) { spSkeleton_update(skeleton, deltaTime * timeScale); } -void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void Skeleton::onDraw(const Mat4 &transform, bool transformUpdated) +void Skeleton::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index dbcde2fb2c..fa468e9880 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -67,8 +67,8 @@ public: virtual ~Skeleton (); virtual void update (float deltaTime) override; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; - void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated); + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; + void onDraw(const cocos2d::Mat4 &transform, uint32_t flags); void onEnter() override; void onExit() override; virtual cocos2d::Rect getBoundingBox () const override; diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index aa1e572159..f4c8604b3a 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -39,6 +39,26 @@ THE SOFTWARE. extern "C" { + // To resolve link error when building 32bits with Xcode 6. + // More information please refer to the discussion in https://github.com/cocos2d/cocos2d-x/pull/6986 +#if defined(__APPLE__) || defined(__unix) +#ifndef __ENABLE_COMPATIBILITY_WITH_UNIX_2003__ +#define __ENABLE_COMPATIBILITY_WITH_UNIX_2003__ +#include + FILE *fopen$UNIX2003( const char *filename, const char *mode ) + { + return fopen(filename, mode); + } + size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d ) + { + return fwrite(a, b, c, d); + } + char *strerror$UNIX2003( int errnum ) + { + return strerror(errnum); + } +#endif +#endif #include "png.h" #include "tiffio.h" #include "base/etc1.h" @@ -961,7 +981,15 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) png_read_end(png_ptr, nullptr); - _preMulti = false; + // premultiplied alpha for RGBA8888 + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + premultipliedAlpha(); + } + else + { + _preMulti = false; + } if (row_pointers != nullptr) { @@ -1542,7 +1570,9 @@ bool Image::initWithTGAData(tImageTGA* tgaData) _data = tgaData->imageData; _dataLen = _width * _height * tgaData->pixelDepth / 8; _fileType = Format::TGA; + _preMulti = false; + ret = true; }while(false); @@ -2175,5 +2205,19 @@ bool Image::saveImageToJPG(const std::string& filePath) return bRet; } +void Image::premultipliedAlpha() +{ + CCASSERT(_renderFormat == Texture2D::PixelFormat::RGBA8888, "The pixel format should be RGBA8888!"); + + unsigned int* fourBytes = (unsigned int*)_data; + for(int i = 0; i < _width * _height; i++) + { + unsigned char* p = _data + i * 4; + fourBytes[i] = CC_RGB_PREMULTIPLY_ALPHA(p[0], p[1], p[2], p[3]); + } + + _preMulti = true; +} + NS_CC_END diff --git a/cocos/platform/CCImage.h b/cocos/platform/CCImage.h index 6762204b05..5c37da9436 100644 --- a/cocos/platform/CCImage.h +++ b/cocos/platform/CCImage.h @@ -155,6 +155,8 @@ protected: bool saveImageToPNG(const std::string& filePath, bool isToRGB = true); bool saveImageToJPG(const std::string& filePath); + void premultipliedAlpha(); + protected: /** @brief Determine how many mipmaps can we have. diff --git a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp index 28b4ba3bbf..5a37af879f 100644 --- a/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp +++ b/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp @@ -1,6 +1,7 @@ #include "base/CCIMEDispatcher.h" #include "base/CCDirector.h" #include "base/CCEventType.h" +#include "base/CCEventCustom.h" #include "../CCApplication.h" #include "platform/CCFileUtils.h" #include "JniHelper.h" @@ -16,6 +17,8 @@ extern "C" { JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { Application::getInstance()->applicationDidEnterBackground(); + cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); + cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { diff --git a/cocos/platform/ios/CCDevice.mm b/cocos/platform/ios/CCDevice.mm index 3a72be780a..5eeaf7ccaa 100644 --- a/cocos/platform/ios/CCDevice.mm +++ b/cocos/platform/ios/CCDevice.mm @@ -128,6 +128,8 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; case UIInterfaceOrientationPortrait: break; + default: + NSAssert(false, @"unknow orientation"); } cocos2d::EventAcceleration event(*_acceleration); diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 68b6c27fb9..a408aac219 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -33,6 +33,10 @@ THE SOFTWARE. #include "renderer/CCGLProgramCache.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCTexture2D.h" +#include "base/CCEventCustom.h" +#include "base/CCEventListenerCustom.h" +#include "base/CCEventType.h" +#include "base/CCDirector.h" NS_CC_BEGIN @@ -272,11 +276,22 @@ GLProgramState::GLProgramState() : _vertexAttribsFlags(0) , _glprogram(nullptr) , _textureUnitIndex(1) +, _uniformAttributeValueDirty(true) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // listen the event when app go to foreground + CCLOG("create _backToForegroundlistener for GLProgramState"); + _backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { _uniformAttributeValueDirty = true; }); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1); +#endif } GLProgramState::~GLProgramState() -{ +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); +#endif + CC_SAFE_RELEASE(_glprogram); } @@ -312,7 +327,24 @@ void GLProgramState::resetGLProgram() void GLProgramState::apply(const Mat4& modelView) { CCASSERT(_glprogram, "invalid glprogram"); - + if(_uniformAttributeValueDirty) + { + for(auto& uniformValue : _uniforms) + { + uniformValue.second._uniform = _glprogram->getUniform(uniformValue.first); + } + + _vertexAttribsFlags = 0; + for(auto& attributeValue : _attributes) + { + attributeValue.second._vertexAttrib = _glprogram->getVertexAttrib(attributeValue.first);; + if(attributeValue.second._enabled) + _vertexAttribsFlags |= 1 << attributeValue.second._vertexAttrib->index; + } + + _uniformAttributeValueDirty = false; + + } // set shader _glprogram->use(); _glprogram->setUniformsForBuiltins(modelView); @@ -322,9 +354,9 @@ void GLProgramState::apply(const Mat4& modelView) if(_vertexAttribsFlags) { // enable/disable vertex attribs GL::enableVertexAttribs(_vertexAttribsFlags); - // set attributes - for(auto &attribute : _attributes) { + for(auto &attribute : _attributes) + { attribute.second.apply(); } } @@ -465,9 +497,21 @@ void GLProgramState::setUniformTexture(const std::string &uniformName, GLuint te { auto v = getUniformValue(uniformName); if (v) - v->setTexture(textureId, _textureUnitIndex++); + { + if (_boundTextureUnits.find(uniformName) != _boundTextureUnits.end()) + { + v->setTexture(textureId, _boundTextureUnits[uniformName]); + } + else + { + v->setTexture(textureId, _textureUnitIndex); + _boundTextureUnits[uniformName] = _textureUnitIndex++; + } + } else + { CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); + } } diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index 11dd923d05..fc30ea7900 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -39,6 +39,8 @@ class GLProgram; class Texture2D; struct Uniform; struct VertexAttrib; +class EventListenerCustom; +class EventCustom; // // @@ -48,7 +50,7 @@ struct VertexAttrib; class UniformValue { friend class GLProgram; - + friend class GLProgramState; public: UniformValue(); UniformValue(Uniform *uniform, GLProgram* glprogram); @@ -177,7 +179,7 @@ public: void setUniformCallback(const std::string &uniformName, const std::function &callback); void setUniformTexture(const std::string &uniformName, Texture2D *texture); void setUniformTexture(const std::string &uniformName, GLuint textureId); - + protected: GLProgramState(); ~GLProgramState(); @@ -185,13 +187,19 @@ protected: void resetGLProgram(); VertexAttribValue* getVertexAttribValue(const std::string &attributeName); UniformValue* getUniformValue(const std::string &uniformName); - + + bool _uniformAttributeValueDirty; std::unordered_map _uniforms; std::unordered_map _attributes; + std::unordered_map _boundTextureUnits; int _textureUnitIndex; uint32_t _vertexAttribsFlags; GLProgram *_glprogram; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + EventListenerCustom* _backToForegroundlistener; +#endif }; NS_CC_END diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index b2025c315e..dfc548899b 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -535,11 +535,6 @@ bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::Pixel mipmap.address = (unsigned char*)data; mipmap.len = static_cast(dataLen); return initWithMipmaps(&mipmap, 1, pixelFormat, pixelsWide, pixelsHigh); - - //update information - _contentSize = contentSize; - _maxS = contentSize.width / (float)(pixelsWide); - _maxT = contentSize.height / (float)(pixelsHigh); } bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh) @@ -709,7 +704,7 @@ std::string Texture2D::getDescription() const // implementation Texture2D (Image) bool Texture2D::initWithImage(Image *image) { - return initWithImage(image, PixelFormat::NONE); + return initWithImage(image, image->getRenderFormat()); } bool Texture2D::initWithImage(Image *image, PixelFormat format) diff --git a/cocos/scripting/lua-bindings/Android.mk b/cocos/scripting/lua-bindings/Android.mk index 5cd2ddad5e..deb09960e1 100644 --- a/cocos/scripting/lua-bindings/Android.mk +++ b/cocos/scripting/lua-bindings/Android.mk @@ -54,7 +54,8 @@ LOCAL_SRC_FILES := manual/CCLuaBridge.cpp \ ../../../external/lua/luasocket/timeout.c \ ../../../external/lua/luasocket/udp.c \ ../../../external/lua/luasocket/unix.c \ - ../../../external/lua/luasocket/usocket.c + ../../../external/lua/luasocket/usocket.c \ + ../../../external/xxtea/xxtea.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../external/lua/tolua \ @@ -68,7 +69,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../external/lua/tolua \ $(LOCAL_PATH)/auto \ $(LOCAL_PATH)/manual \ $(LOCAL_PATH)/manual/platform/android \ - $(LOCAL_PATH)/manual/platform/android/jni + $(LOCAL_PATH)/manual/platform/android/jni \ + $(LOCAL_PATH)/../../../external/xxtea LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../external/lua/tolua \ diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 30d215e573..00db47361c 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -35,6 +35,7 @@ include_directories( ../../ui ../../../external/lua/lua ../../../external/lua/tolua + ../../../external/xxtea ) @@ -46,6 +47,7 @@ target_link_libraries(luabinding tolua lua spine + xxtea ) set_target_properties(luabinding diff --git a/cocos/scripting/lua-bindings/auto/api/Armature.lua b/cocos/scripting/lua-bindings/auto/api/Armature.lua index 9676b5e9b9..b4b18c2dcd 100644 --- a/cocos/scripting/lua-bindings/auto/api/Armature.lua +++ b/cocos/scripting/lua-bindings/auto/api/Armature.lua @@ -148,7 +148,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Armature] getAnchorPointInPoints diff --git a/cocos/scripting/lua-bindings/auto/api/AtlasNode.lua b/cocos/scripting/lua-bindings/auto/api/AtlasNode.lua index 0547ad8f90..d93994cd64 100644 --- a/cocos/scripting/lua-bindings/auto/api/AtlasNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/AtlasNode.lua @@ -51,7 +51,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#AtlasNode] isOpacityModifyRGB diff --git a/cocos/scripting/lua-bindings/auto/api/BatchNode.lua b/cocos/scripting/lua-bindings/auto/api/BatchNode.lua index 5295e0b828..bdb12532a2 100644 --- a/cocos/scripting/lua-bindings/auto/api/BatchNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/BatchNode.lua @@ -31,7 +31,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#BatchNode] removeChild diff --git a/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua b/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua index 4d8874787b..b9978df300 100644 --- a/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/ClippingNode.lua @@ -48,6 +48,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/DrawNode.lua b/cocos/scripting/lua-bindings/auto/api/DrawNode.lua index 9559d3cb69..2fcb7d876d 100644 --- a/cocos/scripting/lua-bindings/auto/api/DrawNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/DrawNode.lua @@ -16,7 +16,7 @@ -- @function [parent=#DrawNode] onDraw -- @param self -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#DrawNode] clear @@ -65,6 +65,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index c4160465fc..158c715090 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -267,7 +267,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Label] addChild @@ -306,7 +306,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Label] getScaleX diff --git a/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua b/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua index e9a08687bd..1e6e09dc33 100644 --- a/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua +++ b/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua @@ -182,7 +182,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#LabelTTF] LabelTTF diff --git a/cocos/scripting/lua-bindings/auto/api/LayerColor.lua b/cocos/scripting/lua-bindings/auto/api/LayerColor.lua index 8ad9f7a5c9..5b24aa4282 100644 --- a/cocos/scripting/lua-bindings/auto/api/LayerColor.lua +++ b/cocos/scripting/lua-bindings/auto/api/LayerColor.lua @@ -38,7 +38,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#LayerColor] getDescription diff --git a/cocos/scripting/lua-bindings/auto/api/Layout.lua b/cocos/scripting/lua-bindings/auto/api/Layout.lua index 86f82de45b..286fb1cd4f 100644 --- a/cocos/scripting/lua-bindings/auto/api/Layout.lua +++ b/cocos/scripting/lua-bindings/auto/api/Layout.lua @@ -204,10 +204,6 @@ -- @function [parent=#Layout] removeAllChildren -- @param self --------------------------------- --- @function [parent=#Layout] sortAllChildren --- @param self - -------------------------------- -- @function [parent=#Layout] findNextFocusedWidget -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/ListView.lua b/cocos/scripting/lua-bindings/auto/api/ListView.lua index c59ad69677..162a34bcf9 100644 --- a/cocos/scripting/lua-bindings/auto/api/ListView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ListView.lua @@ -43,6 +43,10 @@ -- @param self -- @param #long long +-------------------------------- +-- @function [parent=#ListView] requestRefreshView +-- @param self + -------------------------------- -- @function [parent=#ListView] setItemsMargin -- @param self @@ -78,7 +82,7 @@ -- @param #ccui.Widget widget -------------------------------- --- @function [parent=#ListView] requestRefreshView +-- @function [parent=#ListView] doLayout -- @param self -------------------------------- @@ -133,10 +137,6 @@ -- @function [parent=#ListView] removeAllChildren -- @param self --------------------------------- --- @function [parent=#ListView] sortAllChildren --- @param self - -------------------------------- -- @function [parent=#ListView] removeChild -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/Node.lua b/cocos/scripting/lua-bindings/auto/api/Node.lua index 51e97f83f2..7078931e44 100644 --- a/cocos/scripting/lua-bindings/auto/api/Node.lua +++ b/cocos/scripting/lua-bindings/auto/api/Node.lua @@ -167,6 +167,11 @@ -- @param self -- @return unsigned char#unsigned char ret (return value: unsigned char) +-------------------------------- +-- @function [parent=#Node] setNormalizedPosition +-- @param self +-- @param #vec2_table vec2 + -------------------------------- -- @function [parent=#Node] convertTouchToNodeSpace -- @param self @@ -293,6 +298,11 @@ -- @function [parent=#Node] updateTransform -- @param self +-------------------------------- +-- @function [parent=#Node] setGLProgram +-- @param self +-- @param #cc.GLProgram glprogram + -------------------------------- -- @function [parent=#Node] isVisible -- @param self @@ -316,16 +326,11 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- overload function: visit() --- --- overload function: visit(cc.Renderer, mat4_table, bool) --- --- @function [parent=#Node] visit +-- @function [parent=#Node] runAction -- @param self --- @param #cc.Renderer renderer --- @param #mat4_table mat4 --- @param #bool bool - +-- @param #cc.Action action +-- @return Action#Action ret (return value: cc.Action) + -------------------------------- -- @function [parent=#Node] isOpacityModifyRGB -- @param self @@ -342,11 +347,16 @@ -- @return vec2_table#vec2_table ret (return value: vec2_table) -------------------------------- --- @function [parent=#Node] runAction +-- overload function: visit() +-- +-- overload function: visit(cc.Renderer, mat4_table, unsigned int) +-- +-- @function [parent=#Node] visit -- @param self --- @param #cc.Action action --- @return Action#Action ret (return value: cc.Action) - +-- @param #cc.Renderer renderer +-- @param #mat4_table mat4 +-- @param #unsigned int int + -------------------------------- -- @function [parent=#Node] getGLProgramState -- @param self @@ -589,13 +599,13 @@ -------------------------------- -- overload function: draw() -- --- overload function: draw(cc.Renderer, mat4_table, bool) +-- overload function: draw(cc.Renderer, mat4_table, unsigned int) -- -- @function [parent=#Node] draw -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Node] setUserObject @@ -630,16 +640,16 @@ -- @param self -- @return mat4_table#mat4_table ret (return value: mat4_table) --------------------------------- --- @function [parent=#Node] setGLProgram --- @param self --- @param #cc.GLProgram glprogram - -------------------------------- -- @function [parent=#Node] getScale -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- @function [parent=#Node] getNormalizedPosition +-- @param self +-- @return vec2_table#vec2_table ret (return value: vec2_table) + -------------------------------- -- @function [parent=#Node] getRotationSkewX -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/NodeGrid.lua b/cocos/scripting/lua-bindings/auto/api/NodeGrid.lua index a9cf17eb9f..fad5b236bc 100644 --- a/cocos/scripting/lua-bindings/auto/api/NodeGrid.lua +++ b/cocos/scripting/lua-bindings/auto/api/NodeGrid.lua @@ -32,6 +32,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/ParallaxNode.lua b/cocos/scripting/lua-bindings/auto/api/ParallaxNode.lua index 8012fb2601..905d50955e 100644 --- a/cocos/scripting/lua-bindings/auto/api/ParallaxNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/ParallaxNode.lua @@ -38,7 +38,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#ParallaxNode] removeChild diff --git a/cocos/scripting/lua-bindings/auto/api/ParticleBatchNode.lua b/cocos/scripting/lua-bindings/auto/api/ParticleBatchNode.lua index a46e930611..729804b2d6 100644 --- a/cocos/scripting/lua-bindings/auto/api/ParticleBatchNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/ParticleBatchNode.lua @@ -71,14 +71,14 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#ParticleBatchNode] visit -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#ParticleBatchNode] reorderChild diff --git a/cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua b/cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua index f67e8a0e34..6863db2340 100644 --- a/cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua +++ b/cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua @@ -83,7 +83,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#ProgressTimer] setColor diff --git a/cocos/scripting/lua-bindings/auto/api/ProtectedNode.lua b/cocos/scripting/lua-bindings/auto/api/ProtectedNode.lua index 3ff16f3f84..d26eeff4b4 100644 --- a/cocos/scripting/lua-bindings/auto/api/ProtectedNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/ProtectedNode.lua @@ -67,7 +67,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#ProtectedNode] updateDisplayedOpacity diff --git a/cocos/scripting/lua-bindings/auto/api/RenderTexture.lua b/cocos/scripting/lua-bindings/auto/api/RenderTexture.lua index 5be903a678..1a072caad4 100644 --- a/cocos/scripting/lua-bindings/auto/api/RenderTexture.lua +++ b/cocos/scripting/lua-bindings/auto/api/RenderTexture.lua @@ -170,14 +170,14 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#RenderTexture] visit -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#RenderTexture] RenderTexture diff --git a/cocos/scripting/lua-bindings/auto/api/Scene.lua b/cocos/scripting/lua-bindings/auto/api/Scene.lua index 112cdd6a5a..a8eee9150a 100644 --- a/cocos/scripting/lua-bindings/auto/api/Scene.lua +++ b/cocos/scripting/lua-bindings/auto/api/Scene.lua @@ -8,6 +8,12 @@ -- @param self -- @return PhysicsWorld#PhysicsWorld ret (return value: cc.PhysicsWorld) +-------------------------------- +-- @function [parent=#Scene] createWithSize +-- @param self +-- @param #size_table size +-- @return Scene#Scene ret (return value: cc.Scene) + -------------------------------- -- @function [parent=#Scene] create -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/ScrollView.lua b/cocos/scripting/lua-bindings/auto/api/ScrollView.lua index 6e0532f762..217c88aa56 100644 --- a/cocos/scripting/lua-bindings/auto/api/ScrollView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ScrollView.lua @@ -1,7 +1,7 @@ -------------------------------- -- @module ScrollView --- @extend Layout,ScrollViewProtocol +-- @extend Layout -------------------------------- -- @function [parent=#ScrollView] scrollToTop diff --git a/cocos/scripting/lua-bindings/auto/api/Skeleton.lua b/cocos/scripting/lua-bindings/auto/api/Skeleton.lua index 2a39623d42..dcc9c656b0 100644 --- a/cocos/scripting/lua-bindings/auto/api/Skeleton.lua +++ b/cocos/scripting/lua-bindings/auto/api/Skeleton.lua @@ -16,7 +16,7 @@ -- @function [parent=#Skeleton] onDraw -- @param self -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Skeleton] setSlotsToSetupPose diff --git a/cocos/scripting/lua-bindings/auto/api/Skin.lua b/cocos/scripting/lua-bindings/auto/api/Skin.lua index a2abb312d6..d2f6384b84 100644 --- a/cocos/scripting/lua-bindings/auto/api/Skin.lua +++ b/cocos/scripting/lua-bindings/auto/api/Skin.lua @@ -69,7 +69,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Skin] Skin diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Sprite.lua index 0c1d07a411..5186c283b6 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite.lua @@ -185,7 +185,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#Sprite] addChild diff --git a/cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua b/cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua index 44aba3aa83..fbe9380166 100644 --- a/cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua +++ b/cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua @@ -119,7 +119,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#SpriteBatchNode] getDescription @@ -131,7 +131,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#SpriteBatchNode] sortAllChildren diff --git a/cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua b/cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua index 57b9051eaa..145e82f645 100644 --- a/cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua +++ b/cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua @@ -19,19 +19,10 @@ -- @param #cc.Texture2D texture2d -------------------------------- --- overload function: initWithTexture(cc.Texture2D, rect_table, bool, vec2_table, size_table) --- --- overload function: initWithTexture(cc.Texture2D, rect_table) --- --- @function [parent=#SpriteFrame] initWithTexture +-- @function [parent=#SpriteFrame] getOffset -- @param self --- @param #cc.Texture2D texture2d --- @param #rect_table rect --- @param #bool bool --- @param #vec2_table vec2 --- @param #size_table size --- @return bool#bool ret (retunr value: bool) - +-- @return vec2_table#vec2_table ret (return value: vec2_table) + -------------------------------- -- @function [parent=#SpriteFrame] setRectInPixels -- @param self @@ -77,30 +68,11 @@ -- @param self -- @param #vec2_table vec2 --------------------------------- --- @function [parent=#SpriteFrame] getOffset --- @param self --- @return vec2_table#vec2_table ret (return value: vec2_table) - -------------------------------- -- @function [parent=#SpriteFrame] isRotated -- @param self -- @return bool#bool ret (return value: bool) --------------------------------- --- overload function: initWithTextureFilename(string, rect_table, bool, vec2_table, size_table) --- --- overload function: initWithTextureFilename(string, rect_table) --- --- @function [parent=#SpriteFrame] initWithTextureFilename --- @param self --- @param #string str --- @param #rect_table rect --- @param #bool bool --- @param #vec2_table vec2 --- @param #size_table size --- @return bool#bool ret (retunr value: bool) - -------------------------------- -- @function [parent=#SpriteFrame] setRect -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/Text.lua b/cocos/scripting/lua-bindings/auto/api/Text.lua index c3fe348834..31a4f1da94 100644 --- a/cocos/scripting/lua-bindings/auto/api/Text.lua +++ b/cocos/scripting/lua-bindings/auto/api/Text.lua @@ -23,6 +23,12 @@ -- @param self -- @return int#int ret (return value: int) +-------------------------------- +-- @function [parent=#Text] enableOutline +-- @param self +-- @param #color4b_table color4b +-- @param #int int + -------------------------------- -- @function [parent=#Text] getTextVerticalAlignment -- @param self @@ -33,6 +39,10 @@ -- @param self -- @return string#string ret (return value: string) +-------------------------------- +-- @function [parent=#Text] enableShadow +-- @param self + -------------------------------- -- @function [parent=#Text] setString -- @param self @@ -48,6 +58,11 @@ -- @param self -- @param #cc.TextVAlignment textvalignment +-------------------------------- +-- @function [parent=#Text] enableGlow +-- @param self +-- @param #color4b_table color4b + -------------------------------- -- @function [parent=#Text] getTextAreaSize -- @param self @@ -73,6 +88,10 @@ -- @param self -- @return Text::Type#Text::Type ret (return value: ccui.Text::Type) +-------------------------------- +-- @function [parent=#Text] disableEffect +-- @param self + -------------------------------- -- @function [parent=#Text] getFontName -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/TextField.lua b/cocos/scripting/lua-bindings/auto/api/TextField.lua index 006ea4a57a..f98098cd9f 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextField.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextField.lua @@ -81,6 +81,11 @@ -- @function [parent=#TextField] attachWithIME -- @param self +-------------------------------- +-- @function [parent=#TextField] getStringLength +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- @function [parent=#TextField] setPasswordEnabled -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionCrossFade.lua b/cocos/scripting/lua-bindings/auto/api/TransitionCrossFade.lua index 25b651549f..ba3b6f2672 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionCrossFade.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionCrossFade.lua @@ -15,6 +15,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionFadeTR.lua b/cocos/scripting/lua-bindings/auto/api/TransitionFadeTR.lua index 9e48aca88a..9d0f0a2268 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionFadeTR.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionFadeTR.lua @@ -27,6 +27,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionPageTurn.lua b/cocos/scripting/lua-bindings/auto/api/TransitionPageTurn.lua index a39e5b6238..aa2ea6f91f 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionPageTurn.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionPageTurn.lua @@ -30,7 +30,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#TransitionPageTurn] TransitionPageTurn diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua b/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua index d00ce314c1..b4427b22ba 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionScene.lua @@ -23,7 +23,7 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int -------------------------------- -- @function [parent=#TransitionScene] cleanup diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionSplitCols.lua b/cocos/scripting/lua-bindings/auto/api/TransitionSplitCols.lua index 6e8529756a..827d705800 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionSplitCols.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionSplitCols.lua @@ -26,6 +26,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/TransitionTurnOffTiles.lua b/cocos/scripting/lua-bindings/auto/api/TransitionTurnOffTiles.lua index b502036231..f887d9a4d1 100644 --- a/cocos/scripting/lua-bindings/auto/api/TransitionTurnOffTiles.lua +++ b/cocos/scripting/lua-bindings/auto/api/TransitionTurnOffTiles.lua @@ -21,6 +21,6 @@ -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table mat4 --- @param #bool bool +-- @param #unsigned int int return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Widget.lua b/cocos/scripting/lua-bindings/auto/api/Widget.lua index e91820a74f..a46441c338 100644 --- a/cocos/scripting/lua-bindings/auto/api/Widget.lua +++ b/cocos/scripting/lua-bindings/auto/api/Widget.lua @@ -3,11 +3,6 @@ -- @module Widget -- @extend ProtectedNode,LayoutParameterProtocol --------------------------------- --- @function [parent=#Widget] clone --- @param self --- @return Widget#Widget ret (return value: ccui.Widget) - -------------------------------- -- @function [parent=#Widget] setSizePercent -- @param self @@ -34,9 +29,9 @@ -- @return Node#Node ret (return value: cc.Node) -------------------------------- --- @function [parent=#Widget] getTouchEndPos +-- @function [parent=#Widget] getSize -- @param self --- @return vec2_table#vec2_table ret (return value: vec2_table) +-- @return size_table#size_table ret (return value: size_table) -------------------------------- -- @function [parent=#Widget] setPositionPercent @@ -83,6 +78,13 @@ -- @param self -- @return LayoutParameter#LayoutParameter ret (return value: ccui.LayoutParameter) +-------------------------------- +-- @function [parent=#Widget] findNextFocusedWidget +-- @param self +-- @param #ccui.Widget::FocusDirection focusdirection +-- @param #ccui.Widget widget +-- @return Widget#Widget ret (return value: ccui.Widget) + -------------------------------- -- @function [parent=#Widget] getPositionType -- @param self @@ -110,11 +112,9 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#Widget] findNextFocusedWidget +-- @function [parent=#Widget] getTouchBeganPosition -- @param self --- @param #ccui.Widget::FocusDirection focusdirection --- @param #ccui.Widget widget --- @return Widget#Widget ret (return value: ccui.Widget) +-- @return vec2_table#vec2_table ret (return value: vec2_table) -------------------------------- -- @function [parent=#Widget] isTouchEnabled @@ -151,11 +151,6 @@ -- @param self -- @param #bool bool --------------------------------- --- @function [parent=#Widget] getTouchMovePos --- @param self --- @return vec2_table#vec2_table ret (return value: vec2_table) - -------------------------------- -- @function [parent=#Widget] setEnabled -- @param self @@ -182,14 +177,9 @@ -- @param #ccui.LayoutParameter layoutparameter -------------------------------- --- @function [parent=#Widget] getSizePercent +-- @function [parent=#Widget] clone -- @param self --- @return vec2_table#vec2_table ret (return value: vec2_table) - --------------------------------- --- @function [parent=#Widget] getTouchStartPos --- @param self --- @return vec2_table#vec2_table ret (return value: vec2_table) +-- @return Widget#Widget ret (return value: ccui.Widget) -------------------------------- -- @function [parent=#Widget] setFocusEnabled @@ -206,12 +196,6 @@ -- @param self -- @return bool#bool ret (return value: bool) --------------------------------- --- @function [parent=#Widget] clippingParentAreaContainPoint --- @param self --- @param #vec2_table vec2 --- @return bool#bool ret (return value: bool) - -------------------------------- -- @function [parent=#Widget] getCurrentFocusedWidget -- @param self @@ -231,9 +215,14 @@ -- @param #size_table size -------------------------------- --- @function [parent=#Widget] getSize +-- @function [parent=#Widget] getSizePercent -- @param self --- @return size_table#size_table ret (return value: size_table) +-- @return vec2_table#vec2_table ret (return value: vec2_table) + +-------------------------------- +-- @function [parent=#Widget] getTouchMovePosition +-- @param self +-- @return vec2_table#vec2_table ret (return value: vec2_table) -------------------------------- -- @function [parent=#Widget] getSizeType @@ -245,18 +234,16 @@ -- @param self -- @param #bool bool --------------------------------- --- @function [parent=#Widget] interceptTouchEvent --- @param self --- @param #ccui.Widget::TouchEventType toucheventtype --- @param #ccui.Widget widget --- @param #vec2_table vec2 - -------------------------------- -- @function [parent=#Widget] addTouchEventListener -- @param self -- @param #function func +-------------------------------- +-- @function [parent=#Widget] getTouchEndPosition +-- @param self +-- @return vec2_table#vec2_table ret (return value: vec2_table) + -------------------------------- -- @function [parent=#Widget] getPositionPercent -- @param self @@ -278,6 +265,12 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- @function [parent=#Widget] isClippingParentContainsPoint +-- @param self +-- @param #vec2_table vec2 +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @function [parent=#Widget] setSizeType -- @param self @@ -309,35 +302,15 @@ -- @return Widget#Widget ret (return value: ccui.Widget) -------------------------------- --- @function [parent=#Widget] setColor +-- @function [parent=#Widget] getDescription -- @param self --- @param #color3b_table color3b - --------------------------------- --- @function [parent=#Widget] getColor --- @param self --- @return color3b_table#color3b_table ret (return value: color3b_table) - --------------------------------- --- @function [parent=#Widget] setOpacity --- @param self --- @param #unsigned char char - --------------------------------- --- @function [parent=#Widget] getOpacity --- @param self --- @return unsigned char#unsigned char ret (return value: unsigned char) +-- @return string#string ret (return value: string) -------------------------------- -- @function [parent=#Widget] setPosition -- @param self -- @param #vec2_table vec2 --------------------------------- --- @function [parent=#Widget] getDescription --- @param self --- @return string#string ret (return value: string) - -------------------------------- -- @function [parent=#Widget] Widget -- @param self diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 572a8d3075..8f264e16eb 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -1505,6 +1505,7 @@ int lua_register_cocos2dx_EventDispatcher(lua_State* tolua_S) tolua_cclass(tolua_S,"EventDispatcher","cc.EventDispatcher","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"EventDispatcher"); + tolua_function(tolua_S,"new",lua_cocos2dx_EventDispatcher_constructor); tolua_function(tolua_S,"pauseEventListenersForTarget",lua_cocos2dx_EventDispatcher_pauseEventListenersForTarget); tolua_function(tolua_S,"addEventListenerWithSceneGraphPriority",lua_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_EventDispatcher_setEnabled); @@ -1519,7 +1520,6 @@ int lua_register_cocos2dx_EventDispatcher(lua_State* tolua_S) tolua_function(tolua_S,"removeCustomEventListeners",lua_cocos2dx_EventDispatcher_removeCustomEventListeners); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_EventDispatcher_isEnabled); tolua_function(tolua_S,"removeEventListenersForType",lua_cocos2dx_EventDispatcher_removeEventListenersForType); - tolua_function(tolua_S,"new",lua_cocos2dx_EventDispatcher_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventDispatcher).name(); g_luaType[typeName] = "cc.EventDispatcher"; @@ -1977,6 +1977,7 @@ int lua_register_cocos2dx_Touch(lua_State* tolua_S) tolua_cclass(tolua_S,"Touch","cc.Touch","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Touch"); + tolua_function(tolua_S,"new",lua_cocos2dx_Touch_constructor); tolua_function(tolua_S,"getPreviousLocationInView",lua_cocos2dx_Touch_getPreviousLocationInView); tolua_function(tolua_S,"getLocation",lua_cocos2dx_Touch_getLocation); tolua_function(tolua_S,"getDelta",lua_cocos2dx_Touch_getDelta); @@ -1986,7 +1987,6 @@ int lua_register_cocos2dx_Touch(lua_State* tolua_S) tolua_function(tolua_S,"setTouchInfo",lua_cocos2dx_Touch_setTouchInfo); tolua_function(tolua_S,"getLocationInView",lua_cocos2dx_Touch_getLocationInView); tolua_function(tolua_S,"getPreviousLocation",lua_cocos2dx_Touch_getPreviousLocation); - tolua_function(tolua_S,"new",lua_cocos2dx_Touch_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Touch).name(); g_luaType[typeName] = "cc.Touch"; @@ -2130,9 +2130,9 @@ int lua_register_cocos2dx_EventTouch(lua_State* tolua_S) tolua_cclass(tolua_S,"EventTouch","cc.EventTouch","cc.Event",nullptr); tolua_beginmodule(tolua_S,"EventTouch"); + tolua_function(tolua_S,"new",lua_cocos2dx_EventTouch_constructor); tolua_function(tolua_S,"getEventCode",lua_cocos2dx_EventTouch_getEventCode); tolua_function(tolua_S,"setEventCode",lua_cocos2dx_EventTouch_setEventCode); - tolua_function(tolua_S,"new",lua_cocos2dx_EventTouch_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventTouch).name(); g_luaType[typeName] = "cc.EventTouch"; @@ -2192,6 +2192,7 @@ int lua_register_cocos2dx_EventKeyboard(lua_State* tolua_S) tolua_cclass(tolua_S,"EventKeyboard","cc.EventKeyboard","cc.Event",nullptr); tolua_beginmodule(tolua_S,"EventKeyboard"); + tolua_function(tolua_S,"new",lua_cocos2dx_EventKeyboard_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventKeyboard).name(); g_luaType[typeName] = "cc.EventKeyboard"; @@ -3650,6 +3651,7 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_cclass(tolua_S,"Texture2D","cc.Texture2D","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Texture2D"); + tolua_function(tolua_S,"new",lua_cocos2dx_Texture2D_constructor); tolua_function(tolua_S,"getMaxT",lua_cocos2dx_Texture2D_getMaxT); tolua_function(tolua_S,"getStringForFormat",lua_cocos2dx_Texture2D_getStringForFormat); tolua_function(tolua_S,"initWithImage",lua_cocos2dx_Texture2D_initWithImage); @@ -3676,7 +3678,6 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_function(tolua_S,"getGLProgram",lua_cocos2dx_Texture2D_getGLProgram); tolua_function(tolua_S,"hasMipmaps",lua_cocos2dx_Texture2D_hasMipmaps); tolua_function(tolua_S,"setMaxS",lua_cocos2dx_Texture2D_setMaxS); - tolua_function(tolua_S,"new",lua_cocos2dx_Texture2D_constructor); tolua_function(tolua_S,"setDefaultAlphaPixelFormat", lua_cocos2dx_Texture2D_setDefaultAlphaPixelFormat); tolua_function(tolua_S,"getDefaultAlphaPixelFormat", lua_cocos2dx_Texture2D_getDefaultAlphaPixelFormat); tolua_function(tolua_S,"PVRImagesHavePremultipliedAlpha", lua_cocos2dx_Texture2D_PVRImagesHavePremultipliedAlpha); @@ -5090,6 +5091,52 @@ int lua_cocos2dx_Node_getOpacity(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_setNormalizedPosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setNormalizedPosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0); + if(!ok) + return 0; + cobj->setNormalizedPosition(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setNormalizedPosition",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setNormalizedPosition'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_convertTouchToNodeSpace(lua_State* tolua_S) { int argc = 0; @@ -6148,6 +6195,52 @@ int lua_cocos2dx_Node_updateTransform(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setGLProgram'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::GLProgram* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); + if(!ok) + return 0; + cobj->setGLProgram(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLProgram",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setGLProgram'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_isVisible(lua_State* tolua_S) { int argc = 0; @@ -6330,59 +6423,49 @@ int lua_cocos2dx_Node_addComponent(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_visit(lua_State* tolua_S) +int lua_cocos2dx_Node_runAction(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; + #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif + #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_visit'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_runAction'", nullptr); return 0; } #endif + argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 0) { - cobj->visit(); + if (argc == 1) + { + cocos2d::Action* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.Action",&arg0); + if(!ok) return 0; - } - }while(0); - ok = true; - do{ - if (argc == 3) { - cocos2d::Renderer* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Renderer",&arg0); - - if (!ok) { break; } - cocos2d::Mat4 arg1; - ok &= luaval_to_mat4(tolua_S, 3, &arg1); - - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2); - - if (!ok) { break; } - cobj->visit(arg0, arg1, arg2); - return 0; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "visit",argc, 3); + cocos2d::Action* ret = cobj->runAction(arg0); + object_to_luaval(tolua_S, "cc.Action",(cocos2d::Action*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAction",argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_visit'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_runAction'.",&tolua_err); #endif return 0; @@ -6519,49 +6602,59 @@ int lua_cocos2dx_Node_getAnchorPointInPoints(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_runAction(lua_State* tolua_S) +int lua_cocos2dx_Node_visit(lua_State* tolua_S) { int argc = 0; cocos2d::Node* cobj = nullptr; bool ok = true; - #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif - #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_runAction'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_visit'", nullptr); return 0; } #endif - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Action* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Action",&arg0); - if(!ok) + do{ + if (argc == 0) { + cobj->visit(); return 0; - cocos2d::Action* ret = cobj->runAction(arg0); - object_to_luaval(tolua_S, "cc.Action",(cocos2d::Action*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "runAction",argc, 1); + } + }while(0); + ok = true; + do{ + if (argc == 3) { + cocos2d::Renderer* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Renderer",&arg0); + + if (!ok) { break; } + cocos2d::Mat4 arg1; + ok &= luaval_to_mat4(tolua_S, 3, &arg1); + + if (!ok) { break; } + unsigned int arg2; + ok &= luaval_to_uint32(tolua_S, 4,&arg2); + + if (!ok) { break; } + cobj->visit(arg0, arg1, arg2); + return 0; + } + }while(0); + ok = true; + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "visit",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_runAction'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_visit'.",&tolua_err); #endif return 0; @@ -8614,8 +8707,8 @@ int lua_cocos2dx_Node_draw(lua_State* tolua_S) ok &= luaval_to_mat4(tolua_S, 3, &arg1); if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2); + unsigned int arg2; + ok &= luaval_to_uint32(tolua_S, 4,&arg2); if (!ok) { break; } cobj->draw(arg0, arg1, arg2); @@ -8907,52 +9000,6 @@ int lua_cocos2dx_Node_getWorldToNodeTransform(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Node_setGLProgram(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Node* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setGLProgram'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::GLProgram* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.GLProgram",&arg0); - if(!ok) - return 0; - cobj->setGLProgram(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setGLProgram",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setGLProgram'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Node_getScale(lua_State* tolua_S) { int argc = 0; @@ -8997,6 +9044,50 @@ int lua_cocos2dx_Node_getScale(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Node_getNormalizedPosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Node* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getNormalizedPosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::Vec2& ret = cobj->getNormalizedPosition(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getNormalizedPosition",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getNormalizedPosition'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Node_getRotationSkewX(lua_State* tolua_S) { int argc = 0; @@ -9341,6 +9432,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"setSkewX",lua_cocos2dx_Node_setSkewX); tolua_function(tolua_S,"setGLProgramState",lua_cocos2dx_Node_setGLProgramState); tolua_function(tolua_S,"getOpacity",lua_cocos2dx_Node_getOpacity); + tolua_function(tolua_S,"setNormalizedPosition",lua_cocos2dx_Node_setNormalizedPosition); tolua_function(tolua_S,"convertTouchToNodeSpace",lua_cocos2dx_Node_convertTouchToNodeSpace); tolua_function(tolua_S,"removeAllChildren",lua_cocos2dx_Node_removeAllChildrenWithCleanup); tolua_function(tolua_S,"getNodeToParentAffineTransform",lua_cocos2dx_Node_getNodeToParentAffineTransform); @@ -9364,15 +9456,16 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"getAnchorPoint",lua_cocos2dx_Node_getAnchorPoint); tolua_function(tolua_S,"getNumberOfRunningActions",lua_cocos2dx_Node_getNumberOfRunningActions); tolua_function(tolua_S,"updateTransform",lua_cocos2dx_Node_updateTransform); + tolua_function(tolua_S,"setGLProgram",lua_cocos2dx_Node_setGLProgram); tolua_function(tolua_S,"isVisible",lua_cocos2dx_Node_isVisible); tolua_function(tolua_S,"getChildrenCount",lua_cocos2dx_Node_getChildrenCount); tolua_function(tolua_S,"convertToNodeSpaceAR",lua_cocos2dx_Node_convertToNodeSpaceAR); tolua_function(tolua_S,"addComponent",lua_cocos2dx_Node_addComponent); - tolua_function(tolua_S,"visit",lua_cocos2dx_Node_visit); + tolua_function(tolua_S,"runAction",lua_cocos2dx_Node_runAction); tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB); tolua_function(tolua_S,"getRotation",lua_cocos2dx_Node_getRotation); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_Node_getAnchorPointInPoints); - tolua_function(tolua_S,"runAction",lua_cocos2dx_Node_runAction); + tolua_function(tolua_S,"visit",lua_cocos2dx_Node_visit); tolua_function(tolua_S,"getGLProgramState",lua_cocos2dx_Node_getGLProgramState); tolua_function(tolua_S,"setScheduler",lua_cocos2dx_Node_setScheduler); tolua_function(tolua_S,"stopAllActions",lua_cocos2dx_Node_stopAllActions); @@ -9424,8 +9517,8 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S) tolua_function(tolua_S,"update",lua_cocos2dx_Node_update); tolua_function(tolua_S,"sortAllChildren",lua_cocos2dx_Node_sortAllChildren); tolua_function(tolua_S,"getWorldToNodeTransform",lua_cocos2dx_Node_getWorldToNodeTransform); - tolua_function(tolua_S,"setGLProgram",lua_cocos2dx_Node_setGLProgram); tolua_function(tolua_S,"getScale",lua_cocos2dx_Node_getScale); + tolua_function(tolua_S,"getNormalizedPosition",lua_cocos2dx_Node_getNormalizedPosition); tolua_function(tolua_S,"getRotationSkewX",lua_cocos2dx_Node_getRotationSkewX); tolua_function(tolua_S,"getRotationSkewY",lua_cocos2dx_Node_getRotationSkewY); tolua_function(tolua_S,"setTag",lua_cocos2dx_Node_setTag); @@ -14136,9 +14229,9 @@ int lua_register_cocos2dx_Scheduler(lua_State* tolua_S) tolua_cclass(tolua_S,"Scheduler","cc.Scheduler","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Scheduler"); + tolua_function(tolua_S,"new",lua_cocos2dx_Scheduler_constructor); tolua_function(tolua_S,"setTimeScale",lua_cocos2dx_Scheduler_setTimeScale); tolua_function(tolua_S,"getTimeScale",lua_cocos2dx_Scheduler_getTimeScale); - tolua_function(tolua_S,"new",lua_cocos2dx_Scheduler_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Scheduler).name(); g_luaType[typeName] = "cc.Scheduler"; @@ -16441,6 +16534,7 @@ int lua_register_cocos2dx_EventMouse(lua_State* tolua_S) tolua_cclass(tolua_S,"EventMouse","cc.EventMouse","cc.Event",nullptr); tolua_beginmodule(tolua_S,"EventMouse"); + tolua_function(tolua_S,"new",lua_cocos2dx_EventMouse_constructor); tolua_function(tolua_S,"getMouseButton",lua_cocos2dx_EventMouse_getMouseButton); tolua_function(tolua_S,"setScrollData",lua_cocos2dx_EventMouse_setScrollData); tolua_function(tolua_S,"setMouseButton",lua_cocos2dx_EventMouse_setMouseButton); @@ -16449,7 +16543,6 @@ int lua_register_cocos2dx_EventMouse(lua_State* tolua_S) tolua_function(tolua_S,"getCursorX",lua_cocos2dx_EventMouse_getCursorX); tolua_function(tolua_S,"getCursorY",lua_cocos2dx_EventMouse_getCursorY); tolua_function(tolua_S,"setCursorPosition",lua_cocos2dx_EventMouse_setCursorPosition); - tolua_function(tolua_S,"new",lua_cocos2dx_EventMouse_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventMouse).name(); g_luaType[typeName] = "cc.EventMouse"; @@ -16607,8 +16700,8 @@ int lua_register_cocos2dx_EventCustom(lua_State* tolua_S) tolua_cclass(tolua_S,"EventCustom","cc.EventCustom","cc.Event",nullptr); tolua_beginmodule(tolua_S,"EventCustom"); - tolua_function(tolua_S,"getEventName",lua_cocos2dx_EventCustom_getEventName); tolua_function(tolua_S,"new",lua_cocos2dx_EventCustom_constructor); + tolua_function(tolua_S,"getEventName",lua_cocos2dx_EventCustom_getEventName); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventCustom).name(); g_luaType[typeName] = "cc.EventCustom"; @@ -16687,6 +16780,7 @@ int lua_register_cocos2dx_EventFocus(lua_State* tolua_S) tolua_cclass(tolua_S,"EventFocus","cc.EventFocus","cc.Event",nullptr); tolua_beginmodule(tolua_S,"EventFocus"); + tolua_function(tolua_S,"new",lua_cocos2dx_EventFocus_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::EventFocus).name(); g_luaType[typeName] = "cc.EventFocus"; @@ -17971,77 +18065,46 @@ int lua_cocos2dx_SpriteFrame_setTexture(lua_State* tolua_S) return 0; } -int lua_cocos2dx_SpriteFrame_initWithTexture(lua_State* tolua_S) +int lua_cocos2dx_SpriteFrame_getOffset(lua_State* tolua_S) { int argc = 0; cocos2d::SpriteFrame* cobj = nullptr; bool ok = true; + #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif + #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; #endif + cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); + #if COCOS2D_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_initWithTexture'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOffset'", nullptr); return 0; } #endif + argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 5) { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1); - - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2); - - if (!ok) { break; } - cocos2d::Vec2 arg3; - ok &= luaval_to_vec2(tolua_S, 5, &arg3); - - if (!ok) { break; } - cocos2d::Size arg4; - ok &= luaval_to_size(tolua_S, 6, &arg4); - - if (!ok) { break; } - bool ret = cobj->initWithTexture(arg0, arg1, arg2, arg3, arg4); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1); - - if (!ok) { break; } - bool ret = cobj->initWithTexture(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTexture",argc, 2); + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::Vec2& ret = cobj->getOffset(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffset",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_initWithTexture'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOffset'.",&tolua_err); #endif return 0; @@ -18452,50 +18515,6 @@ int lua_cocos2dx_SpriteFrame_setOffset(lua_State* tolua_S) return 0; } -int lua_cocos2dx_SpriteFrame_getOffset(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::SpriteFrame* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_getOffset'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - const cocos2d::Vec2& ret = cobj->getOffset(); - vec2_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffset",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_getOffset'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_SpriteFrame_isRotated(lua_State* tolua_S) { int argc = 0; @@ -18540,81 +18559,6 @@ int lua_cocos2dx_SpriteFrame_isRotated(lua_State* tolua_S) return 0; } -int lua_cocos2dx_SpriteFrame_initWithTextureFilename(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::SpriteFrame* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.SpriteFrame",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::SpriteFrame*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpriteFrame_initWithTextureFilename'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 5) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1); - - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2); - - if (!ok) { break; } - cocos2d::Vec2 arg3; - ok &= luaval_to_vec2(tolua_S, 5, &arg3); - - if (!ok) { break; } - cocos2d::Size arg4; - ok &= luaval_to_size(tolua_S, 6, &arg4); - - if (!ok) { break; } - bool ret = cobj->initWithTextureFilename(arg0, arg1, arg2, arg3, arg4); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1); - - if (!ok) { break; } - bool ret = cobj->initWithTextureFilename(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "initWithTextureFilename",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteFrame_initWithTextureFilename'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_SpriteFrame_setRect(lua_State* tolua_S) { int argc = 0; @@ -18890,7 +18834,7 @@ int lua_register_cocos2dx_SpriteFrame(lua_State* tolua_S) tolua_function(tolua_S,"clone",lua_cocos2dx_SpriteFrame_clone); tolua_function(tolua_S,"setRotated",lua_cocos2dx_SpriteFrame_setRotated); tolua_function(tolua_S,"setTexture",lua_cocos2dx_SpriteFrame_setTexture); - tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_SpriteFrame_initWithTexture); + tolua_function(tolua_S,"getOffset",lua_cocos2dx_SpriteFrame_getOffset); tolua_function(tolua_S,"setRectInPixels",lua_cocos2dx_SpriteFrame_setRectInPixels); tolua_function(tolua_S,"getTexture",lua_cocos2dx_SpriteFrame_getTexture); tolua_function(tolua_S,"getRect",lua_cocos2dx_SpriteFrame_getRect); @@ -18900,9 +18844,7 @@ int lua_register_cocos2dx_SpriteFrame(lua_State* tolua_S) tolua_function(tolua_S,"getOriginalSizeInPixels",lua_cocos2dx_SpriteFrame_getOriginalSizeInPixels); tolua_function(tolua_S,"setOriginalSizeInPixels",lua_cocos2dx_SpriteFrame_setOriginalSizeInPixels); tolua_function(tolua_S,"setOffset",lua_cocos2dx_SpriteFrame_setOffset); - tolua_function(tolua_S,"getOffset",lua_cocos2dx_SpriteFrame_getOffset); tolua_function(tolua_S,"isRotated",lua_cocos2dx_SpriteFrame_isRotated); - tolua_function(tolua_S,"initWithTextureFilename",lua_cocos2dx_SpriteFrame_initWithTextureFilename); tolua_function(tolua_S,"setRect",lua_cocos2dx_SpriteFrame_setRect); tolua_function(tolua_S,"getOffsetInPixels",lua_cocos2dx_SpriteFrame_getOffsetInPixels); tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_SpriteFrame_getOriginalSize); @@ -22434,13 +22376,13 @@ int lua_register_cocos2dx_ActionCamera(lua_State* tolua_S) tolua_cclass(tolua_S,"ActionCamera","cc.ActionCamera","cc.ActionInterval",nullptr); tolua_beginmodule(tolua_S,"ActionCamera"); + tolua_function(tolua_S,"new",lua_cocos2dx_ActionCamera_constructor); tolua_function(tolua_S,"setEye",lua_cocos2dx_ActionCamera_setEye); tolua_function(tolua_S,"getEye",lua_cocos2dx_ActionCamera_getEye); tolua_function(tolua_S,"setUp",lua_cocos2dx_ActionCamera_setUp); tolua_function(tolua_S,"getCenter",lua_cocos2dx_ActionCamera_getCenter); tolua_function(tolua_S,"setCenter",lua_cocos2dx_ActionCamera_setCenter); tolua_function(tolua_S,"getUp",lua_cocos2dx_ActionCamera_getUp); - tolua_function(tolua_S,"new",lua_cocos2dx_ActionCamera_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionCamera).name(); g_luaType[typeName] = "cc.ActionCamera"; @@ -23173,6 +23115,7 @@ int lua_register_cocos2dx_ActionManager(lua_State* tolua_S) tolua_cclass(tolua_S,"ActionManager","cc.ActionManager","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"ActionManager"); + tolua_function(tolua_S,"new",lua_cocos2dx_ActionManager_constructor); tolua_function(tolua_S,"getActionByTag",lua_cocos2dx_ActionManager_getActionByTag); tolua_function(tolua_S,"removeActionByTag",lua_cocos2dx_ActionManager_removeActionByTag); tolua_function(tolua_S,"removeAllActions",lua_cocos2dx_ActionManager_removeAllActions); @@ -23185,7 +23128,6 @@ int lua_register_cocos2dx_ActionManager(lua_State* tolua_S) tolua_function(tolua_S,"removeAction",lua_cocos2dx_ActionManager_removeAction); tolua_function(tolua_S,"pauseTarget",lua_cocos2dx_ActionManager_pauseTarget); tolua_function(tolua_S,"pauseAllRunningActions",lua_cocos2dx_ActionManager_pauseAllRunningActions); - tolua_function(tolua_S,"new",lua_cocos2dx_ActionManager_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ActionManager).name(); g_luaType[typeName] = "cc.ActionManager"; @@ -30143,10 +30085,10 @@ int lua_register_cocos2dx_CardinalSplineTo(lua_State* tolua_S) tolua_cclass(tolua_S,"CardinalSplineTo","cc.CardinalSplineTo","cc.ActionInterval",nullptr); tolua_beginmodule(tolua_S,"CardinalSplineTo"); + tolua_function(tolua_S,"new",lua_cocos2dx_CardinalSplineTo_constructor); tolua_function(tolua_S,"getPoints",lua_cocos2dx_CardinalSplineTo_getPoints); tolua_function(tolua_S,"updatePosition",lua_cocos2dx_CardinalSplineTo_updatePosition); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_CardinalSplineTo_initWithDuration); - tolua_function(tolua_S,"new",lua_cocos2dx_CardinalSplineTo_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CardinalSplineTo).name(); g_luaType[typeName] = "cc.CardinalSplineTo"; @@ -30200,6 +30142,7 @@ int lua_register_cocos2dx_CardinalSplineBy(lua_State* tolua_S) tolua_cclass(tolua_S,"CardinalSplineBy","cc.CardinalSplineBy","cc.CardinalSplineTo",nullptr); tolua_beginmodule(tolua_S,"CardinalSplineBy"); + tolua_function(tolua_S,"new",lua_cocos2dx_CardinalSplineBy_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::CardinalSplineBy).name(); g_luaType[typeName] = "cc.CardinalSplineBy"; @@ -30434,11 +30377,11 @@ int lua_cocos2dx_DrawNode_onDraw(lua_State* tolua_S) if (argc == 2) { cocos2d::Mat4 arg0; - bool arg1; + unsigned int arg1; ok &= luaval_to_mat4(tolua_S, 2, &arg0); - ok &= luaval_to_boolean(tolua_S, 3,&arg1); + ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cobj->onDraw(arg0, arg1); @@ -32270,6 +32213,7 @@ int lua_register_cocos2dx_LabelTTF(lua_State* tolua_S) tolua_cclass(tolua_S,"LabelTTF","cc.LabelTTF","cc.Node",nullptr); tolua_beginmodule(tolua_S,"LabelTTF"); + tolua_function(tolua_S,"new",lua_cocos2dx_LabelTTF_constructor); tolua_function(tolua_S,"enableShadow",lua_cocos2dx_LabelTTF_enableShadow); tolua_function(tolua_S,"setDimensions",lua_cocos2dx_LabelTTF_setDimensions); tolua_function(tolua_S,"getFontSize",lua_cocos2dx_LabelTTF_getFontSize); @@ -32295,7 +32239,6 @@ int lua_register_cocos2dx_LabelTTF(lua_State* tolua_S) tolua_function(tolua_S,"setHorizontalAlignment",lua_cocos2dx_LabelTTF_setHorizontalAlignment); tolua_function(tolua_S,"disableShadow",lua_cocos2dx_LabelTTF_disableShadow); tolua_function(tolua_S,"disableStroke",lua_cocos2dx_LabelTTF_disableStroke); - tolua_function(tolua_S,"new",lua_cocos2dx_LabelTTF_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_LabelTTF_create); tolua_function(tolua_S,"createWithFontDefinition", lua_cocos2dx_LabelTTF_createWithFontDefinition); tolua_endmodule(tolua_S); @@ -33641,6 +33584,7 @@ int lua_register_cocos2dx_GLProgram(lua_State* tolua_S) tolua_cclass(tolua_S,"GLProgram","cc.GLProgram","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"GLProgram"); + tolua_function(tolua_S,"new",lua_cocos2dx_GLProgram_constructor); tolua_function(tolua_S,"getFragmentShaderLog",lua_cocos2dx_GLProgram_getFragmentShaderLog); tolua_function(tolua_S,"initWithByteArrays",lua_cocos2dx_GLProgram_initWithByteArrays); tolua_function(tolua_S,"setUniformLocationWithMatrix4fv",lua_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv); @@ -33666,7 +33610,6 @@ int lua_register_cocos2dx_GLProgram(lua_State* tolua_S) tolua_function(tolua_S,"setUniformLocationWith4i",lua_cocos2dx_GLProgram_setUniformLocationWith4i); tolua_function(tolua_S,"link",lua_cocos2dx_GLProgram_link); tolua_function(tolua_S,"setUniformLocationWith2i",lua_cocos2dx_GLProgram_setUniformLocationWith2i); - tolua_function(tolua_S,"new",lua_cocos2dx_GLProgram_constructor); tolua_function(tolua_S,"createWithByteArrays", lua_cocos2dx_GLProgram_createWithByteArrays); tolua_function(tolua_S,"createWithFilenames", lua_cocos2dx_GLProgram_createWithFilenames); tolua_endmodule(tolua_S); @@ -37653,6 +37596,7 @@ int lua_register_cocos2dx_LabelBMFont(lua_State* tolua_S) tolua_cclass(tolua_S,"LabelBMFont","cc.LabelBMFont","cc.Node",nullptr); tolua_beginmodule(tolua_S,"LabelBMFont"); + tolua_function(tolua_S,"new",lua_cocos2dx_LabelBMFont_constructor); tolua_function(tolua_S,"setLineBreakWithoutSpace",lua_cocos2dx_LabelBMFont_setLineBreakWithoutSpace); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_LabelBMFont_getBlendFunc); tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_LabelBMFont_isOpacityModifyRGB); @@ -37666,7 +37610,6 @@ int lua_register_cocos2dx_LabelBMFont(lua_State* tolua_S) tolua_function(tolua_S,"setFntFile",lua_cocos2dx_LabelBMFont_setFntFile); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_LabelBMFont_setAlignment); tolua_function(tolua_S,"setWidth",lua_cocos2dx_LabelBMFont_setWidth); - tolua_function(tolua_S,"new",lua_cocos2dx_LabelBMFont_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_LabelBMFont_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::LabelBMFont).name(); @@ -38797,6 +38740,39 @@ int lua_cocos2dx_Scene_getPhysicsWorld(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Scene_createWithSize(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,"cc.Scene",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Size arg0; + ok &= luaval_to_size(tolua_S, 2, &arg0); + if(!ok) + return 0; + cocos2d::Scene* ret = cocos2d::Scene::createWithSize(arg0); + object_to_luaval(tolua_S, "cc.Scene",(cocos2d::Scene*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createWithSize",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_createWithSize'.",&tolua_err); +#endif + return 0; +} int lua_cocos2dx_Scene_create(lua_State* tolua_S) { int argc = 0; @@ -38872,6 +38848,7 @@ int lua_register_cocos2dx_Scene(lua_State* tolua_S) tolua_beginmodule(tolua_S,"Scene"); tolua_function(tolua_S,"getPhysicsWorld",lua_cocos2dx_Scene_getPhysicsWorld); + tolua_function(tolua_S,"createWithSize", lua_cocos2dx_Scene_createWithSize); tolua_function(tolua_S,"create", lua_cocos2dx_Scene_create); tolua_function(tolua_S,"createWithPhysics", lua_cocos2dx_Scene_createWithPhysics); tolua_endmodule(tolua_S); @@ -41521,9 +41498,9 @@ int lua_register_cocos2dx_TransitionPageTurn(lua_State* tolua_S) tolua_cclass(tolua_S,"TransitionPageTurn","cc.TransitionPageTurn","cc.TransitionScene",nullptr); tolua_beginmodule(tolua_S,"TransitionPageTurn"); + tolua_function(tolua_S,"new",lua_cocos2dx_TransitionPageTurn_constructor); tolua_function(tolua_S,"actionWithSize",lua_cocos2dx_TransitionPageTurn_actionWithSize); tolua_function(tolua_S,"initWithDuration",lua_cocos2dx_TransitionPageTurn_initWithDuration); - tolua_function(tolua_S,"new",lua_cocos2dx_TransitionPageTurn_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionPageTurn_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionPageTurn).name(); @@ -41613,6 +41590,7 @@ int lua_register_cocos2dx_TransitionProgress(lua_State* tolua_S) tolua_cclass(tolua_S,"TransitionProgress","cc.TransitionProgress","cc.TransitionScene",nullptr); tolua_beginmodule(tolua_S,"TransitionProgress"); + tolua_function(tolua_S,"new",lua_cocos2dx_TransitionProgress_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TransitionProgress_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TransitionProgress).name(); @@ -47428,6 +47406,7 @@ int lua_register_cocos2dx_Image(lua_State* tolua_S) tolua_cclass(tolua_S,"Image","cc.Image","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"Image"); + tolua_function(tolua_S,"new",lua_cocos2dx_Image_constructor); tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Image_hasPremultipliedAlpha); tolua_function(tolua_S,"saveToFile",lua_cocos2dx_Image_saveToFile); tolua_function(tolua_S,"getBitPerPixel",lua_cocos2dx_Image_getBitPerPixel); @@ -47440,7 +47419,6 @@ int lua_register_cocos2dx_Image(lua_State* tolua_S) tolua_function(tolua_S,"getFileType",lua_cocos2dx_Image_getFileType); tolua_function(tolua_S,"getNumberOfMipmaps",lua_cocos2dx_Image_getNumberOfMipmaps); tolua_function(tolua_S,"getRenderFormat",lua_cocos2dx_Image_getRenderFormat); - tolua_function(tolua_S,"new",lua_cocos2dx_Image_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Image).name(); g_luaType[typeName] = "cc.Image"; @@ -48788,6 +48766,7 @@ int lua_register_cocos2dx_RenderTexture(lua_State* tolua_S) tolua_cclass(tolua_S,"RenderTexture","cc.RenderTexture","cc.Node",nullptr); tolua_beginmodule(tolua_S,"RenderTexture"); + tolua_function(tolua_S,"new",lua_cocos2dx_RenderTexture_constructor); tolua_function(tolua_S,"setVirtualViewport",lua_cocos2dx_RenderTexture_setVirtualViewport); tolua_function(tolua_S,"clearStencil",lua_cocos2dx_RenderTexture_clearStencil); tolua_function(tolua_S,"getClearDepth",lua_cocos2dx_RenderTexture_getClearDepth); @@ -48812,7 +48791,6 @@ int lua_register_cocos2dx_RenderTexture(lua_State* tolua_S) tolua_function(tolua_S,"newImage",lua_cocos2dx_RenderTexture_newImage); tolua_function(tolua_S,"setClearDepth",lua_cocos2dx_RenderTexture_setClearDepth); tolua_function(tolua_S,"initWithWidthAndHeight",lua_cocos2dx_RenderTexture_initWithWidthAndHeight); - tolua_function(tolua_S,"new",lua_cocos2dx_RenderTexture_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_RenderTexture_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::RenderTexture).name(); @@ -56296,6 +56274,7 @@ int lua_register_cocos2dx_Grid3D(lua_State* tolua_S) tolua_cclass(tolua_S,"Grid3D","cc.Grid3D","cc.GridBase",nullptr); tolua_beginmodule(tolua_S,"Grid3D"); + tolua_function(tolua_S,"new",lua_cocos2dx_Grid3D_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_Grid3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Grid3D).name(); @@ -56404,6 +56383,7 @@ int lua_register_cocos2dx_TiledGrid3D(lua_State* tolua_S) tolua_cclass(tolua_S,"TiledGrid3D","cc.TiledGrid3D","cc.GridBase",nullptr); tolua_beginmodule(tolua_S,"TiledGrid3D"); + tolua_function(tolua_S,"new",lua_cocos2dx_TiledGrid3D_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TiledGrid3D_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TiledGrid3D).name(); @@ -56701,11 +56681,11 @@ int lua_register_cocos2dx_GLProgramCache(lua_State* tolua_S) tolua_cclass(tolua_S,"GLProgramCache","cc.GLProgramCache","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"GLProgramCache"); + tolua_function(tolua_S,"new",lua_cocos2dx_GLProgramCache_constructor); tolua_function(tolua_S,"addGLProgram",lua_cocos2dx_GLProgramCache_addGLProgram); tolua_function(tolua_S,"getGLProgram",lua_cocos2dx_GLProgramCache_getGLProgram); tolua_function(tolua_S,"reloadDefaultGLPrograms",lua_cocos2dx_GLProgramCache_reloadDefaultGLPrograms); tolua_function(tolua_S,"loadDefaultGLPrograms",lua_cocos2dx_GLProgramCache_loadDefaultGLPrograms); - tolua_function(tolua_S,"new",lua_cocos2dx_GLProgramCache_constructor); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_GLProgramCache_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_GLProgramCache_getInstance); tolua_endmodule(tolua_S); @@ -57312,6 +57292,7 @@ int lua_register_cocos2dx_TextureCache(lua_State* tolua_S) tolua_cclass(tolua_S,"TextureCache","cc.TextureCache","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"TextureCache"); + tolua_function(tolua_S,"new",lua_cocos2dx_TextureCache_constructor); tolua_function(tolua_S,"reloadTexture",lua_cocos2dx_TextureCache_reloadTexture); tolua_function(tolua_S,"unbindAllImageAsync",lua_cocos2dx_TextureCache_unbindAllImageAsync); tolua_function(tolua_S,"removeTextureForKey",lua_cocos2dx_TextureCache_removeTextureForKey); @@ -57324,7 +57305,6 @@ int lua_register_cocos2dx_TextureCache(lua_State* tolua_S) tolua_function(tolua_S,"removeUnusedTextures",lua_cocos2dx_TextureCache_removeUnusedTextures); tolua_function(tolua_S,"removeTexture",lua_cocos2dx_TextureCache_removeTexture); tolua_function(tolua_S,"waitForQuit",lua_cocos2dx_TextureCache_waitForQuit); - tolua_function(tolua_S,"new",lua_cocos2dx_TextureCache_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TextureCache).name(); g_luaType[typeName] = "cc.TextureCache"; @@ -59135,13 +59115,13 @@ int lua_register_cocos2dx_AnimationCache(lua_State* tolua_S) tolua_cclass(tolua_S,"AnimationCache","cc.AnimationCache","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"AnimationCache"); + tolua_function(tolua_S,"new",lua_cocos2dx_AnimationCache_constructor); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_AnimationCache_getAnimation); tolua_function(tolua_S,"addAnimation",lua_cocos2dx_AnimationCache_addAnimation); tolua_function(tolua_S,"init",lua_cocos2dx_AnimationCache_init); tolua_function(tolua_S,"addAnimationsWithDictionary",lua_cocos2dx_AnimationCache_addAnimationsWithDictionary); tolua_function(tolua_S,"removeAnimation",lua_cocos2dx_AnimationCache_removeAnimation); tolua_function(tolua_S,"addAnimations",lua_cocos2dx_AnimationCache_addAnimationsWithFile); - tolua_function(tolua_S,"new",lua_cocos2dx_AnimationCache_constructor); tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_AnimationCache_destroyInstance); tolua_function(tolua_S,"getInstance", lua_cocos2dx_AnimationCache_getInstance); tolua_endmodule(tolua_S); @@ -60385,6 +60365,7 @@ int lua_register_cocos2dx_TMXObjectGroup(lua_State* tolua_S) tolua_cclass(tolua_S,"TMXObjectGroup","cc.TMXObjectGroup","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"TMXObjectGroup"); + tolua_function(tolua_S,"new",lua_cocos2dx_TMXObjectGroup_constructor); tolua_function(tolua_S,"setPositionOffset",lua_cocos2dx_TMXObjectGroup_setPositionOffset); tolua_function(tolua_S,"getProperty",lua_cocos2dx_TMXObjectGroup_getProperty); tolua_function(tolua_S,"getPositionOffset",lua_cocos2dx_TMXObjectGroup_getPositionOffset); @@ -60395,7 +60376,6 @@ int lua_register_cocos2dx_TMXObjectGroup(lua_State* tolua_S) tolua_function(tolua_S,"getGroupName",lua_cocos2dx_TMXObjectGroup_getGroupName); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXObjectGroup_setProperties); tolua_function(tolua_S,"setObjects",lua_cocos2dx_TMXObjectGroup_setObjects); - tolua_function(tolua_S,"new",lua_cocos2dx_TMXObjectGroup_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXObjectGroup).name(); g_luaType[typeName] = "cc.TMXObjectGroup"; @@ -60539,9 +60519,9 @@ int lua_register_cocos2dx_TMXLayerInfo(lua_State* tolua_S) tolua_cclass(tolua_S,"TMXLayerInfo","cc.TMXLayerInfo","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"TMXLayerInfo"); + tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayerInfo_constructor); tolua_function(tolua_S,"setProperties",lua_cocos2dx_TMXLayerInfo_setProperties); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXLayerInfo_getProperties); - tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayerInfo_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXLayerInfo).name(); g_luaType[typeName] = "cc.TMXLayerInfo"; @@ -60642,8 +60622,8 @@ int lua_register_cocos2dx_TMXTilesetInfo(lua_State* tolua_S) tolua_cclass(tolua_S,"TMXTilesetInfo","cc.TMXTilesetInfo","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"TMXTilesetInfo"); - tolua_function(tolua_S,"getRectForGID",lua_cocos2dx_TMXTilesetInfo_getRectForGID); tolua_function(tolua_S,"new",lua_cocos2dx_TMXTilesetInfo_constructor); + tolua_function(tolua_S,"getRectForGID",lua_cocos2dx_TMXTilesetInfo_getRectForGID); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXTilesetInfo).name(); g_luaType[typeName] = "cc.TMXTilesetInfo"; @@ -62228,6 +62208,7 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_cclass(tolua_S,"TMXMapInfo","cc.TMXMapInfo","",nullptr); tolua_beginmodule(tolua_S,"TMXMapInfo"); + tolua_function(tolua_S,"new",lua_cocos2dx_TMXMapInfo_constructor); tolua_function(tolua_S,"setObjectGroups",lua_cocos2dx_TMXMapInfo_setObjectGroups); tolua_function(tolua_S,"setTileSize",lua_cocos2dx_TMXMapInfo_setTileSize); tolua_function(tolua_S,"initWithTMXFile",lua_cocos2dx_TMXMapInfo_initWithTMXFile); @@ -62260,7 +62241,6 @@ int lua_register_cocos2dx_TMXMapInfo(lua_State* tolua_S) tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXMapInfo_getProperties); tolua_function(tolua_S,"getCurrentString",lua_cocos2dx_TMXMapInfo_getCurrentString); tolua_function(tolua_S,"setLayerAttribs",lua_cocos2dx_TMXMapInfo_setLayerAttribs); - tolua_function(tolua_S,"new",lua_cocos2dx_TMXMapInfo_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TMXMapInfo_create); tolua_function(tolua_S,"createWithXML", lua_cocos2dx_TMXMapInfo_createWithXML); tolua_endmodule(tolua_S); @@ -63394,6 +63374,7 @@ int lua_register_cocos2dx_TMXLayer(lua_State* tolua_S) tolua_cclass(tolua_S,"TMXLayer","cc.TMXLayer","cc.SpriteBatchNode",nullptr); tolua_beginmodule(tolua_S,"TMXLayer"); + tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayer_constructor); tolua_function(tolua_S,"getTileGIDAt",lua_cocos2dx_TMXLayer_getTileGIDAt); tolua_function(tolua_S,"getPositionAt",lua_cocos2dx_TMXLayer_getPositionAt); tolua_function(tolua_S,"setLayerOrientation",lua_cocos2dx_TMXLayer_setLayerOrientation); @@ -63416,7 +63397,6 @@ int lua_register_cocos2dx_TMXLayer(lua_State* tolua_S) tolua_function(tolua_S,"getTileSet",lua_cocos2dx_TMXLayer_getTileSet); tolua_function(tolua_S,"getProperties",lua_cocos2dx_TMXLayer_getProperties); tolua_function(tolua_S,"getTileAt",lua_cocos2dx_TMXLayer_getTileAt); - tolua_function(tolua_S,"new",lua_cocos2dx_TMXLayer_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TMXLayer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TMXLayer).name(); @@ -64447,12 +64427,12 @@ int lua_register_cocos2dx_TileMapAtlas(lua_State* tolua_S) tolua_cclass(tolua_S,"TileMapAtlas","cc.TileMapAtlas","cc.AtlasNode",nullptr); tolua_beginmodule(tolua_S,"TileMapAtlas"); + tolua_function(tolua_S,"new",lua_cocos2dx_TileMapAtlas_constructor); tolua_function(tolua_S,"initWithTileFile",lua_cocos2dx_TileMapAtlas_initWithTileFile); tolua_function(tolua_S,"releaseMap",lua_cocos2dx_TileMapAtlas_releaseMap); tolua_function(tolua_S,"getTileAt",lua_cocos2dx_TileMapAtlas_getTileAt); tolua_function(tolua_S,"setTile",lua_cocos2dx_TileMapAtlas_setTile); tolua_function(tolua_S,"setTGAInfo",lua_cocos2dx_TileMapAtlas_setTGAInfo); - tolua_function(tolua_S,"new",lua_cocos2dx_TileMapAtlas_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_TileMapAtlas_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::TileMapAtlas).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 66aba6e633..2a7aac6379 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1612,6 +1612,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index 673e875412..6a66e82f68 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -1315,6 +1315,7 @@ int lua_register_cocos2dx_extension_Scale9Sprite(lua_State* tolua_S) tolua_cclass(tolua_S,"Scale9Sprite","cc.Scale9Sprite","cc.Node",nullptr); tolua_beginmodule(tolua_S,"Scale9Sprite"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_Scale9Sprite_constructor); tolua_function(tolua_S,"resizableSpriteWithCapInsets",lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets); tolua_function(tolua_S,"setInsetBottom",lua_cocos2dx_extension_Scale9Sprite_setInsetBottom); tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName); @@ -1336,7 +1337,6 @@ int lua_register_cocos2dx_extension_Scale9Sprite(lua_State* tolua_S) tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_extension_Scale9Sprite_setCapInsets); tolua_function(tolua_S,"getInsetLeft",lua_cocos2dx_extension_Scale9Sprite_getInsetLeft); tolua_function(tolua_S,"setInsetRight",lua_cocos2dx_extension_Scale9Sprite_setInsetRight); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_Scale9Sprite_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_Scale9Sprite_create); tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName); tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame); @@ -4676,6 +4676,7 @@ int lua_register_cocos2dx_extension_ControlHuePicker(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlHuePicker","cc.ControlHuePicker","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlHuePicker"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlHuePicker_constructor); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlHuePicker_setEnabled); tolua_function(tolua_S,"initWithTargetAndPos",lua_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos); tolua_function(tolua_S,"setHue",lua_cocos2dx_extension_ControlHuePicker_setHue); @@ -4687,7 +4688,6 @@ int lua_register_cocos2dx_extension_ControlHuePicker(lua_State* tolua_S) tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlHuePicker_getBackground); tolua_function(tolua_S,"getHuePercentage",lua_cocos2dx_extension_ControlHuePicker_getHuePercentage); tolua_function(tolua_S,"setSlider",lua_cocos2dx_extension_ControlHuePicker_setSlider); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlHuePicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlHuePicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlHuePicker).name(); @@ -5181,6 +5181,7 @@ int lua_register_cocos2dx_extension_ControlSaturationBrightnessPicker(lua_State* tolua_cclass(tolua_S,"ControlSaturationBrightnessPicker","cc.ControlSaturationBrightnessPicker","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlSaturationBrightnessPicker"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor); tolua_function(tolua_S,"getShadow",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow); tolua_function(tolua_S,"initWithTargetAndPos",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos); tolua_function(tolua_S,"getStartPos",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos); @@ -5190,7 +5191,6 @@ int lua_register_cocos2dx_extension_ControlSaturationBrightnessPicker(lua_State* tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground); tolua_function(tolua_S,"getSaturation",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation); tolua_function(tolua_S,"getBrightness",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSaturationBrightnessPicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSaturationBrightnessPicker).name(); @@ -5780,6 +5780,7 @@ int lua_register_cocos2dx_extension_ControlColourPicker(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlColourPicker","cc.ControlColourPicker","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlColourPicker"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlColourPicker_constructor); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlColourPicker_setEnabled); tolua_function(tolua_S,"getHuePicker",lua_cocos2dx_extension_ControlColourPicker_getHuePicker); tolua_function(tolua_S,"setColor",lua_cocos2dx_extension_ControlColourPicker_setColor); @@ -5791,7 +5792,6 @@ int lua_register_cocos2dx_extension_ControlColourPicker(lua_State* tolua_S) tolua_function(tolua_S,"colourSliderValueChanged",lua_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged); tolua_function(tolua_S,"setHuePicker",lua_cocos2dx_extension_ControlColourPicker_setHuePicker); tolua_function(tolua_S,"getBackground",lua_cocos2dx_extension_ControlColourPicker_getBackground); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlColourPicker_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlColourPicker_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlColourPicker).name(); @@ -6720,6 +6720,7 @@ int lua_register_cocos2dx_extension_ControlPotentiometer(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlPotentiometer","cc.ControlPotentiometer","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlPotentiometer"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlPotentiometer_constructor); tolua_function(tolua_S,"setPreviousLocation",lua_cocos2dx_extension_ControlPotentiometer_setPreviousLocation); tolua_function(tolua_S,"setValue",lua_cocos2dx_extension_ControlPotentiometer_setValue); tolua_function(tolua_S,"getProgressTimer",lua_cocos2dx_extension_ControlPotentiometer_getProgressTimer); @@ -6738,7 +6739,6 @@ int lua_register_cocos2dx_extension_ControlPotentiometer(lua_State* tolua_S) tolua_function(tolua_S,"getThumbSprite",lua_cocos2dx_extension_ControlPotentiometer_getThumbSprite); tolua_function(tolua_S,"initWithTrackSprite_ProgressTimer_ThumbSprite",lua_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite); tolua_function(tolua_S,"potentiometerMoved",lua_cocos2dx_extension_ControlPotentiometer_potentiometerMoved); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlPotentiometer_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlPotentiometer_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlPotentiometer).name(); @@ -7965,6 +7965,7 @@ int lua_register_cocos2dx_extension_ControlSlider(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlSlider","cc.ControlSlider","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlSlider"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSlider_constructor); tolua_function(tolua_S,"getSelectedThumbSprite",lua_cocos2dx_extension_ControlSlider_getSelectedThumbSprite); tolua_function(tolua_S,"locationFromTouch",lua_cocos2dx_extension_ControlSlider_locationFromTouch); tolua_function(tolua_S,"setSelectedThumbSprite",lua_cocos2dx_extension_ControlSlider_setSelectedThumbSprite); @@ -7988,7 +7989,6 @@ int lua_register_cocos2dx_extension_ControlSlider(lua_State* tolua_S) tolua_function(tolua_S,"getProgressSprite",lua_cocos2dx_extension_ControlSlider_getProgressSprite); tolua_function(tolua_S,"setBackgroundSprite",lua_cocos2dx_extension_ControlSlider_setBackgroundSprite); tolua_function(tolua_S,"setMaximumAllowedValue",lua_cocos2dx_extension_ControlSlider_setMaximumAllowedValue); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSlider_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSlider_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSlider).name(); @@ -9033,6 +9033,7 @@ int lua_register_cocos2dx_extension_ControlStepper(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlStepper","cc.ControlStepper","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlStepper"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlStepper_constructor); tolua_function(tolua_S,"setMinusSprite",lua_cocos2dx_extension_ControlStepper_setMinusSprite); tolua_function(tolua_S,"getMinusLabel",lua_cocos2dx_extension_ControlStepper_getMinusLabel); tolua_function(tolua_S,"setWraps",lua_cocos2dx_extension_ControlStepper_setWraps); @@ -9054,7 +9055,6 @@ int lua_register_cocos2dx_extension_ControlStepper(lua_State* tolua_S) tolua_function(tolua_S,"initWithMinusSpriteAndPlusSprite",lua_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite); tolua_function(tolua_S,"getValue",lua_cocos2dx_extension_ControlStepper_getValue); tolua_function(tolua_S,"setPlusLabel",lua_cocos2dx_extension_ControlStepper_setPlusLabel); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlStepper_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlStepper_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlStepper).name(); @@ -9506,13 +9506,13 @@ int lua_register_cocos2dx_extension_ControlSwitch(lua_State* tolua_S) tolua_cclass(tolua_S,"ControlSwitch","cc.ControlSwitch","cc.Control",nullptr); tolua_beginmodule(tolua_S,"ControlSwitch"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSwitch_constructor); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ControlSwitch_setEnabled); tolua_function(tolua_S,"setOn",lua_cocos2dx_extension_ControlSwitch_setOn); tolua_function(tolua_S,"isOn",lua_cocos2dx_extension_ControlSwitch_isOn); tolua_function(tolua_S,"initWithMaskSprite",lua_cocos2dx_extension_ControlSwitch_initWithMaskSprite); tolua_function(tolua_S,"hasMoved",lua_cocos2dx_extension_ControlSwitch_hasMoved); tolua_function(tolua_S,"locationFromTouch",lua_cocos2dx_extension_ControlSwitch_locationFromTouch); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ControlSwitch_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ControlSwitch_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ControlSwitch).name(); @@ -11179,6 +11179,7 @@ int lua_register_cocos2dx_extension_ScrollView(lua_State* tolua_S) tolua_cclass(tolua_S,"ScrollView","cc.ScrollView","cc.Layer",nullptr); tolua_beginmodule(tolua_S,"ScrollView"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_ScrollView_constructor); tolua_function(tolua_S,"isClippingToBounds",lua_cocos2dx_extension_ScrollView_isClippingToBounds); tolua_function(tolua_S,"setContainer",lua_cocos2dx_extension_ScrollView_setContainer); tolua_function(tolua_S,"onTouchEnded",lua_cocos2dx_extension_ScrollView_onTouchEnded); @@ -11212,7 +11213,6 @@ int lua_register_cocos2dx_extension_ScrollView(lua_State* tolua_S) tolua_function(tolua_S,"isNodeVisible",lua_cocos2dx_extension_ScrollView_isNodeVisible); tolua_function(tolua_S,"minContainerOffset",lua_cocos2dx_extension_ScrollView_minContainerOffset); tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_extension_ScrollView_setZoomScale); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_ScrollView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_ScrollView_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::ScrollView).name(); @@ -11431,10 +11431,10 @@ int lua_register_cocos2dx_extension_TableViewCell(lua_State* tolua_S) tolua_cclass(tolua_S,"TableViewCell","cc.TableViewCell","cc.Node",nullptr); tolua_beginmodule(tolua_S,"TableViewCell"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableViewCell_constructor); tolua_function(tolua_S,"reset",lua_cocos2dx_extension_TableViewCell_reset); tolua_function(tolua_S,"getIdx",lua_cocos2dx_extension_TableViewCell_getIdx); tolua_function(tolua_S,"setIdx",lua_cocos2dx_extension_TableViewCell_setIdx); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableViewCell_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_TableViewCell_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::TableViewCell).name(); @@ -12047,6 +12047,7 @@ int lua_register_cocos2dx_extension_TableView(lua_State* tolua_S) tolua_cclass(tolua_S,"TableView","cc.TableView","cc.ScrollView",nullptr); tolua_beginmodule(tolua_S,"TableView"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableView_constructor); tolua_function(tolua_S,"updateCellAtIndex",lua_cocos2dx_extension_TableView_updateCellAtIndex); tolua_function(tolua_S,"setVerticalFillOrder",lua_cocos2dx_extension_TableView_setVerticalFillOrder); tolua_function(tolua_S,"scrollViewDidZoom",lua_cocos2dx_extension_TableView_scrollViewDidZoom); @@ -12059,7 +12060,6 @@ int lua_register_cocos2dx_extension_TableView(lua_State* tolua_S) tolua_function(tolua_S,"insertCellAtIndex",lua_cocos2dx_extension_TableView_insertCellAtIndex); tolua_function(tolua_S,"cellAtIndex",lua_cocos2dx_extension_TableView_cellAtIndex); tolua_function(tolua_S,"dequeueCell",lua_cocos2dx_extension_TableView_dequeueCell); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_TableView_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::TableView).name(); g_luaType[typeName] = "cc.TableView"; @@ -13010,6 +13010,7 @@ int lua_register_cocos2dx_extension_EditBox(lua_State* tolua_S) tolua_cclass(tolua_S,"EditBox","cc.EditBox","cc.ControlButton",nullptr); tolua_beginmodule(tolua_S,"EditBox"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_EditBox_constructor); tolua_function(tolua_S,"getText",lua_cocos2dx_extension_EditBox_getText); tolua_function(tolua_S,"setPlaceholderFontName",lua_cocos2dx_extension_EditBox_setPlaceholderFontName); tolua_function(tolua_S,"getPlaceHolder",lua_cocos2dx_extension_EditBox_getPlaceHolder); @@ -13028,7 +13029,6 @@ int lua_register_cocos2dx_extension_EditBox(lua_State* tolua_S) tolua_function(tolua_S,"setText",lua_cocos2dx_extension_EditBox_setText); tolua_function(tolua_S,"setMaxLength",lua_cocos2dx_extension_EditBox_setMaxLength); tolua_function(tolua_S,"setFont",lua_cocos2dx_extension_EditBox_setFont); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_EditBox_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_EditBox_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::EditBox).name(); @@ -13723,6 +13723,7 @@ int lua_register_cocos2dx_extension_AssetsManager(lua_State* tolua_S) tolua_cclass(tolua_S,"AssetsManager","cc.AssetsManager","cc.Node",nullptr); tolua_beginmodule(tolua_S,"AssetsManager"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_AssetsManager_constructor); tolua_function(tolua_S,"setStoragePath",lua_cocos2dx_extension_AssetsManager_setStoragePath); tolua_function(tolua_S,"setPackageUrl",lua_cocos2dx_extension_AssetsManager_setPackageUrl); tolua_function(tolua_S,"checkUpdate",lua_cocos2dx_extension_AssetsManager_checkUpdate); @@ -13735,7 +13736,6 @@ int lua_register_cocos2dx_extension_AssetsManager(lua_State* tolua_S) tolua_function(tolua_S,"getVersion",lua_cocos2dx_extension_AssetsManager_getVersion); tolua_function(tolua_S,"getVersionFileUrl",lua_cocos2dx_extension_AssetsManager_getVersionFileUrl); tolua_function(tolua_S,"deleteVersion",lua_cocos2dx_extension_AssetsManager_deleteVersion); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_AssetsManager_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_extension_AssetsManager_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::extension::AssetsManager).name(); @@ -15441,6 +15441,7 @@ int lua_register_cocos2dx_extension_CCBAnimationManager(lua_State* tolua_S) tolua_cclass(tolua_S,"CCBAnimationManager","cc.CCBAnimationManager","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"CCBAnimationManager"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBAnimationManager_constructor); tolua_function(tolua_S,"moveAnimationsFromNode",lua_cocos2dx_extension_CCBAnimationManager_moveAnimationsFromNode); tolua_function(tolua_S,"setAutoPlaySequenceId",lua_cocos2dx_extension_CCBAnimationManager_setAutoPlaySequenceId); tolua_function(tolua_S,"getDocumentCallbackNames",lua_cocos2dx_extension_CCBAnimationManager_getDocumentCallbackNames); @@ -15477,7 +15478,6 @@ int lua_register_cocos2dx_extension_CCBAnimationManager(lua_State* tolua_S) tolua_function(tolua_S,"setSequences",lua_cocos2dx_extension_CCBAnimationManager_setSequences); tolua_function(tolua_S,"debug",lua_cocos2dx_extension_CCBAnimationManager_debug); tolua_function(tolua_S,"getDocumentControllerName",lua_cocos2dx_extension_CCBAnimationManager_getDocumentControllerName); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBAnimationManager_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocosbuilder::CCBAnimationManager).name(); g_luaType[typeName] = "cc.CCBAnimationManager"; @@ -16469,6 +16469,7 @@ int lua_register_cocos2dx_extension_CCBReader(lua_State* tolua_S) tolua_cclass(tolua_S,"CCBReader","cc.CCBReader","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"CCBReader"); + tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBReader_constructor); tolua_function(tolua_S,"addOwnerOutletName",lua_cocos2dx_extension_CCBReader_addOwnerOutletName); tolua_function(tolua_S,"getOwnerCallbackNames",lua_cocos2dx_extension_CCBReader_getOwnerCallbackNames); tolua_function(tolua_S,"addDocumentCallbackControlEvents",lua_cocos2dx_extension_CCBReader_addDocumentCallbackControlEvents); @@ -16487,7 +16488,6 @@ int lua_register_cocos2dx_extension_CCBReader(lua_State* tolua_S) tolua_function(tolua_S,"getAnimationManagersForNodes",lua_cocos2dx_extension_CCBReader_getAnimationManagersForNodes); tolua_function(tolua_S,"getNodesWithAnimationManagers",lua_cocos2dx_extension_CCBReader_getNodesWithAnimationManagers); tolua_function(tolua_S,"getActionManager",lua_cocos2dx_extension_CCBReader_getAnimationManager); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_CCBReader_constructor); tolua_function(tolua_S,"setResolutionScale", lua_cocos2dx_extension_CCBReader_setResolutionScale); tolua_endmodule(tolua_S); std::string typeName = typeid(cocosbuilder::CCBReader).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp index e41bcee980..55c306c217 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp @@ -123,11 +123,11 @@ int lua_cocos2dx_spine_Skeleton_onDraw(lua_State* tolua_S) if (argc == 2) { cocos2d::Mat4 arg0; - bool arg1; + unsigned int arg1; ok &= luaval_to_mat4(tolua_S, 2, &arg0); - ok &= luaval_to_boolean(tolua_S, 3,&arg1); + ok &= luaval_to_uint32(tolua_S, 3,&arg1); if(!ok) return 0; cobj->onDraw(arg0, arg1); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp index be3c27cf08..20b5463506 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp @@ -818,6 +818,7 @@ int lua_register_cocos2dx_studio_ActionObject(lua_State* tolua_S) tolua_cclass(tolua_S,"ActionObject","ccs.ActionObject","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"ActionObject"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ActionObject_constructor); tolua_function(tolua_S,"setCurrentTime",lua_cocos2dx_studio_ActionObject_setCurrentTime); tolua_function(tolua_S,"pause",lua_cocos2dx_studio_ActionObject_pause); tolua_function(tolua_S,"setName",lua_cocos2dx_studio_ActionObject_setName); @@ -835,7 +836,6 @@ int lua_register_cocos2dx_studio_ActionObject(lua_State* tolua_S) tolua_function(tolua_S,"updateToFrameByTime",lua_cocos2dx_studio_ActionObject_updateToFrameByTime); tolua_function(tolua_S,"setLoop",lua_cocos2dx_studio_ActionObject_setLoop); tolua_function(tolua_S,"simulationActionUpdate",lua_cocos2dx_studio_ActionObject_simulationActionUpdate); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_ActionObject_constructor); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ActionObject).name(); g_luaType[typeName] = "ccs.ActionObject"; @@ -1255,9 +1255,9 @@ int lua_register_cocos2dx_studio_BaseData(lua_State* tolua_S) tolua_cclass(tolua_S,"BaseData","ccs.BaseData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"BaseData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_BaseData_constructor); tolua_function(tolua_S,"getColor",lua_cocos2dx_studio_BaseData_getColor); tolua_function(tolua_S,"setColor",lua_cocos2dx_studio_BaseData_setColor); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_BaseData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_BaseData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::BaseData).name(); @@ -1422,8 +1422,8 @@ int lua_register_cocos2dx_studio_DisplayData(lua_State* tolua_S) tolua_cclass(tolua_S,"DisplayData","ccs.DisplayData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"DisplayData"); - tolua_function(tolua_S,"copy",lua_cocos2dx_studio_DisplayData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_DisplayData_constructor); + tolua_function(tolua_S,"copy",lua_cocos2dx_studio_DisplayData_copy); tolua_function(tolua_S,"changeDisplayToTexture", lua_cocos2dx_studio_DisplayData_changeDisplayToTexture); tolua_function(tolua_S,"create", lua_cocos2dx_studio_DisplayData_create); tolua_endmodule(tolua_S); @@ -1556,8 +1556,8 @@ int lua_register_cocos2dx_studio_SpriteDisplayData(lua_State* tolua_S) tolua_cclass(tolua_S,"SpriteDisplayData","ccs.SpriteDisplayData","ccs.DisplayData",nullptr); tolua_beginmodule(tolua_S,"SpriteDisplayData"); - tolua_function(tolua_S,"copy",lua_cocos2dx_studio_SpriteDisplayData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_SpriteDisplayData_constructor); + tolua_function(tolua_S,"copy",lua_cocos2dx_studio_SpriteDisplayData_copy); tolua_function(tolua_S,"create", lua_cocos2dx_studio_SpriteDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::SpriteDisplayData).name(); @@ -1643,6 +1643,7 @@ int lua_register_cocos2dx_studio_ArmatureDisplayData(lua_State* tolua_S) tolua_cclass(tolua_S,"ArmatureDisplayData","ccs.ArmatureDisplayData","ccs.DisplayData",nullptr); tolua_beginmodule(tolua_S,"ArmatureDisplayData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureDisplayData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureDisplayData).name(); @@ -1728,6 +1729,7 @@ int lua_register_cocos2dx_studio_ParticleDisplayData(lua_State* tolua_S) tolua_cclass(tolua_S,"ParticleDisplayData","ccs.ParticleDisplayData","ccs.DisplayData",nullptr); tolua_beginmodule(tolua_S,"ParticleDisplayData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ParticleDisplayData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ParticleDisplayData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ParticleDisplayData).name(); @@ -1950,10 +1952,10 @@ int lua_register_cocos2dx_studio_BoneData(lua_State* tolua_S) tolua_cclass(tolua_S,"BoneData","ccs.BoneData","ccs.BaseData",nullptr); tolua_beginmodule(tolua_S,"BoneData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_BoneData_constructor); tolua_function(tolua_S,"getDisplayData",lua_cocos2dx_studio_BoneData_getDisplayData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_BoneData_init); tolua_function(tolua_S,"addDisplayData",lua_cocos2dx_studio_BoneData_addDisplayData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_BoneData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_BoneData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::BoneData).name(); @@ -2176,10 +2178,10 @@ int lua_register_cocos2dx_studio_ArmatureData(lua_State* tolua_S) tolua_cclass(tolua_S,"ArmatureData","ccs.ArmatureData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"ArmatureData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureData_constructor); tolua_function(tolua_S,"addBoneData",lua_cocos2dx_studio_ArmatureData_addBoneData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ArmatureData_init); tolua_function(tolua_S,"getBoneData",lua_cocos2dx_studio_ArmatureData_getBoneData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureData).name(); @@ -2311,8 +2313,8 @@ int lua_register_cocos2dx_studio_FrameData(lua_State* tolua_S) tolua_cclass(tolua_S,"FrameData","ccs.FrameData","ccs.BaseData",nullptr); tolua_beginmodule(tolua_S,"FrameData"); - tolua_function(tolua_S,"copy",lua_cocos2dx_studio_FrameData_copy); tolua_function(tolua_S,"new",lua_cocos2dx_studio_FrameData_constructor); + tolua_function(tolua_S,"copy",lua_cocos2dx_studio_FrameData_copy); tolua_function(tolua_S,"create", lua_cocos2dx_studio_FrameData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::FrameData).name(); @@ -2535,10 +2537,10 @@ int lua_register_cocos2dx_studio_MovementBoneData(lua_State* tolua_S) tolua_cclass(tolua_S,"MovementBoneData","ccs.MovementBoneData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"MovementBoneData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementBoneData_constructor); tolua_function(tolua_S,"init",lua_cocos2dx_studio_MovementBoneData_init); tolua_function(tolua_S,"getFrameData",lua_cocos2dx_studio_MovementBoneData_getFrameData); tolua_function(tolua_S,"addFrameData",lua_cocos2dx_studio_MovementBoneData_addFrameData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementBoneData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_MovementBoneData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::MovementBoneData).name(); @@ -2717,9 +2719,9 @@ int lua_register_cocos2dx_studio_MovementData(lua_State* tolua_S) tolua_cclass(tolua_S,"MovementData","ccs.MovementData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"MovementData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementData_constructor); tolua_function(tolua_S,"getMovementBoneData",lua_cocos2dx_studio_MovementData_getMovementBoneData); tolua_function(tolua_S,"addMovementBoneData",lua_cocos2dx_studio_MovementData_addMovementBoneData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_MovementData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_MovementData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::MovementData).name(); @@ -2942,10 +2944,10 @@ int lua_register_cocos2dx_studio_AnimationData(lua_State* tolua_S) tolua_cclass(tolua_S,"AnimationData","ccs.AnimationData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"AnimationData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_AnimationData_constructor); tolua_function(tolua_S,"getMovement",lua_cocos2dx_studio_AnimationData_getMovement); tolua_function(tolua_S,"getMovementCount",lua_cocos2dx_studio_AnimationData_getMovementCount); tolua_function(tolua_S,"addMovement",lua_cocos2dx_studio_AnimationData_addMovement); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_AnimationData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_AnimationData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::AnimationData).name(); @@ -3121,9 +3123,9 @@ int lua_register_cocos2dx_studio_ContourData(lua_State* tolua_S) tolua_cclass(tolua_S,"ContourData","ccs.ContourData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"ContourData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ContourData_constructor); tolua_function(tolua_S,"init",lua_cocos2dx_studio_ContourData_init); tolua_function(tolua_S,"addVertex",lua_cocos2dx_studio_ContourData_addVertex); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_ContourData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ContourData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ContourData).name(); @@ -3346,10 +3348,10 @@ int lua_register_cocos2dx_studio_TextureData(lua_State* tolua_S) tolua_cclass(tolua_S,"TextureData","ccs.TextureData","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"TextureData"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_TextureData_constructor); tolua_function(tolua_S,"getContourData",lua_cocos2dx_studio_TextureData_getContourData); tolua_function(tolua_S,"init",lua_cocos2dx_studio_TextureData_init); tolua_function(tolua_S,"addContourData",lua_cocos2dx_studio_TextureData_addContourData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_TextureData_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_TextureData_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::TextureData).name(); @@ -3724,13 +3726,13 @@ int lua_register_cocos2dx_studio_Tween(lua_State* tolua_S) tolua_cclass(tolua_S,"Tween","ccs.Tween","ccs.ProcessBase",nullptr); tolua_beginmodule(tolua_S,"Tween"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_Tween_constructor); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_studio_Tween_getAnimation); tolua_function(tolua_S,"gotoAndPause",lua_cocos2dx_studio_Tween_gotoAndPause); tolua_function(tolua_S,"play",lua_cocos2dx_studio_Tween_play); tolua_function(tolua_S,"gotoAndPlay",lua_cocos2dx_studio_Tween_gotoAndPlay); tolua_function(tolua_S,"init",lua_cocos2dx_studio_Tween_init); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_studio_Tween_setAnimation); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_Tween_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Tween_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Tween).name(); @@ -4661,6 +4663,7 @@ int lua_register_cocos2dx_studio_DisplayManager(lua_State* tolua_S) tolua_cclass(tolua_S,"DisplayManager","ccs.DisplayManager","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"DisplayManager"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_DisplayManager_constructor); tolua_function(tolua_S,"getDisplayRenderNode",lua_cocos2dx_studio_DisplayManager_getDisplayRenderNode); tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_studio_DisplayManager_getAnchorPointInPoints); tolua_function(tolua_S,"getDisplayRenderNodeType",lua_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType); @@ -4679,7 +4682,6 @@ int lua_register_cocos2dx_studio_DisplayManager(lua_State* tolua_S) tolua_function(tolua_S,"getDecorativeDisplayList",lua_cocos2dx_studio_DisplayManager_getDecorativeDisplayList); tolua_function(tolua_S,"isVisible",lua_cocos2dx_studio_DisplayManager_isVisible); tolua_function(tolua_S,"setVisible",lua_cocos2dx_studio_DisplayManager_setVisible); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_DisplayManager_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_DisplayManager_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::DisplayManager).name(); @@ -6288,6 +6290,7 @@ int lua_register_cocos2dx_studio_Bone(lua_State* tolua_S) tolua_cclass(tolua_S,"Bone","ccs.Bone","cc.Node",nullptr); tolua_beginmodule(tolua_S,"Bone"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_Bone_constructor); tolua_function(tolua_S,"isTransformDirty",lua_cocos2dx_studio_Bone_isTransformDirty); tolua_function(tolua_S,"isIgnoreMovementBoneData",lua_cocos2dx_studio_Bone_isIgnoreMovementBoneData); tolua_function(tolua_S,"updateZOrder",lua_cocos2dx_studio_Bone_updateZOrder); @@ -6321,7 +6324,6 @@ int lua_register_cocos2dx_studio_Bone(lua_State* tolua_S) tolua_function(tolua_S,"getDisplayManager",lua_cocos2dx_studio_Bone_getDisplayManager); tolua_function(tolua_S,"getArmature",lua_cocos2dx_studio_Bone_getArmature); tolua_function(tolua_S,"getBoneData",lua_cocos2dx_studio_Bone_getBoneData); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_Bone_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Bone_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Bone).name(); @@ -7387,6 +7389,7 @@ int lua_register_cocos2dx_studio_ArmatureAnimation(lua_State* tolua_S) tolua_cclass(tolua_S,"ArmatureAnimation","ccs.ArmatureAnimation","ccs.ProcessBase",nullptr); tolua_beginmodule(tolua_S,"ArmatureAnimation"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureAnimation_constructor); tolua_function(tolua_S,"getSpeedScale",lua_cocos2dx_studio_ArmatureAnimation_getSpeedScale); tolua_function(tolua_S,"pause",lua_cocos2dx_studio_ArmatureAnimation_pause); tolua_function(tolua_S,"setSpeedScale",lua_cocos2dx_studio_ArmatureAnimation_setSpeedScale); @@ -7404,7 +7407,6 @@ int lua_register_cocos2dx_studio_ArmatureAnimation(lua_State* tolua_S) tolua_function(tolua_S,"gotoAndPlay",lua_cocos2dx_studio_ArmatureAnimation_gotoAndPlay); tolua_function(tolua_S,"playWithNames",lua_cocos2dx_studio_ArmatureAnimation_playWithNames); tolua_function(tolua_S,"getMovementCount",lua_cocos2dx_studio_ArmatureAnimation_getMovementCount); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_ArmatureAnimation_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ArmatureAnimation_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::ArmatureAnimation).name(); @@ -9510,6 +9512,7 @@ int lua_register_cocos2dx_studio_Armature(lua_State* tolua_S) tolua_cclass(tolua_S,"Armature","ccs.Armature","cc.Node",nullptr); tolua_beginmodule(tolua_S,"Armature"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_Armature_constructor); tolua_function(tolua_S,"getBone",lua_cocos2dx_studio_Armature_getBone); tolua_function(tolua_S,"changeBoneParent",lua_cocos2dx_studio_Armature_changeBoneParent); tolua_function(tolua_S,"setAnimation",lua_cocos2dx_studio_Armature_setAnimation); @@ -9532,7 +9535,6 @@ int lua_register_cocos2dx_studio_Armature(lua_State* tolua_S) tolua_function(tolua_S,"getVersion",lua_cocos2dx_studio_Armature_getVersion); tolua_function(tolua_S,"getAnimation",lua_cocos2dx_studio_Armature_getAnimation); tolua_function(tolua_S,"getBoneDic",lua_cocos2dx_studio_Armature_getBoneDic); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_Armature_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Armature_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocostudio::Armature).name(); @@ -9980,6 +9982,7 @@ int lua_register_cocos2dx_studio_Skin(lua_State* tolua_S) tolua_cclass(tolua_S,"Skin","ccs.Skin","cc.Sprite",nullptr); tolua_beginmodule(tolua_S,"Skin"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_Skin_constructor); tolua_function(tolua_S,"getBone",lua_cocos2dx_studio_Skin_getBone); tolua_function(tolua_S,"getNodeToWorldTransformAR",lua_cocos2dx_studio_Skin_getNodeToWorldTransformAR); tolua_function(tolua_S,"initWithFile",lua_cocos2dx_studio_Skin_initWithFile); @@ -9987,7 +9990,6 @@ int lua_register_cocos2dx_studio_Skin(lua_State* tolua_S) tolua_function(tolua_S,"updateArmatureTransform",lua_cocos2dx_studio_Skin_updateArmatureTransform); tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_studio_Skin_initWithSpriteFrameName); tolua_function(tolua_S,"setBone",lua_cocos2dx_studio_Skin_setBone); - tolua_function(tolua_S,"new",lua_cocos2dx_studio_Skin_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_Skin_create); tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_studio_Skin_createWithSpriteFrameName); tolua_endmodule(tolua_S); @@ -11998,6 +12000,7 @@ int lua_register_cocos2dx_studio_ComController(lua_State* tolua_S) tolua_cclass(tolua_S,"ComController","ccs.ComController","cc.Component",nullptr); tolua_beginmodule(tolua_S,"ComController"); + tolua_function(tolua_S,"new",lua_cocos2dx_studio_ComController_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_studio_ComController_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_studio_ComController_createInstance); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 5d4c79e84c..0545aa5cf3 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -260,11 +260,11 @@ int lua_register_cocos2dx_ui_LayoutParameter(lua_State* tolua_S) tolua_cclass(tolua_S,"LayoutParameter","ccui.LayoutParameter","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"LayoutParameter"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_LayoutParameter_constructor); tolua_function(tolua_S,"clone",lua_cocos2dx_ui_LayoutParameter_clone); tolua_function(tolua_S,"getLayoutType",lua_cocos2dx_ui_LayoutParameter_getLayoutType); tolua_function(tolua_S,"createCloneInstance",lua_cocos2dx_ui_LayoutParameter_createCloneInstance); tolua_function(tolua_S,"copyProperties",lua_cocos2dx_ui_LayoutParameter_copyProperties); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_LayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_LayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::LayoutParameter).name(); @@ -440,9 +440,9 @@ int lua_register_cocos2dx_ui_LinearLayoutParameter(lua_State* tolua_S) tolua_cclass(tolua_S,"LinearLayoutParameter","ccui.LinearLayoutParameter","ccui.LayoutParameter",nullptr); tolua_beginmodule(tolua_S,"LinearLayoutParameter"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_LinearLayoutParameter_constructor); tolua_function(tolua_S,"setGravity",lua_cocos2dx_ui_LinearLayoutParameter_setGravity); tolua_function(tolua_S,"getGravity",lua_cocos2dx_ui_LinearLayoutParameter_getGravity); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_LinearLayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_LinearLayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::LinearLayoutParameter).name(); @@ -798,13 +798,13 @@ int lua_register_cocos2dx_ui_RelativeLayoutParameter(lua_State* tolua_S) tolua_cclass(tolua_S,"RelativeLayoutParameter","ccui.RelativeLayoutParameter","ccui.LayoutParameter",nullptr); tolua_beginmodule(tolua_S,"RelativeLayoutParameter"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_RelativeLayoutParameter_constructor); tolua_function(tolua_S,"setAlign",lua_cocos2dx_ui_RelativeLayoutParameter_setAlign); tolua_function(tolua_S,"setRelativeToWidgetName",lua_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName); tolua_function(tolua_S,"getRelativeName",lua_cocos2dx_ui_RelativeLayoutParameter_getRelativeName); tolua_function(tolua_S,"getRelativeToWidgetName",lua_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName); tolua_function(tolua_S,"setRelativeName",lua_cocos2dx_ui_RelativeLayoutParameter_setRelativeName); tolua_function(tolua_S,"getAlign",lua_cocos2dx_ui_RelativeLayoutParameter_getAlign); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_RelativeLayoutParameter_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_RelativeLayoutParameter_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RelativeLayoutParameter).name(); @@ -813,50 +813,6 @@ int lua_register_cocos2dx_ui_RelativeLayoutParameter(lua_State* tolua_S) return 1; } -int lua_cocos2dx_ui_Widget_clone(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_clone'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::ui::Widget* ret = cobj->clone(); - object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_clone'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_setSizePercent(lua_State* tolua_S) { int argc = 0; @@ -1081,7 +1037,7 @@ int lua_cocos2dx_ui_Widget_getVirtualRenderer(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getTouchEndPos(lua_State* tolua_S) +int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Widget* cobj = nullptr; @@ -1101,7 +1057,7 @@ int lua_cocos2dx_ui_Widget_getTouchEndPos(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchEndPos'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSize'", nullptr); return 0; } #endif @@ -1111,16 +1067,16 @@ int lua_cocos2dx_ui_Widget_getTouchEndPos(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vec2& ret = cobj->getTouchEndPos(); - vec2_to_luaval(tolua_S, ret); + const cocos2d::Size& ret = cobj->getSize(); + size_to_luaval(tolua_S, ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchEndPos",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSize",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchEndPos'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSize'.",&tolua_err); #endif return 0; @@ -1527,6 +1483,56 @@ int lua_cocos2dx_ui_Widget_getLayoutParameter(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Widget_findNextFocusedWidget(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Widget* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_findNextFocusedWidget'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + cocos2d::ui::Widget::FocusDirection arg0; + cocos2d::ui::Widget* arg1; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); + + ok &= luaval_to_object(tolua_S, 3, "ccui.Widget",&arg1); + if(!ok) + return 0; + cocos2d::ui::Widget* ret = cobj->findNextFocusedWidget(arg0, arg1); + object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "findNextFocusedWidget",argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_findNextFocusedWidget'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Widget_getPositionType(lua_State* tolua_S) { int argc = 0; @@ -1750,7 +1756,7 @@ int lua_cocos2dx_ui_Widget_isFocused(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_findNextFocusedWidget(lua_State* tolua_S) +int lua_cocos2dx_ui_Widget_getTouchBeganPosition(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Widget* cobj = nullptr; @@ -1770,32 +1776,26 @@ int lua_cocos2dx_ui_Widget_findNextFocusedWidget(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_findNextFocusedWidget'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchBeganPosition'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 2) + if (argc == 0) { - cocos2d::ui::Widget::FocusDirection arg0; - cocos2d::ui::Widget* arg1; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_object(tolua_S, 3, "ccui.Widget",&arg1); if(!ok) return 0; - cocos2d::ui::Widget* ret = cobj->findNextFocusedWidget(arg0, arg1); - object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); + const cocos2d::Vec2& ret = cobj->getTouchBeganPosition(); + vec2_to_luaval(tolua_S, ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "findNextFocusedWidget",argc, 2); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchBeganPosition",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_findNextFocusedWidget'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchBeganPosition'.",&tolua_err); #endif return 0; @@ -2116,50 +2116,6 @@ int lua_cocos2dx_ui_Widget_setFlippedY(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getTouchMovePos(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchMovePos'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - const cocos2d::Vec2& ret = cobj->getTouchMovePos(); - vec2_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchMovePos",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchMovePos'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_setEnabled(lua_State* tolua_S) { int argc = 0; @@ -2388,7 +2344,7 @@ int lua_cocos2dx_ui_Widget_setLayoutParameter(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S) +int lua_cocos2dx_ui_Widget_clone(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Widget* cobj = nullptr; @@ -2408,7 +2364,7 @@ int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSizePercent'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_clone'", nullptr); return 0; } #endif @@ -2418,60 +2374,16 @@ int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Vec2& ret = cobj->getSizePercent(); - vec2_to_luaval(tolua_S, ret); + cocos2d::ui::Widget* ret = cobj->clone(); + object_to_luaval(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizePercent",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clone",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSizePercent'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_ui_Widget_getTouchStartPos(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchStartPos'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - const cocos2d::Vec2& ret = cobj->getTouchStartPos(); - vec2_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchStartPos",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchStartPos'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_clone'.",&tolua_err); #endif return 0; @@ -2610,53 +2522,6 @@ int lua_cocos2dx_ui_Widget_isBright(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_clippingParentAreaContainPoint(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_clippingParentAreaContainPoint'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Vec2 arg0; - - ok &= luaval_to_vec2(tolua_S, 2, &arg0); - if(!ok) - return 0; - bool ret = cobj->clippingParentAreaContainPoint(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clippingParentAreaContainPoint",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_clippingParentAreaContainPoint'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_getCurrentFocusedWidget(lua_State* tolua_S) { int argc = 0; @@ -2793,7 +2658,7 @@ int lua_cocos2dx_ui_Widget_updateSizeAndPosition(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S) +int lua_cocos2dx_ui_Widget_getSizePercent(lua_State* tolua_S) { int argc = 0; cocos2d::ui::Widget* cobj = nullptr; @@ -2813,7 +2678,7 @@ int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSize'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getSizePercent'", nullptr); return 0; } #endif @@ -2823,16 +2688,60 @@ int lua_cocos2dx_ui_Widget_getSize(lua_State* tolua_S) { if(!ok) return 0; - const cocos2d::Size& ret = cobj->getSize(); - size_to_luaval(tolua_S, ret); + const cocos2d::Vec2& ret = cobj->getSizePercent(); + vec2_to_luaval(tolua_S, ret); return 1; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSize",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSizePercent",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSize'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getSizePercent'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_Widget_getTouchMovePosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Widget* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchMovePosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::Vec2& ret = cobj->getTouchMovePosition(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchMovePosition",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchMovePosition'.",&tolua_err); #endif return 0; @@ -2927,58 +2836,6 @@ int lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Widget_interceptTouchEvent(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Widget* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_interceptTouchEvent'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - cocos2d::ui::Widget::TouchEventType arg0; - cocos2d::ui::Widget* arg1; - cocos2d::Vec2 arg2; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0); - - ok &= luaval_to_object(tolua_S, 3, "ccui.Widget",&arg1); - - ok &= luaval_to_vec2(tolua_S, 4, &arg2); - if(!ok) - return 0; - cobj->interceptTouchEvent(arg0, arg1, arg2); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "interceptTouchEvent",argc, 3); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_interceptTouchEvent'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Widget_addTouchEventListener(lua_State* tolua_S) { int argc = 0; @@ -3029,6 +2886,50 @@ int lua_cocos2dx_ui_Widget_addTouchEventListener(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Widget_getTouchEndPosition(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Widget* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getTouchEndPosition'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::Vec2& ret = cobj->getTouchEndPosition(); + vec2_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTouchEndPosition",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getTouchEndPosition'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Widget_getPositionPercent(lua_State* tolua_S) { int argc = 0; @@ -3208,6 +3109,53 @@ int lua_cocos2dx_ui_Widget_isFlippedY(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Widget_isClippingParentContainsPoint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Widget* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_isClippingParentContainsPoint'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Vec2 arg0; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0); + if(!ok) + return 0; + bool ret = cobj->isClippingParentContainsPoint(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isClippingParentContainsPoint",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_isClippingParentContainsPoint'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Widget_setSizeType(lua_State* tolua_S) { int argc = 0; @@ -3499,13 +3447,13 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_cclass(tolua_S,"Widget","ccui.Widget","cc.ProtectedNode",nullptr); tolua_beginmodule(tolua_S,"Widget"); - tolua_function(tolua_S,"clone",lua_cocos2dx_ui_Widget_clone); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_Widget_constructor); tolua_function(tolua_S,"setSizePercent",lua_cocos2dx_ui_Widget_setSizePercent); tolua_function(tolua_S,"getCustomSize",lua_cocos2dx_ui_Widget_getCustomSize); tolua_function(tolua_S,"getLeftBoundary",lua_cocos2dx_ui_Widget_getLeftBoundary); tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_ui_Widget_setFlippedX); tolua_function(tolua_S,"getVirtualRenderer",lua_cocos2dx_ui_Widget_getVirtualRenderer); - tolua_function(tolua_S,"getTouchEndPos",lua_cocos2dx_ui_Widget_getTouchEndPos); + tolua_function(tolua_S,"getSize",lua_cocos2dx_ui_Widget_getSize); tolua_function(tolua_S,"setPositionPercent",lua_cocos2dx_ui_Widget_setPositionPercent); tolua_function(tolua_S,"getLayoutSize",lua_cocos2dx_ui_Widget_getLayoutSize); tolua_function(tolua_S,"setHighlighted",lua_cocos2dx_ui_Widget_setHighlighted); @@ -3515,12 +3463,13 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"getVirtualRendererSize",lua_cocos2dx_ui_Widget_getVirtualRendererSize); tolua_function(tolua_S,"isHighlighted",lua_cocos2dx_ui_Widget_isHighlighted); tolua_function(tolua_S,"getLayoutParameter",lua_cocos2dx_ui_Widget_getLayoutParameter); + tolua_function(tolua_S,"findNextFocusedWidget",lua_cocos2dx_ui_Widget_findNextFocusedWidget); tolua_function(tolua_S,"getPositionType",lua_cocos2dx_ui_Widget_getPositionType); tolua_function(tolua_S,"getTopBoundary",lua_cocos2dx_ui_Widget_getTopBoundary); tolua_function(tolua_S,"getChildByName",lua_cocos2dx_ui_Widget_getChildByName); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_ui_Widget_isEnabled); tolua_function(tolua_S,"isFocused",lua_cocos2dx_ui_Widget_isFocused); - tolua_function(tolua_S,"findNextFocusedWidget",lua_cocos2dx_ui_Widget_findNextFocusedWidget); + tolua_function(tolua_S,"getTouchBeganPosition",lua_cocos2dx_ui_Widget_getTouchBeganPosition); tolua_function(tolua_S,"isTouchEnabled",lua_cocos2dx_ui_Widget_isTouchEnabled); tolua_function(tolua_S,"getActionTag",lua_cocos2dx_ui_Widget_getActionTag); tolua_function(tolua_S,"getWorldPosition",lua_cocos2dx_ui_Widget_getWorldPosition); @@ -3528,35 +3477,33 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S) tolua_function(tolua_S,"setActionTag",lua_cocos2dx_ui_Widget_setActionTag); tolua_function(tolua_S,"setTouchEnabled",lua_cocos2dx_ui_Widget_setTouchEnabled); tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_ui_Widget_setFlippedY); - tolua_function(tolua_S,"getTouchMovePos",lua_cocos2dx_ui_Widget_getTouchMovePos); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_ui_Widget_setEnabled); tolua_function(tolua_S,"getRightBoundary",lua_cocos2dx_ui_Widget_getRightBoundary); tolua_function(tolua_S,"setBrightStyle",lua_cocos2dx_ui_Widget_setBrightStyle); tolua_function(tolua_S,"setName",lua_cocos2dx_ui_Widget_setName); tolua_function(tolua_S,"setLayoutParameter",lua_cocos2dx_ui_Widget_setLayoutParameter); - tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_ui_Widget_getSizePercent); - tolua_function(tolua_S,"getTouchStartPos",lua_cocos2dx_ui_Widget_getTouchStartPos); + tolua_function(tolua_S,"clone",lua_cocos2dx_ui_Widget_clone); tolua_function(tolua_S,"setFocusEnabled",lua_cocos2dx_ui_Widget_setFocusEnabled); tolua_function(tolua_S,"getBottomBoundary",lua_cocos2dx_ui_Widget_getBottomBoundary); tolua_function(tolua_S,"isBright",lua_cocos2dx_ui_Widget_isBright); - tolua_function(tolua_S,"clippingParentAreaContainPoint",lua_cocos2dx_ui_Widget_clippingParentAreaContainPoint); tolua_function(tolua_S,"getCurrentFocusedWidget",lua_cocos2dx_ui_Widget_getCurrentFocusedWidget); tolua_function(tolua_S,"requestFocus",lua_cocos2dx_ui_Widget_requestFocus); tolua_function(tolua_S,"updateSizeAndPosition",lua_cocos2dx_ui_Widget_updateSizeAndPosition); - tolua_function(tolua_S,"getSize",lua_cocos2dx_ui_Widget_getSize); + tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_ui_Widget_getSizePercent); + tolua_function(tolua_S,"getTouchMovePosition",lua_cocos2dx_ui_Widget_getTouchMovePosition); tolua_function(tolua_S,"getSizeType",lua_cocos2dx_ui_Widget_getSizeType); tolua_function(tolua_S,"ignoreContentAdaptWithSize",lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize); - tolua_function(tolua_S,"interceptTouchEvent",lua_cocos2dx_ui_Widget_interceptTouchEvent); tolua_function(tolua_S,"addTouchEventListener",lua_cocos2dx_ui_Widget_addTouchEventListener); + tolua_function(tolua_S,"getTouchEndPosition",lua_cocos2dx_ui_Widget_getTouchEndPosition); tolua_function(tolua_S,"getPositionPercent",lua_cocos2dx_ui_Widget_getPositionPercent); tolua_function(tolua_S,"hitTest",lua_cocos2dx_ui_Widget_hitTest); tolua_function(tolua_S,"isFlippedX",lua_cocos2dx_ui_Widget_isFlippedX); tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_ui_Widget_isFlippedY); + tolua_function(tolua_S,"isClippingParentContainsPoint",lua_cocos2dx_ui_Widget_isClippingParentContainsPoint); tolua_function(tolua_S,"setSizeType",lua_cocos2dx_ui_Widget_setSizeType); tolua_function(tolua_S,"setSize",lua_cocos2dx_ui_Widget_setSize); tolua_function(tolua_S,"setBright",lua_cocos2dx_ui_Widget_setBright); tolua_function(tolua_S,"isFocusEnabled",lua_cocos2dx_ui_Widget_isFocusEnabled); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_Widget_constructor); tolua_function(tolua_S,"enableDpadNavigation", lua_cocos2dx_ui_Widget_enableDpadNavigation); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Widget_create); tolua_endmodule(tolua_S); @@ -5132,6 +5079,7 @@ int lua_register_cocos2dx_ui_Layout(lua_State* tolua_S) tolua_cclass(tolua_S,"Layout","ccui.Layout","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"Layout"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_Layout_constructor); tolua_function(tolua_S,"setBackGroundColorVector",lua_cocos2dx_ui_Layout_setBackGroundColorVector); tolua_function(tolua_S,"setClippingType",lua_cocos2dx_ui_Layout_setClippingType); tolua_function(tolua_S,"setBackGroundColorType",lua_cocos2dx_ui_Layout_setBackGroundColorType); @@ -5164,7 +5112,6 @@ int lua_register_cocos2dx_ui_Layout(lua_State* tolua_S) tolua_function(tolua_S,"getBackGroundStartColor",lua_cocos2dx_ui_Layout_getBackGroundStartColor); tolua_function(tolua_S,"setBackGroundImageScale9Enabled",lua_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled); tolua_function(tolua_S,"setLayoutType",lua_cocos2dx_ui_Layout_setLayoutType); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_Layout_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Layout_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Layout_createInstance); tolua_endmodule(tolua_S); @@ -6426,6 +6373,7 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_cclass(tolua_S,"Button","ccui.Button","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"Button"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_Button_constructor); tolua_function(tolua_S,"getTitleText",lua_cocos2dx_ui_Button_getTitleText); tolua_function(tolua_S,"setTitleFontSize",lua_cocos2dx_ui_Button_setTitleFontSize); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_Button_setScale9Enabled); @@ -6448,7 +6396,6 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_function(tolua_S,"getTitleFontName",lua_cocos2dx_ui_Button_getTitleFontName); tolua_function(tolua_S,"getTitleColor",lua_cocos2dx_ui_Button_getTitleColor); tolua_function(tolua_S,"setPressedActionEnabled",lua_cocos2dx_ui_Button_setPressedActionEnabled); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_Button_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Button_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Button_createInstance); tolua_endmodule(tolua_S); @@ -7138,6 +7085,7 @@ int lua_register_cocos2dx_ui_CheckBox(lua_State* tolua_S) tolua_cclass(tolua_S,"CheckBox","ccui.CheckBox","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"CheckBox"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_CheckBox_constructor); tolua_function(tolua_S,"getSelectedState",lua_cocos2dx_ui_CheckBox_getSelectedState); tolua_function(tolua_S,"loadTextureBackGroundSelected",lua_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected); tolua_function(tolua_S,"loadTextureBackGroundDisabled",lua_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled); @@ -7147,7 +7095,6 @@ int lua_register_cocos2dx_ui_CheckBox(lua_State* tolua_S) tolua_function(tolua_S,"loadTextureBackGround",lua_cocos2dx_ui_CheckBox_loadTextureBackGround); tolua_function(tolua_S,"setSelectedState",lua_cocos2dx_ui_CheckBox_setSelectedState); tolua_function(tolua_S,"loadTextureFrontCrossDisabled",lua_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_CheckBox_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_CheckBox_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_CheckBox_createInstance); tolua_endmodule(tolua_S); @@ -7580,13 +7527,13 @@ int lua_register_cocos2dx_ui_ImageView(lua_State* tolua_S) tolua_cclass(tolua_S,"ImageView","ccui.ImageView","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"ImageView"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_ImageView_constructor); tolua_function(tolua_S,"loadTexture",lua_cocos2dx_ui_ImageView_loadTexture); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_ImageView_setScale9Enabled); tolua_function(tolua_S,"setTextureRect",lua_cocos2dx_ui_ImageView_setTextureRect); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_ImageView_setCapInsets); tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_ui_ImageView_getCapInsets); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_ImageView_isScale9Enabled); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_ImageView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_ImageView_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_ImageView_createInstance); tolua_endmodule(tolua_S); @@ -7776,6 +7723,65 @@ int lua_cocos2dx_ui_Text_getFontSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_enableOutline(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_enableOutline'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Color4B arg0; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + if(!ok) + return 0; + cobj->enableOutline(arg0); + return 0; + } + if (argc == 2) + { + cocos2d::Color4B arg0; + int arg1; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + if(!ok) + return 0; + cobj->enableOutline(arg0, arg1); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enableOutline",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_enableOutline'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_getTextVerticalAlignment(lua_State* tolua_S) { int argc = 0; @@ -7864,6 +7870,88 @@ int lua_cocos2dx_ui_Text_getString(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_enableShadow(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_enableShadow'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->enableShadow(); + return 0; + } + if (argc == 1) + { + cocos2d::Color4B arg0; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + if(!ok) + return 0; + cobj->enableShadow(arg0); + return 0; + } + if (argc == 2) + { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + + ok &= luaval_to_size(tolua_S, 3, &arg1); + if(!ok) + return 0; + cobj->enableShadow(arg0, arg1); + return 0; + } + if (argc == 3) + { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + int arg2; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + + ok &= luaval_to_size(tolua_S, 3, &arg1); + + ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2); + if(!ok) + return 0; + cobj->enableShadow(arg0, arg1, arg2); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enableShadow",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_enableShadow'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_setString(lua_State* tolua_S) { int argc = 0; @@ -8000,6 +8088,52 @@ int lua_cocos2dx_ui_Text_setTextVerticalAlignment(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_enableGlow(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_enableGlow'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Color4B arg0; + + ok &=luaval_to_color4b(tolua_S, 2, &arg0); + if(!ok) + return 0; + cobj->enableGlow(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "enableGlow",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_enableGlow'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_getTextAreaSize(lua_State* tolua_S) { int argc = 0; @@ -8224,6 +8358,49 @@ int lua_cocos2dx_ui_Text_getType(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_disableEffect(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_disableEffect'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->disableEffect(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "disableEffect",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_disableEffect'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_getFontName(lua_State* tolua_S) { int argc = 0; @@ -8442,23 +8619,27 @@ int lua_register_cocos2dx_ui_Text(lua_State* tolua_S) tolua_cclass(tolua_S,"Text","ccui.Text","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"Text"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_Text_constructor); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_Text_getStringLength); tolua_function(tolua_S,"setFontName",lua_cocos2dx_ui_Text_setFontName); tolua_function(tolua_S,"setTouchScaleChangeEnabled",lua_cocos2dx_ui_Text_setTouchScaleChangeEnabled); tolua_function(tolua_S,"getFontSize",lua_cocos2dx_ui_Text_getFontSize); + tolua_function(tolua_S,"enableOutline",lua_cocos2dx_ui_Text_enableOutline); tolua_function(tolua_S,"getTextVerticalAlignment",lua_cocos2dx_ui_Text_getTextVerticalAlignment); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_Text_getString); + tolua_function(tolua_S,"enableShadow",lua_cocos2dx_ui_Text_enableShadow); tolua_function(tolua_S,"setString",lua_cocos2dx_ui_Text_setString); tolua_function(tolua_S,"getTextHorizontalAlignment",lua_cocos2dx_ui_Text_getTextHorizontalAlignment); tolua_function(tolua_S,"setTextVerticalAlignment",lua_cocos2dx_ui_Text_setTextVerticalAlignment); + tolua_function(tolua_S,"enableGlow",lua_cocos2dx_ui_Text_enableGlow); tolua_function(tolua_S,"getTextAreaSize",lua_cocos2dx_ui_Text_getTextAreaSize); tolua_function(tolua_S,"setTextHorizontalAlignment",lua_cocos2dx_ui_Text_setTextHorizontalAlignment); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_ui_Text_setFontSize); tolua_function(tolua_S,"isTouchScaleChangeEnabled",lua_cocos2dx_ui_Text_isTouchScaleChangeEnabled); tolua_function(tolua_S,"getType",lua_cocos2dx_ui_Text_getType); + tolua_function(tolua_S,"disableEffect",lua_cocos2dx_ui_Text_disableEffect); tolua_function(tolua_S,"getFontName",lua_cocos2dx_ui_Text_getFontName); tolua_function(tolua_S,"setTextAreaSize",lua_cocos2dx_ui_Text_setTextAreaSize); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_Text_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Text_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Text_createInstance); tolua_endmodule(tolua_S); @@ -8837,12 +9018,12 @@ int lua_register_cocos2dx_ui_TextAtlas(lua_State* tolua_S) tolua_cclass(tolua_S,"TextAtlas","ccui.TextAtlas","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"TextAtlas"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextAtlas_constructor); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_TextAtlas_getStringLength); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_TextAtlas_getString); tolua_function(tolua_S,"setString",lua_cocos2dx_ui_TextAtlas_setString); tolua_function(tolua_S,"setProperty",lua_cocos2dx_ui_TextAtlas_setProperty); tolua_function(tolua_S,"adaptRenderers",lua_cocos2dx_ui_TextAtlas_adaptRenderers); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextAtlas_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_TextAtlas_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_TextAtlas_createInstance); tolua_endmodule(tolua_S); @@ -9409,6 +9590,7 @@ int lua_register_cocos2dx_ui_LoadingBar(lua_State* tolua_S) tolua_cclass(tolua_S,"LoadingBar","ccui.LoadingBar","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"LoadingBar"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_LoadingBar_constructor); tolua_function(tolua_S,"setPercent",lua_cocos2dx_ui_LoadingBar_setPercent); tolua_function(tolua_S,"loadTexture",lua_cocos2dx_ui_LoadingBar_loadTexture); tolua_function(tolua_S,"setDirection",lua_cocos2dx_ui_LoadingBar_setDirection); @@ -9418,7 +9600,6 @@ int lua_register_cocos2dx_ui_LoadingBar(lua_State* tolua_S) tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_ui_LoadingBar_getCapInsets); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_LoadingBar_isScale9Enabled); tolua_function(tolua_S,"getPercent",lua_cocos2dx_ui_LoadingBar_getPercent); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_LoadingBar_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_LoadingBar_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_LoadingBar_createInstance); tolua_endmodule(tolua_S); @@ -11020,6 +11201,7 @@ int lua_register_cocos2dx_ui_ScrollView(lua_State* tolua_S) tolua_cclass(tolua_S,"ScrollView","ccui.ScrollView","ccui.Layout",nullptr); tolua_beginmodule(tolua_S,"ScrollView"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_ScrollView_constructor); tolua_function(tolua_S,"scrollToTop",lua_cocos2dx_ui_ScrollView_scrollToTop); tolua_function(tolua_S,"scrollToPercentHorizontal",lua_cocos2dx_ui_ScrollView_scrollToPercentHorizontal); tolua_function(tolua_S,"isInertiaScrollEnabled",lua_cocos2dx_ui_ScrollView_isInertiaScrollEnabled); @@ -11052,7 +11234,6 @@ int lua_register_cocos2dx_ui_ScrollView(lua_State* tolua_S) tolua_function(tolua_S,"scrollToRight",lua_cocos2dx_ui_ScrollView_scrollToRight); tolua_function(tolua_S,"jumpToRight",lua_cocos2dx_ui_ScrollView_jumpToRight); tolua_function(tolua_S,"scrollToTopRight",lua_cocos2dx_ui_ScrollView_scrollToTopRight); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_ScrollView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_ScrollView_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_ScrollView_createInstance); tolua_endmodule(tolua_S); @@ -11424,6 +11605,49 @@ int lua_cocos2dx_ui_ListView_insertDefaultItem(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_ListView_requestRefreshView(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::ListView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::ListView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_ListView_requestRefreshView'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cobj->requestRefreshView(); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "requestRefreshView",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_ListView_requestRefreshView'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_ListView_setItemsMargin(lua_State* tolua_S) { int argc = 0; @@ -11743,7 +11967,7 @@ int lua_cocos2dx_ui_ListView_setItemModel(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_ListView_requestRefreshView(lua_State* tolua_S) +int lua_cocos2dx_ui_ListView_doLayout(lua_State* tolua_S) { int argc = 0; cocos2d::ui::ListView* cobj = nullptr; @@ -11763,7 +11987,7 @@ int lua_cocos2dx_ui_ListView_requestRefreshView(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_ListView_requestRefreshView'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_ListView_doLayout'", nullptr); return 0; } #endif @@ -11773,15 +11997,15 @@ int lua_cocos2dx_ui_ListView_requestRefreshView(lua_State* tolua_S) { if(!ok) return 0; - cobj->requestRefreshView(); + cobj->doLayout(); return 0; } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "requestRefreshView",argc, 0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "doLayout",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_ListView_requestRefreshView'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_ListView_doLayout'.",&tolua_err); #endif return 0; @@ -11986,6 +12210,7 @@ int lua_register_cocos2dx_ui_ListView(lua_State* tolua_S) tolua_cclass(tolua_S,"ListView","ccui.ListView","ccui.ScrollView",nullptr); tolua_beginmodule(tolua_S,"ListView"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_ListView_constructor); tolua_function(tolua_S,"getIndex",lua_cocos2dx_ui_ListView_getIndex); tolua_function(tolua_S,"removeAllItems",lua_cocos2dx_ui_ListView_removeAllItems); tolua_function(tolua_S,"setGravity",lua_cocos2dx_ui_ListView_setGravity); @@ -11994,6 +12219,7 @@ int lua_register_cocos2dx_ui_ListView(lua_State* tolua_S) tolua_function(tolua_S,"removeItem",lua_cocos2dx_ui_ListView_removeItem); tolua_function(tolua_S,"getCurSelectedIndex",lua_cocos2dx_ui_ListView_getCurSelectedIndex); tolua_function(tolua_S,"insertDefaultItem",lua_cocos2dx_ui_ListView_insertDefaultItem); + tolua_function(tolua_S,"requestRefreshView",lua_cocos2dx_ui_ListView_requestRefreshView); tolua_function(tolua_S,"setItemsMargin",lua_cocos2dx_ui_ListView_setItemsMargin); tolua_function(tolua_S,"refreshView",lua_cocos2dx_ui_ListView_refreshView); tolua_function(tolua_S,"removeLastItem",lua_cocos2dx_ui_ListView_removeLastItem); @@ -12001,10 +12227,9 @@ int lua_register_cocos2dx_ui_ListView(lua_State* tolua_S) tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_ListView_addEventListener); tolua_function(tolua_S,"getItem",lua_cocos2dx_ui_ListView_getItem); tolua_function(tolua_S,"setItemModel",lua_cocos2dx_ui_ListView_setItemModel); - tolua_function(tolua_S,"requestRefreshView",lua_cocos2dx_ui_ListView_requestRefreshView); + tolua_function(tolua_S,"doLayout",lua_cocos2dx_ui_ListView_doLayout); tolua_function(tolua_S,"pushBackDefaultItem",lua_cocos2dx_ui_ListView_pushBackDefaultItem); tolua_function(tolua_S,"insertCustomItem",lua_cocos2dx_ui_ListView_insertCustomItem); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_ListView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_ListView_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_ListView_createInstance); tolua_endmodule(tolua_S); @@ -12944,6 +13169,7 @@ int lua_register_cocos2dx_ui_Slider(lua_State* tolua_S) tolua_cclass(tolua_S,"Slider","ccui.Slider","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"Slider"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_Slider_constructor); tolua_function(tolua_S,"setPercent",lua_cocos2dx_ui_Slider_setPercent); tolua_function(tolua_S,"loadSlidBallTextureDisabled",lua_cocos2dx_ui_Slider_loadSlidBallTextureDisabled); tolua_function(tolua_S,"loadSlidBallTextureNormal",lua_cocos2dx_ui_Slider_loadSlidBallTextureNormal); @@ -12960,7 +13186,6 @@ int lua_register_cocos2dx_ui_Slider(lua_State* tolua_S) tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Slider_isScale9Enabled); tolua_function(tolua_S,"getCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer); tolua_function(tolua_S,"getPercent",lua_cocos2dx_ui_Slider_getPercent); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_Slider_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Slider_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Slider_createInstance); tolua_endmodule(tolua_S); @@ -13688,6 +13913,50 @@ int lua_cocos2dx_ui_TextField_attachWithIME(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_TextField_getStringLength(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::TextField* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::TextField*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_TextField_getStringLength'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + int ret = cobj->getStringLength(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getStringLength",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_TextField_getStringLength'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_TextField_setPasswordEnabled(lua_State* tolua_S) { int argc = 0; @@ -14635,6 +14904,7 @@ int lua_register_cocos2dx_ui_TextField(lua_State* tolua_S) tolua_cclass(tolua_S,"TextField","ccui.TextField","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"TextField"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextField_constructor); tolua_function(tolua_S,"setAttachWithIME",lua_cocos2dx_ui_TextField_setAttachWithIME); tolua_function(tolua_S,"getFontSize",lua_cocos2dx_ui_TextField_getFontSize); tolua_function(tolua_S,"getStringValue",lua_cocos2dx_ui_TextField_getStringValue); @@ -14651,6 +14921,7 @@ int lua_register_cocos2dx_ui_TextField(lua_State* tolua_S) tolua_function(tolua_S,"getFontName",lua_cocos2dx_ui_TextField_getFontName); tolua_function(tolua_S,"setTextAreaSize",lua_cocos2dx_ui_TextField_setTextAreaSize); tolua_function(tolua_S,"attachWithIME",lua_cocos2dx_ui_TextField_attachWithIME); + tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_TextField_getStringLength); tolua_function(tolua_S,"setPasswordEnabled",lua_cocos2dx_ui_TextField_setPasswordEnabled); tolua_function(tolua_S,"getPasswordStyleText",lua_cocos2dx_ui_TextField_getPasswordStyleText); tolua_function(tolua_S,"setMaxLengthEnabled",lua_cocos2dx_ui_TextField_setMaxLengthEnabled); @@ -14669,7 +14940,6 @@ int lua_register_cocos2dx_ui_TextField(lua_State* tolua_S) tolua_function(tolua_S,"setMaxLength",lua_cocos2dx_ui_TextField_setMaxLength); tolua_function(tolua_S,"setTouchSize",lua_cocos2dx_ui_TextField_setTouchSize); tolua_function(tolua_S,"getTouchSize",lua_cocos2dx_ui_TextField_getTouchSize); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextField_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_TextField_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_TextField_createInstance); tolua_endmodule(tolua_S); @@ -14984,11 +15254,11 @@ int lua_register_cocos2dx_ui_TextBMFont(lua_State* tolua_S) tolua_cclass(tolua_S,"TextBMFont","ccui.TextBMFont","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"TextBMFont"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextBMFont_constructor); tolua_function(tolua_S,"setFntFile",lua_cocos2dx_ui_TextBMFont_setFntFile); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_TextBMFont_getStringLength); tolua_function(tolua_S,"setString",lua_cocos2dx_ui_TextBMFont_setString); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_TextBMFont_getString); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_TextBMFont_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_TextBMFont_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_TextBMFont_createInstance); tolua_endmodule(tolua_S); @@ -15619,6 +15889,7 @@ int lua_register_cocos2dx_ui_PageView(lua_State* tolua_S) tolua_cclass(tolua_S,"PageView","ccui.PageView","ccui.Layout",nullptr); tolua_beginmodule(tolua_S,"PageView"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_PageView_constructor); tolua_function(tolua_S,"getCurPageIndex",lua_cocos2dx_ui_PageView_getCurPageIndex); tolua_function(tolua_S,"addWidgetToPage",lua_cocos2dx_ui_PageView_addWidgetToPage); tolua_function(tolua_S,"getPage",lua_cocos2dx_ui_PageView_getPage); @@ -15630,7 +15901,6 @@ int lua_register_cocos2dx_ui_PageView(lua_State* tolua_S) tolua_function(tolua_S,"getPages",lua_cocos2dx_ui_PageView_getPages); tolua_function(tolua_S,"removeAllPages",lua_cocos2dx_ui_PageView_removeAllPages); tolua_function(tolua_S,"addPage",lua_cocos2dx_ui_PageView_addPage); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_PageView_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_PageView_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_PageView_createInstance); tolua_endmodule(tolua_S); @@ -15866,8 +16136,8 @@ int lua_register_cocos2dx_ui_RichElement(lua_State* tolua_S) tolua_cclass(tolua_S,"RichElement","ccui.RichElement","cc.Ref",nullptr); tolua_beginmodule(tolua_S,"RichElement"); - tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElement_init); tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichElement_constructor); + tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElement_init); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RichElement).name(); g_luaType[typeName] = "ccui.RichElement"; @@ -16026,8 +16296,8 @@ int lua_register_cocos2dx_ui_RichElementText(lua_State* tolua_S) tolua_cclass(tolua_S,"RichElementText","ccui.RichElementText","ccui.RichElement",nullptr); tolua_beginmodule(tolua_S,"RichElementText"); - tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementText_init); tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichElementText_constructor); + tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementText_init); tolua_function(tolua_S,"create", lua_cocos2dx_ui_RichElementText_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RichElementText).name(); @@ -16177,8 +16447,8 @@ int lua_register_cocos2dx_ui_RichElementImage(lua_State* tolua_S) tolua_cclass(tolua_S,"RichElementImage","ccui.RichElementImage","ccui.RichElement",nullptr); tolua_beginmodule(tolua_S,"RichElementImage"); - tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementImage_init); tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichElementImage_constructor); + tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementImage_init); tolua_function(tolua_S,"create", lua_cocos2dx_ui_RichElementImage_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RichElementImage).name(); @@ -16328,8 +16598,8 @@ int lua_register_cocos2dx_ui_RichElementCustomNode(lua_State* tolua_S) tolua_cclass(tolua_S,"RichElementCustomNode","ccui.RichElementCustomNode","ccui.RichElement",nullptr); tolua_beginmodule(tolua_S,"RichElementCustomNode"); - tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementCustomNode_init); tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichElementCustomNode_constructor); + tolua_function(tolua_S,"init",lua_cocos2dx_ui_RichElementCustomNode_init); tolua_function(tolua_S,"create", lua_cocos2dx_ui_RichElementCustomNode_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RichElementCustomNode).name(); @@ -16744,6 +17014,7 @@ int lua_register_cocos2dx_ui_RichText(lua_State* tolua_S) tolua_cclass(tolua_S,"RichText","ccui.RichText","ccui.Widget",nullptr); tolua_beginmodule(tolua_S,"RichText"); + tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichText_constructor); tolua_function(tolua_S,"insertElement",lua_cocos2dx_ui_RichText_insertElement); tolua_function(tolua_S,"setAnchorPoint",lua_cocos2dx_ui_RichText_setAnchorPoint); tolua_function(tolua_S,"pushBackElement",lua_cocos2dx_ui_RichText_pushBackElement); @@ -16751,7 +17022,6 @@ int lua_register_cocos2dx_ui_RichText(lua_State* tolua_S) tolua_function(tolua_S,"setVerticalSpace",lua_cocos2dx_ui_RichText_setVerticalSpace); tolua_function(tolua_S,"formatText",lua_cocos2dx_ui_RichText_formatText); tolua_function(tolua_S,"removeElement",lua_cocos2dx_ui_RichText_removeElement); - tolua_function(tolua_S,"new",lua_cocos2dx_ui_RichText_constructor); tolua_function(tolua_S,"create", lua_cocos2dx_ui_RichText_create); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::ui::RichText).name(); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 075036bb49..82db355930 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -381,6 +381,11 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp index 75a5ecf941..a5ee2a4b51 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -25,6 +25,7 @@ #include "CCLuaStack.h" #include "tolua_fix.h" +#include "external/xxtea/xxtea.h" extern "C" { #include "lua.h" #include "tolua++.h" @@ -685,4 +686,88 @@ int LuaStack::reload(const char* moduleFileName) return executeString(require.c_str()); } +void LuaStack::setXXTEAKeyAndSign(const char *key, int keyLen, const char *sign, int signLen) +{ + cleanupXXTEAKeyAndSign(); + + if (key && keyLen && sign && signLen) + { + _xxteaKey = (char*)malloc(keyLen); + memcpy(_xxteaKey, key, keyLen); + _xxteaKeyLen = keyLen; + + _xxteaSign = (char*)malloc(signLen); + memcpy(_xxteaSign, sign, signLen); + _xxteaSignLen = signLen; + + _xxteaEnabled = true; + } + else + { + _xxteaEnabled = false; + } +} + +void LuaStack::cleanupXXTEAKeyAndSign() +{ + if (_xxteaKey) + { + free(_xxteaKey); + _xxteaKey = nullptr; + _xxteaKeyLen = 0; + } + if (_xxteaSign) + { + free(_xxteaSign); + _xxteaSign = nullptr; + _xxteaSignLen = 0; + } +} + +int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName) +{ + int r = 0; + + if (_xxteaEnabled && strncmp(chunk, _xxteaSign, _xxteaSignLen) == 0) + { + // decrypt XXTEA + xxtea_long len = 0; + unsigned char* result = xxtea_decrypt((unsigned char*)chunk + _xxteaSignLen, + (xxtea_long)chunkSize - _xxteaSignLen, + (unsigned char*)_xxteaKey, + (xxtea_long)_xxteaKeyLen, + &len); + r = luaL_loadbuffer(L, (char*)result, len, chunkName); + free(result); + } + else + { + r = luaL_loadbuffer(L, chunk, chunkSize, chunkName); + } + +#if defined(COCOS2D_DEBUG) && COCOS2D_DEBUG > 0 + if (r) + { + switch (r) + { + case LUA_ERRSYNTAX: + CCLOG("[LUA ERROR] load \"%s\", error: syntax error during pre-compilation.", chunkName); + break; + + case LUA_ERRMEM: + CCLOG("[LUA ERROR] load \"%s\", error: memory allocation error.", chunkName); + break; + + case LUA_ERRFILE: + CCLOG("[LUA ERROR] load \"%s\", error: cannot open/read file.", chunkName); + break; + + default: + CCLOG("[LUA ERROR] load \"%s\", error: unknown.", chunkName); + } + } +#endif + return r; +} + NS_CC_END diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.h b/cocos/scripting/lua-bindings/manual/CCLuaStack.h index 566dbe8e30..9d6345282e 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.h +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.h @@ -129,10 +129,20 @@ public: virtual bool handleAssert(const char *msg); + virtual void setXXTEAKeyAndSign(const char *key, int keyLen, const char *sign, int signLen); + virtual void cleanupXXTEAKeyAndSign(); + + int luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, const char *chunkName); + protected: LuaStack(void) : _state(nullptr) , _callFromLua(0) + , _xxteaEnabled(false) + , _xxteaKey(nullptr) + , _xxteaKeyLen(0) + , _xxteaSign(nullptr) + , _xxteaSignLen(0) { } @@ -141,6 +151,11 @@ protected: lua_State *_state; int _callFromLua; + bool _xxteaEnabled; + char* _xxteaKey; + int _xxteaKeyLen; + char* _xxteaSign; + int _xxteaSignLen; }; NS_CC_END diff --git a/cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp b/cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp index 6409c99f61..e11d541626 100644 --- a/cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp +++ b/cocos/scripting/lua-bindings/manual/Cocos2dxLuaLoader.cpp @@ -26,14 +26,20 @@ THE SOFTWARE. #include #include +#include "CCLuaStack.h" +#include "CCLuaEngine.h" + using namespace cocos2d; extern "C" { int cocos2dx_lua_loader(lua_State *L) { + static const std::string BYTECODE_FILE_EXT = ".luac"; + static const std::string NOT_BYTECODE_FILE_EXT = ".lua"; + std::string filename(luaL_checkstring(L, 1)); - size_t pos = filename.rfind(".lua"); + size_t pos = filename.rfind(NOT_BYTECODE_FILE_EXT); if (pos != std::string::npos) { filename = filename.substr(0, pos); @@ -45,21 +51,63 @@ extern "C" filename.replace(pos, 1, "/"); pos = filename.find_first_of("."); } - filename.append(".lua"); - Data data = FileUtils::getInstance()->getDataFromFile(filename); + // search file in package.path + unsigned char* chunk = nullptr; + ssize_t chunkSize = 0; + std::string chunkName; + FileUtils* utils = FileUtils::getInstance(); - if (!data.isNull()) + lua_getglobal(L, "package"); + lua_getfield(L, -1, "path"); + std::string searchpath(lua_tostring(L, -1)); + lua_pop(L, 1); + size_t begin = 0; + size_t next = searchpath.find_first_of(";", 0); + + do { - if (luaL_loadbuffer(L, (char*)data.getBytes(), data.getSize(), filename.c_str()) != 0) + if (next == std::string::npos) + next = searchpath.length(); + std::string prefix = searchpath.substr(begin, next); + if (prefix[0] == '.' && prefix[1] == '/') { - luaL_error(L, "error loading module %s from file %s :\n\t%s", - lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1)); + prefix = prefix.substr(2); } + + pos = prefix.find("?.lua"); + chunkName = prefix.substr(0, pos) + filename + BYTECODE_FILE_EXT; + chunkName = utils->fullPathForFilename(chunkName.c_str()); + if (utils->isFileExist(chunkName)) + { + chunk = utils->getFileData(chunkName.c_str(), "rb", &chunkSize); + break; + } + else + { + chunkName = prefix.substr(0, pos) + filename + NOT_BYTECODE_FILE_EXT; + chunkName = utils->fullPathForFilename(chunkName.c_str()); + if (utils->isFileExist(chunkName)) + { + chunk = utils->getFileData(chunkName.c_str(), "rb", &chunkSize); + break; + } + } + + begin = next + 1; + next = searchpath.find_first_of(";", begin); + } while (begin < (int)searchpath.length()); + + if (chunk) + { + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + stack->luaLoadBuffer(L, (char*)chunk, (int)chunkSize, chunkName.c_str()); + delete []chunk; } else { - log("can not get file data of %s", filename.c_str()); + CCLOG("can not get file data of %s", chunkName.c_str()); + return 0; } return 1; diff --git a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp index d07416b867..2b5aba203b 100644 --- a/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaOpengl.cpp @@ -38,14 +38,14 @@ using namespace cocos2d::extension; -void GLNode::draw(Renderer *renderer, const cocos2d::Mat4& transform, bool transformUpdated) +void GLNode::draw(Renderer *renderer, const cocos2d::Mat4& transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(GLNode::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(GLNode::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void GLNode::onDraw(const cocos2d::Mat4 &transform, bool transformUpdated) +void GLNode::onDraw(const cocos2d::Mat4 &transform, uint32_t flags) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::GL_NODE_DRAW); if (0 != handler) @@ -60,7 +60,7 @@ void GLNode::onDraw(const cocos2d::Mat4 &transform, bool transformUpdated) stack->pushFloat(transform.m[i]); lua_rawseti(L, -2, i + 1); } - stack->pushBoolean(transformUpdated); + stack->pushInt(flags); stack->executeFunctionByHandler(handler, 2); stack->clean(); } diff --git a/cocos/scripting/lua-bindings/manual/LuaOpengl.h b/cocos/scripting/lua-bindings/manual/LuaOpengl.h index 606b99ae16..874f814415 100644 --- a/cocos/scripting/lua-bindings/manual/LuaOpengl.h +++ b/cocos/scripting/lua-bindings/manual/LuaOpengl.h @@ -39,10 +39,10 @@ class GLNode:public cocos2d::Node { public: virtual ~GLNode(){} - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4& transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4& transform, uint32_t flags) override; protected: cocos2d::CustomCommand _renderCmd; - void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated); + void onDraw(const cocos2d::Mat4 &transform, uint32_t flags); }; TOLUA_API int tolua_opengl_open(lua_State* tolua_S); diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp index 2db3afbaee..a574142811 100644 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_manual.cpp @@ -5384,7 +5384,14 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S { lua_pushnumber(tolua_S,i + 1); lua_gettable(tolua_S,7); - if (tolua_isnumber(tolua_S, -1, 0, &tolua_err)) + bool isnum = true; +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S, -1, 0, &tolua_err)) + { + isnum = false; + } +#endif + if (isnum) { arg5[i] = tolua_tonumber(tolua_S, -1, 0); } diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 3f682c84da..276e8f8f4a 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -15,6 +15,10 @@ 1503FAA618DA8A1C00F6518C /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 1503FA9F18DA8A1C00F6518C /* io.c */; }; 1503FAA718DA8A1C00F6518C /* io.h in Headers */ = {isa = PBXBuildFile; fileRef = 1503FAA018DA8A1C00F6518C /* io.h */; }; 1503FAA818DA8A1C00F6518C /* io.h in Headers */ = {isa = PBXBuildFile; fileRef = 1503FAA018DA8A1C00F6518C /* io.h */; }; + 1540AF57193EC30500717D8E /* xxtea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1540AF55193EC30500717D8E /* xxtea.cpp */; }; + 1540AF58193EC30500717D8E /* xxtea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1540AF55193EC30500717D8E /* xxtea.cpp */; }; + 1540AF59193EC30500717D8E /* xxtea.h in Headers */ = {isa = PBXBuildFile; fileRef = 1540AF56193EC30500717D8E /* xxtea.h */; }; + 1540AF5A193EC30500717D8E /* xxtea.h in Headers */ = {isa = PBXBuildFile; fileRef = 1540AF56193EC30500717D8E /* xxtea.h */; }; 1A262AB818BEEF5900D2DB92 /* tolua_fix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A262AB718BEEF5900D2DB92 /* tolua_fix.cpp */; }; 1A262AB918BEEF5900D2DB92 /* tolua_fix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A262AB718BEEF5900D2DB92 /* tolua_fix.cpp */; }; 1AACE7B518BC45C200215002 /* lua_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AACE74918BC45C200215002 /* lua_cocos2dx_auto.cpp */; }; @@ -214,6 +218,8 @@ 1503FA9E18DA8A1C00F6518C /* buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = buffer.h; sourceTree = ""; }; 1503FA9F18DA8A1C00F6518C /* io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = io.c; sourceTree = ""; }; 1503FAA018DA8A1C00F6518C /* io.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = io.h; sourceTree = ""; }; + 1540AF55193EC30500717D8E /* xxtea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xxtea.cpp; sourceTree = ""; }; + 1540AF56193EC30500717D8E /* xxtea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxtea.h; sourceTree = ""; }; 1A262AB718BEEF5900D2DB92 /* tolua_fix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tolua_fix.cpp; sourceTree = ""; }; 1AACE74618BC45A000215002 /* libluabindings Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 1AACE74718BC45A000215002 /* libluabindings iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluabindings iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -335,6 +341,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1540AF54193EC30500717D8E /* xxtea */ = { + isa = PBXGroup; + children = ( + 1540AF55193EC30500717D8E /* xxtea.cpp */, + 1540AF56193EC30500717D8E /* xxtea.h */, + ); + name = xxtea; + path = ../../../../external/xxtea; + sourceTree = ""; + }; 1551A334158F2AB200E66CFE = { isa = PBXGroup; children = ( @@ -439,6 +455,7 @@ 1ABCA1E218CD8F230087CE3A /* external */ = { isa = PBXGroup; children = ( + 1540AF54193EC30500717D8E /* xxtea */, 1ABCA1E318CD8F2D0087CE3A /* luajit */, 1ABCA20E18CD8F7D0087CE3A /* luasocket */, 1ABCA1E418CD8F330087CE3A /* tolua */, @@ -548,6 +565,7 @@ 1503FAA818DA8A1C00F6518C /* io.h in Headers */, 1ABCA26C18CD8F7D0087CE3A /* unix.h in Headers */, 1AACE7E018BC45C200215002 /* CCLuaBridge.h in Headers */, + 1540AF5A193EC30500717D8E /* xxtea.h in Headers */, C0FEF4D918BE0E70001F446C /* lua_debugger.h in Headers */, 1AACE7B818BC45C200215002 /* lua_cocos2dx_auto.hpp in Headers */, 1AACE7E418BC45C200215002 /* CCLuaEngine.h in Headers */, @@ -605,6 +623,7 @@ 1503FAA718DA8A1C00F6518C /* io.h in Headers */, 1ABCA26B18CD8F7D0087CE3A /* unix.h in Headers */, 1AACE7DF18BC45C200215002 /* CCLuaBridge.h in Headers */, + 1540AF59193EC30500717D8E /* xxtea.h in Headers */, C0FEF4D818BE0E70001F446C /* lua_debugger.h in Headers */, 1AACE7B718BC45C200215002 /* lua_cocos2dx_auto.hpp in Headers */, 1AACE7E318BC45C200215002 /* CCLuaEngine.h in Headers */, @@ -736,6 +755,7 @@ 1ABCA23E18CD8F7D0087CE3A /* luasocket.c in Sources */, 1ABCA25218CD8F7D0087CE3A /* select.c in Sources */, 1ABCA24A18CD8F7D0087CE3A /* mime.c in Sources */, + 1540AF58193EC30500717D8E /* xxtea.cpp in Sources */, 1ABCA26218CD8F7D0087CE3A /* timeout.c in Sources */, 1503FAA618DA8A1C00F6518C /* io.c in Sources */, 1ABCA26618CD8F7D0087CE3A /* udp.c in Sources */, @@ -792,6 +812,7 @@ 1ABCA23D18CD8F7D0087CE3A /* luasocket.c in Sources */, 1ABCA25118CD8F7D0087CE3A /* select.c in Sources */, 1ABCA24918CD8F7D0087CE3A /* mime.c in Sources */, + 1540AF57193EC30500717D8E /* xxtea.cpp in Sources */, 1ABCA26118CD8F7D0087CE3A /* timeout.c in Sources */, 1503FAA518DA8A1C00F6518C /* io.c in Sources */, 1ABCA26518CD8F7D0087CE3A /* udp.c in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj b/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj index 194e986d50..f646029bfe 100644 --- a/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj @@ -29,6 +29,7 @@ + @@ -79,6 +80,7 @@ + @@ -140,8 +142,8 @@ v100 v110 v110_xp - v120 - v120_xp + v120 + v120_xp StaticLibrary @@ -149,8 +151,8 @@ v100 v110 v110_xp - v120 - v120_xp + v120 + v120_xp diff --git a/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj.filters index 26eec8ffcb..af8cd09e62 100644 --- a/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/liblua.vcxproj.filters @@ -19,6 +19,9 @@ {cc863463-a948-487a-aacd-dc233c3e5200} + + {1fa7ff75-c142-4928-8aef-e6a2eb2b465f} + @@ -159,6 +162,9 @@ tolua + + xxtea + @@ -305,6 +311,9 @@ luajit + + xxtea + diff --git a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua index e07724a7ba..059cccc32c 100644 --- a/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/Cocos2dConstants.lua @@ -383,165 +383,183 @@ cc.LabelEffect = GLOW = 3, } +cc.KeyCodeKey = +{ + "KEY_NONE", + "KEY_PAUSE", + "KEY_SCROLL_LOCK", + "KEY_PRINT", + "KEY_SYSREQ", + "KEY_BREAK", + "KEY_ESCAPE", + "KEY_BACKSPACE", + "KEY_TAB", + "KEY_BACK_TAB", + "KEY_RETURN", + "KEY_CAPS_LOCK", + "KEY_SHIFT", + "KEY_CTRL", + "KEY_ALT", + "KEY_MENU", + "KEY_HYPER", + "KEY_INSERT", + "KEY_HOME", + "KEY_PG_UP", + "KEY_DELETE", + "KEY_END", + "KEY_PG_DOWN", + "KEY_LEFT_ARROW", + "KEY_RIGHT_ARROW", + "KEY_UP_ARROW", + "KEY_DOWN_ARROW", + "KEY_NUM_LOCK", + "KEY_KP_PLUS", + "KEY_KP_MINUS", + "KEY_KP_MULTIPLY", + "KEY_KP_DIVIDE", + "KEY_KP_ENTER", + "KEY_KP_HOME", + "KEY_KP_UP", + "KEY_KP_PG_UP", + "KEY_KP_LEFT", + "KEY_KP_FIVE", + "KEY_KP_RIGHT", + "KEY_KP_END", + "KEY_KP_DOWN", + "KEY_KP_PG_DOWN", + "KEY_KP_INSERT", + "KEY_KP_DELETE", + "KEY_F1", + "KEY_F2", + "KEY_F3", + "KEY_F4", + "KEY_F5", + "KEY_F6", + "KEY_F7", + "KEY_F8", + "KEY_F9", + "KEY_F10", + "KEY_F11", + "KEY_F12", + "KEY_SPACE", + "KEY_EXCLAM", + "KEY_QUOTE", + "KEY_NUMBER", + "KEY_DOLLAR", + "KEY_PERCENT", + "KEY_CIRCUMFLEX", + "KEY_AMPERSAND", + "KEY_APOSTROPHE", + "KEY_LEFT_PARENTHESIS", + "KEY_RIGHT_PARENTHESIS", + "KEY_ASTERISK", + "KEY_PLUS", + "KEY_COMMA", + "KEY_MINUS", + "KEY_PERIOD", + "KEY_SLASH", + "KEY_0", + "KEY_1", + "KEY_2", + "KEY_3", + "KEY_4", + "KEY_5", + "KEY_6", + "KEY_7", + "KEY_8", + "KEY_9", + "KEY_COLON", + "KEY_SEMICOLON", + "KEY_LESS_THAN", + "KEY_EQUAL", + "KEY_GREATER_THAN", + "KEY_QUESTION", + "KEY_AT", + "KEY_CAPITAL_A", + "KEY_CAPITAL_B", + "KEY_CAPITAL_C", + "KEY_CAPITAL_D", + "KEY_CAPITAL_E", + "KEY_CAPITAL_F", + "KEY_CAPITAL_G", + "KEY_CAPITAL_H", + "KEY_CAPITAL_I", + "KEY_CAPITAL_J", + "KEY_CAPITAL_K", + "KEY_CAPITAL_L", + "KEY_CAPITAL_M", + "KEY_CAPITAL_N", + "KEY_CAPITAL_O", + "KEY_CAPITAL_P", + "KEY_CAPITAL_Q", + "KEY_CAPITAL_R", + "KEY_CAPITAL_S", + "KEY_CAPITAL_T", + "KEY_CAPITAL_U", + "KEY_CAPITAL_V", + "KEY_CAPITAL_W", + "KEY_CAPITAL_X", + "KEY_CAPITAL_Y", + "KEY_CAPITAL_Z", + "KEY_LEFT_BRACKET", + "KEY_BACK_SLASH", + "KEY_RIGHT_BRACKET", + "KEY_UNDERSCORE", + "KEY_GRAVE", + "KEY_A", + "KEY_B", + "KEY_C", + "KEY_D", + "KEY_E", + "KEY_F", + "KEY_G", + "KEY_H", + "KEY_I", + "KEY_J", + "KEY_K", + "KEY_L", + "KEY_M", + "KEY_N", + "KEY_O", + "KEY_P", + "KEY_Q", + "KEY_R", + "KEY_S", + "KEY_T", + "KEY_U", + "KEY_V", + "KEY_W", + "KEY_X", + "KEY_Y", + "KEY_Z", + "KEY_LEFT_BRACE", + "KEY_BAR", + "KEY_RIGHT_BRACE", + "KEY_TILDE", + "KEY_EURO", + "KEY_POUND", + "KEY_YEN", + "KEY_MIDDLE_DOT", + "KEY_SEARCH", + "KEY_DPAD_LEFT", + "KEY_DPAD_RIGHT", + "KEY_DPAD_UP", + "KEY_DPAD_DOWN", + "KEY_DPAD_CENTER", + "KEY_ENTER", + "KEY_PLAY", +} + cc.KeyCode = { - KEY_NONE = 0, - KEY_PAUSE = 0x0013, - KEY_SCROLL_LOCK = 0x1014, - KEY_PRINT = 0x1061, - KEY_SYSREQ = 0x106A, - KEY_BREAK = 0x106B, - KEY_ESCAPE = 0x001B, - KEY_BACKSPACE = 0x0008, - KEY_TAB = 0x0009, - KEY_BACK_TAB = 0x0089, - KEY_RETURN = 0x000D, - KEY_CAPS_LOCK = 0x00E5, - KEY_SHIFT = 0x00E1, - KEY_CTRL = 0x00E3, - KEY_ALT = 0x00E9, - KEY_MENU = 0x1067, - KEY_HYPER = 0x10ED, - KEY_INSERT = 0x1063, - KEY_HOME = 0x1050, - KEY_PG_UP = 0x1055, - KEY_DELETE = 0x10FF, - KEY_END = 0x1057, - KEY_PG_DOWN = 0x1056, - KEY_LEFT_ARROW = 0x1051, - KEY_RIGHT_ARROW = 0x1053, - KEY_UP_ARROW = 0x1052, - KEY_DOWN_ARROW = 0x1054, - KEY_NUM_LOCK = 0x107F, - KEY_KP_PLUS = 0x10AB, - KEY_KP_MINUS = 0x10AD, - KEY_KP_MULTIPLY = 0x10AA, - KEY_KP_DIVIDE = 0x10AF, - KEY_KP_ENTER = 0x108D, - KEY_KP_HOME = 0x10B7, - KEY_KP_UP = 0x10B8, - KEY_KP_PG_UP = 0x10B9, - KEY_KP_LEFT = 0x10B4, - KEY_KP_FIVE = 0x10B5, - KEY_KP_RIGHT = 0x10B6, - KEY_KP_END = 0x10B1, - KEY_KP_DOWN = 0x10B2, - KEY_KP_PG_DOWN = 0x10B3, - KEY_KP_INSERT = 0x10B0, - KEY_KP_DELETE = 0x10AE, - KEY_F1 = 0x00BE, - KEY_F2 = 0x00BF, - KEY_F3 = 0x00C0, - KEY_F4 = 0x00C1, - KEY_F5 = 0x00C2, - KEY_F6 = 0x00C3, - KEY_F7 = 0x00C4, - KEY_F8 = 0x00C5, - KEY_F9 = 0x00C6, - KEY_F10 = 0x00C7, - KEY_F11 = 0x00C8, - KEY_F12 = 0x00C9, - KEY_SPACE = ' ', - KEY_EXCLAM = '!', - KEY_QUOTE = '"', - KEY_NUMBER = '#', - KEY_DOLLAR = '$', - KEY_PERCENT = '%', - KEY_CIRCUMFLEX = '^', - KEY_AMPERSAND = '&', - KEY_APOSTROPHE = '\'', - KEY_LEFT_PARENTHESIS = '(', - KEY_RIGHT_PARENTHESIS = ')', - KEY_ASTERISK = '*', - KEY_PLUS = '+', - KEY_COMMA = ',', - KEY_MINUS = '-', - KEY_PERIOD = '.', - KEY_SLASH = '/', - KEY_0 = '0', - KEY_1 = '1', - KEY_2 = '2', - KEY_3 = '3', - KEY_4 = '4', - KEY_5 = '5', - KEY_6 = '6', - KEY_7 = '7', - KEY_8 = '8', - KEY_9 = '9', - KEY_COLON = ':', - KEY_SEMICOLON = ';', - KEY_LESS_THAN = '<', - KEY_EQUAL = '=', - KEY_GREATER_THAN = '>', - KEY_QUESTION = '?', - KEY_AT = '@', - KEY_CAPITAL_A = 'A', - KEY_CAPITAL_B = 'B', - KEY_CAPITAL_C = 'C', - KEY_CAPITAL_D = 'D', - KEY_CAPITAL_E = 'E', - KEY_CAPITAL_F = 'F', - KEY_CAPITAL_G = 'G', - KEY_CAPITAL_H = 'H', - KEY_CAPITAL_I = 'I', - KEY_CAPITAL_J = 'J', - KEY_CAPITAL_K = 'K', - KEY_CAPITAL_L = 'L', - KEY_CAPITAL_M = 'M', - KEY_CAPITAL_N = 'N', - KEY_CAPITAL_O = 'O', - KEY_CAPITAL_P = 'P', - KEY_CAPITAL_Q = 'Q', - KEY_CAPITAL_R = 'R', - KEY_CAPITAL_S = 'S', - KEY_CAPITAL_T = 'T', - KEY_CAPITAL_U = 'U', - KEY_CAPITAL_V = 'V', - KEY_CAPITAL_W = 'W', - KEY_CAPITAL_X = 'X', - KEY_CAPITAL_Y = 'Y', - KEY_CAPITAL_Z = 'Z', - KEY_LEFT_BRACKET = '[', - KEY_BACK_SLASH = '\\', - KEY_RIGHT_BRACKET = ']', - KEY_UNDERSCORE = '_', - KEY_GRAVE = '`', - KEY_A = 'a', - KEY_B = 'b', - KEY_C = 'c', - KEY_D = 'd', - KEY_E = 'e', - KEY_F = 'f', - KEY_G = 'g', - KEY_H = 'h', - KEY_I = 'i', - KEY_J = 'j', - KEY_K = 'k', - KEY_L = 'l', - KEY_M = 'm', - KEY_N = 'n', - KEY_O = 'o', - KEY_P = 'p', - KEY_Q = 'q', - KEY_R = 'r', - KEY_S = 's', - KEY_T = 't', - KEY_U = 'u', - KEY_V = 'v', - KEY_W = 'w', - KEY_X = 'x', - KEY_Y = 'y', - KEY_Z = 'z', - KEY_LEFT_BRACE = '{', - KEY_BAR = '|', - KEY_RIGHT_BRACE = '}', - KEY_TILDE = '~', - KEY_EURO = 0x20AC, - KEY_POUND = 0x00A3, - KEY_YEN = 0x00A5, - KEY_MIDDLE_DOT = 0x0095, - KEY_SEARCH = 0xFFAA, -}; + +} + +for k,v in ipairs(cc.KeyCodeKey) do + cc.KeyCode[v] = k - 1 +end + +cc.KeyCode.KEY_BACK = cc.KeyCode.KEY_ESCAPE diff --git a/cocos/scripting/lua-bindings/script/Deprecated.lua b/cocos/scripting/lua-bindings/script/Deprecated.lua index 842b593a0d..ca036a84c4 100644 --- a/cocos/scripting/lua-bindings/script/Deprecated.lua +++ b/cocos/scripting/lua-bindings/script/Deprecated.lua @@ -1204,4 +1204,32 @@ end rawset(cc.ShaderCache,"getProgram", ShaderCacheDeprecated.getProgram) --functions of ccui.TextBMFont will be deprecated begin +--functions of ccui.Widget will be deprecated begin +local UIWidgetDeprecated = { } +function UIWidgetDeprecated.getLeftInParent(self) + deprecatedTip("ccui.Widget:getLeftInParent","ccui.Widget:getLeftBoundary") + return self:getLeftBoundary() +end +rawset(ccui.Widget,"getLeftInParent", UIWidgetDeprecated.getLeftInParent) + +function UIWidgetDeprecated.getBottomInParent(self) + deprecatedTip("ccui.Widget:getBottomInParent","ccui.Widget:getBottomBoundary") + return self:getBottomBoundary() +end +rawset(ccui.Widget,"getBottomInParent", UIWidgetDeprecated.getBottomInParent) + +function UIWidgetDeprecated.getRightInParent(self) + deprecatedTip("ccui.Widget:getRightInParent","ccui.Widget:getRightBoundary") + return self:getRightBoundary() +end +rawset(ccui.Widget,"getRightInParent", UIWidgetDeprecated.getRightInParent) + +function UIWidgetDeprecated.getTopInParent(self) + deprecatedTip("ccui.Widget:getTopInParent","ccui.Widget:getTopBoundary") + return self:getTopBoundary() +end +rawset(ccui.Widget,"getTopInParent", UIWidgetDeprecated.getTopInParent) + +--functions of ccui.Widget will be deprecated begin + diff --git a/cocos/scripting/lua-bindings/script/DeprecatedEnum.lua b/cocos/scripting/lua-bindings/script/DeprecatedEnum.lua index f10e52a4cd..738f2a2014 100644 --- a/cocos/scripting/lua-bindings/script/DeprecatedEnum.lua +++ b/cocos/scripting/lua-bindings/script/DeprecatedEnum.lua @@ -402,10 +402,10 @@ _G.LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none _G.LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid _G.LAYOUT_COLOR_GRADIENT = ccui.LayoutBackGroundColorType.gradient -_G.LAYOUT_ABSOLUTE = ccui.Type.ABSOLUTE -_G.LAYOUT_LINEAR_VERTICAL = ccui.Type.VERTICAL -_G.LAYOUT_LINEAR_HORIZONTAL = ccui.Type.HORIZONTAL -_G.LAYOUT_RELATIVE = ccui.Type.RELATIVE +_G.LAYOUT_ABSOLUTE = ccui.LayoutType.ABSOLUTE +_G.LAYOUT_LINEAR_VERTICAL = ccui.LayoutType.VERTICAL +_G.LAYOUT_LINEAR_HORIZONTAL = ccui.LayoutType.HORIZONTAL +_G.LAYOUT_RELATIVE = ccui.LayoutType.RELATIVE _G.BRIGHT_NONE = ccui.BrightStyle.none _G.BRIGHT_NORMAL = ccui.BrightStyle.normal diff --git a/cocos/ui/CCProtectedNode.cpp b/cocos/ui/CCProtectedNode.cpp index 6162e57846..e49aa6bbde 100644 --- a/cocos/ui/CCProtectedNode.cpp +++ b/cocos/ui/CCProtectedNode.cpp @@ -268,7 +268,7 @@ void ProtectedNode::reorderProtectedChild(cocos2d::Node *child, int localZOrder) child->_setLocalZOrder(localZOrder); } -void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. if (!_visible) @@ -276,11 +276,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool return; } - bool dirty = _transformUpdated || parentTransformUpdated; - if(dirty) - _modelViewTransform = this->transform(parentTransform); - _transformUpdated = false; - + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, @@ -304,7 +300,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } @@ -314,7 +310,7 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool auto node = _protectedChildren.at(j); if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } @@ -322,16 +318,16 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, bool // // draw self // - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); // // draw children and protectedChildren zOrder >= 0 // for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); // reset for next frame _orderOfArrival = 0; diff --git a/cocos/ui/CCProtectedNode.h b/cocos/ui/CCProtectedNode.h index d49c690699..0c6eb2f949 100644 --- a/cocos/ui/CCProtectedNode.h +++ b/cocos/ui/CCProtectedNode.h @@ -127,7 +127,7 @@ public: /// @} end of Children and Parent - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool transformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; virtual void cleanup() override; diff --git a/cocos/ui/GUIDefine.h b/cocos/ui/GUIDefine.h index 99207e3248..f12bde90de 100644 --- a/cocos/ui/GUIDefine.h +++ b/cocos/ui/GUIDefine.h @@ -26,7 +26,7 @@ #define __TestCpp__GUIDefine__ #include -#include "cocostudio/ObjectFactory.h" +#include "base/ObjectFactory.h" // //// Widget macro @@ -34,7 +34,7 @@ #define DECLARE_CLASS_GUI_INFO \ public: \ - static cocostudio::ObjectFactory::TInfo __Type; \ + static cocos2d::ObjectFactory::TInfo __Type; \ static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_GUI_INFO(className) \ @@ -42,10 +42,10 @@ { \ return className::create(); \ } \ - cocostudio::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \ + cocos2d::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \ #define CREATE_CLASS_GUI_INFO(className) \ - cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \ + cocos2d::ObjectFactory::TInfo(#className, &className::createInstance) \ // @@ -54,7 +54,7 @@ #define DECLARE_CLASS_WIDGET_READER_INFO \ public: \ - static cocostudio::ObjectFactory::TInfo __Type; \ + static cocos2d::ObjectFactory::TInfo __Type; \ static cocos2d::Ref* createInstance(void); \ #define IMPLEMENT_CLASS_WIDGET_READER_INFO(className) \ @@ -62,10 +62,10 @@ { \ return className::getInstance(); \ } \ - cocostudio::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \ + cocos2d::ObjectFactory::TInfo className::__Type(#className, &className::createInstance); \ #define CREATE_CLASS_WIDGET_READER_INFO(className) \ - cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \ + cocos2d::ObjectFactory::TInfo(#className, &className::createInstance) \ #endif /* defined(__TestCpp__GUIDefine__) */ diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 58b0303ca4..9b54a2b440 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -24,6 +24,9 @@ THE SOFTWARE. #include "ui/UIButton.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "2d/CCLabel.h" +#include "2d/CCSprite.h" +#include "2d/CCActionInterval.h" NS_CC_BEGIN @@ -257,7 +260,10 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) _normalTextureSize = _buttonNormalRenderer->getContentSize(); updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_buttonNormalRenderer); + + _buttonNormalRenderer->setColor(this->getColor()); + _buttonNormalRenderer->setOpacity(this->getOpacity()); + updateContentSizeWithTextureSize(_normalTextureSize); _normalTextureLoaded = true; _normalTextureAdaptDirty = true; @@ -305,7 +311,10 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy _pressedTextureSize = _buttonClickedRenderer->getContentSize(); updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_buttonDisableRenderer); + + _buttonDisableRenderer->setColor(this->getColor()); + _buttonDisableRenderer->setOpacity(this->getOpacity()); + _pressedTextureLoaded = true; _pressedTextureAdaptDirty = true; } @@ -352,7 +361,9 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT _disabledTextureSize = _buttonDisableRenderer->getContentSize(); updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_buttonDisableRenderer); + _buttonDisableRenderer->setColor(this->getColor()); + _buttonDisableRenderer->setOpacity(this->getOpacity()); + _disabledTextureLoaded = true; _disabledTextureAdaptDirty = true; } @@ -429,7 +440,7 @@ void Button::onPressStateChangedToNormal() { if (_scale9Enabled) { - updateTextureRGBA(); + updateTexturesRGBA(); } else { @@ -438,6 +449,17 @@ void Button::onPressStateChangedToNormal() } } } + +void Button::updateTexturesRGBA() +{ + _buttonNormalRenderer->setColor(this->getColor()); + _buttonClickedRenderer->setColor(this->getColor()); + _buttonDisableRenderer->setColor(this->getColor()); + + _buttonNormalRenderer->setOpacity(this->getOpacity()); + _buttonClickedRenderer->setOpacity(this->getOpacity()); + _buttonDisableRenderer->setOpacity(this->getOpacity()); +} void Button::onPressStateChangedToPressed() { @@ -729,27 +751,6 @@ std::string Button::getDescription() const { return "Button"; } - -void Button::updateTextureColor() -{ - updateColorToRenderer(_buttonNormalRenderer); - updateColorToRenderer(_buttonClickedRenderer); - updateColorToRenderer(_buttonDisableRenderer); -} - -void Button::updateTextureOpacity() -{ - updateOpacityToRenderer(_buttonNormalRenderer); - updateOpacityToRenderer(_buttonClickedRenderer); - updateOpacityToRenderer(_buttonDisableRenderer); -} - -void Button::updateTextureRGBA() -{ - updateRGBAToRenderer(_buttonNormalRenderer); - updateRGBAToRenderer(_buttonClickedRenderer); - updateRGBAToRenderer(_buttonDisableRenderer); -} Widget* Button::createCloneInstance() { diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index 18a1d5dd17..ff12c127df 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Label; + namespace ui{ /** @@ -199,18 +201,22 @@ protected: virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + virtual void updateFlippedX() override; virtual void updateFlippedY() override; + + void updateTexturesRGBA(); + void normalTextureScaleChangedWithSize(); void pressedTextureScaleChangedWithSize(); void disabledTextureScaleChangedWithSize(); - virtual Widget* createCloneInstance() override; - virtual void copySpecialProperties(Widget* model) override; + virtual void adaptRenderers() override; void updateTitleLocation(); + + virtual Widget* createCloneInstance() override; + virtual void copySpecialProperties(Widget* model) override; + protected: Node* _buttonNormalRenderer; Node* _buttonClickedRenderer; diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index 4a5d81e873..5440da5a3a 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ui/UICheckBox.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -183,7 +184,9 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundBoxRenderer); + _backGroundBoxRenderer->setColor(this->getColor()); + _backGroundBoxRenderer->setOpacity(this->getOpacity()); + updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize()); _backGroundBoxRendererAdaptDirty = true; } @@ -209,7 +212,8 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundSelectedBoxRenderer); + _backGroundSelectedBoxRenderer->setColor(this->getColor()); + _backGroundSelectedBoxRenderer->setOpacity(this->getOpacity()); _backGroundSelectedBoxRendererAdaptDirty = true; } @@ -234,7 +238,8 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_frontCrossRenderer); + _frontCrossRenderer->setColor(this->getColor()); + _frontCrossRenderer->setOpacity(this->getOpacity()); _frontCrossRendererAdaptDirty = true; } @@ -259,7 +264,9 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_backGroundBoxDisabledRenderer); + _backGroundBoxDisabledRenderer->setColor(this->getColor()); + _backGroundBoxDisabledRenderer->setOpacity(this->getOpacity()); + _backGroundBoxDisabledRendererAdaptDirty = true; } @@ -284,7 +291,9 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl } updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_frontCrossDisabledRenderer); + _frontCrossDisabledRenderer->setColor(this->getColor()); + _frontCrossDisabledRenderer->setOpacity(this->getOpacity()); + _frontCrossDisabledRendererAdaptDirty = true; } @@ -564,33 +573,6 @@ std::string CheckBox::getDescription() const { return "CheckBox"; } - -void CheckBox::updateTextureColor() -{ - updateColorToRenderer(_backGroundBoxRenderer); - updateColorToRenderer(_backGroundSelectedBoxRenderer); - updateColorToRenderer(_frontCrossRenderer); - updateColorToRenderer(_backGroundBoxDisabledRenderer); - updateColorToRenderer(_frontCrossDisabledRenderer); -} - -void CheckBox::updateTextureOpacity() -{ - updateOpacityToRenderer(_backGroundBoxRenderer); - updateOpacityToRenderer(_backGroundSelectedBoxRenderer); - updateOpacityToRenderer(_frontCrossRenderer); - updateOpacityToRenderer(_backGroundBoxDisabledRenderer); - updateOpacityToRenderer(_frontCrossDisabledRenderer); -} - -void CheckBox::updateTextureRGBA() -{ - updateRGBAToRenderer(_backGroundBoxRenderer); - updateRGBAToRenderer(_backGroundSelectedBoxRenderer); - updateRGBAToRenderer(_frontCrossRenderer); - updateRGBAToRenderer(_backGroundBoxDisabledRenderer); - updateRGBAToRenderer(_frontCrossDisabledRenderer); -} Widget* CheckBox::createCloneInstance() { diff --git a/cocos/ui/UICheckBox.h b/cocos/ui/UICheckBox.h index 940c3acbbb..05c77d836b 100644 --- a/cocos/ui/UICheckBox.h +++ b/cocos/ui/UICheckBox.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Sprite; + namespace ui { CC_DEPRECATED_ATTRIBUTE typedef enum @@ -209,16 +211,16 @@ protected: virtual void releaseUpEvent(); virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + virtual void updateFlippedX() override; virtual void updateFlippedY() override; + void backGroundTextureScaleChangedWithSize(); void backGroundSelectedTextureScaleChangedWithSize(); void frontCrossTextureScaleChangedWithSize(); void backGroundDisabledTextureScaleChangedWithSize(); void frontCrossDisabledTextureScaleChangedWithSize(); + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void adaptRenderers() override; diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index f37997e1bf..95034eeef5 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UIImageView.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -153,7 +154,9 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) _imageTextureSize = _imageRenderer->getContentSize(); updateFlippedX(); updateFlippedY(); - updateRGBAToRenderer(_imageRenderer); + _imageRenderer->setColor(this->getColor()); + _imageRenderer->setOpacity(this->getOpacity()); + updateContentSizeWithTextureSize(_imageTextureSize); _imageRendererAdaptDirty = true; } @@ -320,21 +323,6 @@ std::string ImageView::getDescription() const { return "ImageView"; } - -void ImageView::updateTextureColor() -{ - updateColorToRenderer(_imageRenderer); -} - -void ImageView::updateTextureOpacity() -{ - updateOpacityToRenderer(_imageRenderer); -} - -void ImageView::updateTextureRGBA() -{ - updateRGBAToRenderer(_imageRenderer); -} Widget* ImageView::createCloneInstance() { diff --git a/cocos/ui/UIImageView.h b/cocos/ui/UIImageView.h index 867d1c1394..8afa3514bb 100644 --- a/cocos/ui/UIImageView.h +++ b/cocos/ui/UIImageView.h @@ -118,15 +118,15 @@ CC_CONSTRUCTOR_ACCESS: protected: virtual void initRenderer() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + virtual void updateFlippedX() override; virtual void updateFlippedY() override; + + virtual void adaptRenderers() override; + void imageTextureScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; - virtual void adaptRenderers() override; protected: bool _scale9Enabled; bool _prevIgnoreSize; diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 8f30aabbe6..74495a8e1b 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -30,9 +30,13 @@ THE SOFTWARE. #include "base/CCDirector.h" #include "2d/CCDrawingPrimitives.h" #include "renderer/CCRenderer.h" -#include "renderer/CCGroupCommand.h" -#include "renderer/CCCustomCommand.h" #include "ui/UILayoutManager.h" +#include "2d/CCDrawNode.h" +#include "2d/CCLayer.h" +#include "CCGLView.h" +#include "2d/CCSprite.h" +#include "base/CCEventFocus.h" + NS_CC_BEGIN @@ -88,8 +92,7 @@ _passFocusToChild(true), _loopFocus(false), _isFocusPassing(false) { - onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); - this->setAnchorPoint(Vec2::ZERO); + //no-op } Layout::~Layout() @@ -136,6 +139,7 @@ bool Layout::init() ignoreContentAdaptWithSize(false); setSize(Size::ZERO); setAnchorPoint(Vec2::ZERO); + onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this); return true; } return false; @@ -183,22 +187,25 @@ bool Layout::isClippingEnabled()const return _clippingEnabled; } -void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (!_visible) { return; } + adaptRenderers(); + doLayout(); + if (_clippingEnabled) { switch (_clippingType) { case ClippingType::STENCIL: - stencilClippingVisit(renderer, parentTransform, parentTransformUpdated); + stencilClippingVisit(renderer, parentTransform, parentFlags); break; case ClippingType::SCISSOR: - scissorClippingVisit(renderer, parentTransform, parentTransformUpdated); + scissorClippingVisit(renderer, parentTransform, parentFlags); break; default: break; @@ -206,26 +213,16 @@ void Layout::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentT } else { - ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated); + Widget::visit(renderer, parentTransform, parentFlags); } - doLayout(); } -void Layout::sortAllChildren() -{ - Widget::sortAllChildren(); - doLayout(); -} - -void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) { if(!_visible) return; - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, @@ -245,7 +242,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); renderer->addCommand(&_beforeVisitCmdStencil); - _clippingStencil->visit(renderer, _modelViewTransform, dirty); + _clippingStencil->visit(renderer, _modelViewTransform, flags); _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); @@ -265,7 +262,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor auto node = _children.at(i); if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } @@ -275,7 +272,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor auto node = _protectedChildren.at(j); if ( node && node->getLocalZOrder() < 0 ) - node->visit(renderer, _modelViewTransform, dirty); + node->visit(renderer, _modelViewTransform, flags); else break; } @@ -283,16 +280,16 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransfor // // draw self // - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); // // draw children and protectedChildren zOrder >= 0 // for(auto it=_protectedChildren.cbegin()+j; it != _protectedChildren.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) - (*it)->visit(renderer, _modelViewTransform, dirty); + (*it)->visit(renderer, _modelViewTransform, flags); _afterVisitCmdStencil.init(_globalZOrder); @@ -327,10 +324,20 @@ void Layout::onBeforeVisitStencil() glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); + this->drawFullScreenQuadClearStencil(); + + glStencilFunc(GL_NEVER, mask_layer, mask_layer); + glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); +} + +void Layout::drawFullScreenQuadClearStencil() +{ Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); @@ -338,8 +345,6 @@ void Layout::onBeforeVisitStencil() director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - glStencilFunc(GL_NEVER, mask_layer, mask_layer); - glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); } void Layout::onAfterDrawStencil() @@ -375,13 +380,13 @@ void Layout::onAfterVisitScissor() glDisable(GL_SCISSOR_TEST); } -void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated) +void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) { _beforeVisitCmdScissor.init(_globalZOrder); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); - ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated); + ProtectedNode::visit(renderer, parentTransform, parentFlags); _afterVisitCmdScissor.init(_globalZOrder); _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index e3ee81c36a..6c77939185 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -26,13 +26,20 @@ THE SOFTWARE. #define __LAYOUT_H__ #include "ui/UIWidget.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCGroupCommand.h" NS_CC_BEGIN +class DrawNode; +class LayerColor; +class LayerGradient; + namespace ui { class LayoutManager; - + + class LayoutProtocol { public: @@ -49,7 +56,12 @@ public: * @js NA * @lua NA */ - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#ifdef RELATIVE +#undef RELATIVE +#endif +#endif + class Layout : public Widget, public LayoutProtocol { @@ -241,7 +253,7 @@ public: */ virtual void addChild(Node* child, int zOrder, int tag) override; - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; virtual void removeChild(Node* child, bool cleanup = true) override; @@ -260,7 +272,6 @@ public: */ virtual void removeAllChildrenWithCleanup(bool cleanup) override; - virtual void sortAllChildren() override; void requestDoLayout(); @@ -321,8 +332,8 @@ protected: virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; - void stencilClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); - void scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated); + void stencilClippingVisit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags); + void scissorClippingVisit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags); void setStencilClippingSize(const Size& size); const Rect& getClippingRect(); @@ -336,6 +347,9 @@ protected: void onBeforeVisitStencil(); void onAfterDrawStencil(); void onAfterVisitStencil(); + /**draw fullscreen quad to clear stencil bits + */ + void drawFullScreenQuadClearStencil(); void onBeforeVisitScissor(); void onAfterVisitScissor(); diff --git a/cocos/ui/UIListView.cpp b/cocos/ui/UIListView.cpp index b0391bbcb1..16d9e29280 100644 --- a/cocos/ui/UIListView.cpp +++ b/cocos/ui/UIListView.cpp @@ -437,9 +437,10 @@ void ListView::refreshView() updateInnerContainerSize(); } -void ListView::sortAllChildren() +void ListView::doLayout() { - ScrollView::sortAllChildren(); + Layout::doLayout(); + if (_refreshViewDirty) { refreshView(); @@ -488,9 +489,9 @@ void ListView::selectedItemEvent(TouchEventType event) } -void ListView::interceptTouchEvent(TouchEventType event, Widget *sender, const Vec2 &touchPoint) +void ListView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch* touch) { - ScrollView::interceptTouchEvent(event, sender, touchPoint); + ScrollView::interceptTouchEvent(event, sender, touch); if (event != TouchEventType::MOVED) { Widget* parent = sender; diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index d053bca7cc..c14ff5f7a1 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -161,7 +161,8 @@ public: float getItemsMargin()const; - virtual void sortAllChildren() override; + virtual void doLayout() override; + virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; virtual void addChild(Node* child, int zOrder, int tag) override; @@ -200,14 +201,19 @@ protected: virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; void selectedItemEvent(TouchEventType event); - virtual void interceptTouchEvent(Widget::TouchEventType event,Widget* sender,const Vec2 &touchPoint) override; + virtual void interceptTouchEvent(Widget::TouchEventType event,Widget* sender,Touch* touch) override; protected: - Widget* _model; + Vector _items; + Gravity _gravity; + float _itemsMargin; + ssize_t _curSelectedIndex; + bool _refreshViewDirty; + Ref* _listViewEventListener; #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -222,9 +228,6 @@ protected: #pragma warning (pop) #endif ccListViewCallback _eventCallback; - - ssize_t _curSelectedIndex; - bool _refreshViewDirty; }; } diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 221b266ebf..5dccc11c5b 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UILoadingBar.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -122,7 +123,7 @@ LoadingBar::Direction LoadingBar::getDirection()const } - void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) +void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) { if (texture.empty()) { @@ -159,7 +160,9 @@ LoadingBar::Direction LoadingBar::getDirection()const default: break; } - updateRGBAToRenderer(_barRenderer); + _barRenderer->setColor(this->getColor()); + _barRenderer->setOpacity(this->getOpacity()); + _barRendererTextureSize = _barRenderer->getContentSize(); switch (_direction) @@ -357,21 +360,6 @@ std::string LoadingBar::getDescription() const { return "LoadingBar"; } - -void LoadingBar::updateTextureColor() -{ - updateColorToRenderer(_barRenderer); -} - -void LoadingBar::updateTextureOpacity() -{ - updateOpacityToRenderer(_barRenderer); -} - -void LoadingBar::updateTextureRGBA() -{ - updateRGBAToRenderer(_barRenderer); -} Widget* LoadingBar::createCloneInstance() { diff --git a/cocos/ui/UILoadingBar.h b/cocos/ui/UILoadingBar.h index 287e1d2569..1a0d6cbe6a 100644 --- a/cocos/ui/UILoadingBar.h +++ b/cocos/ui/UILoadingBar.h @@ -141,14 +141,14 @@ public: protected: virtual void initRenderer() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + void setScale9Scale(); void barRendererScaleChangedWithSize(); + + virtual void adaptRenderers() override; + virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; - virtual void adaptRenderers() override; protected: Direction _direction; float _percent; diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 0d2f42011f..bec6b266b9 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -33,9 +33,6 @@ IMPLEMENT_CLASS_GUI_INFO(PageView) PageView::PageView(): _curPageIdx(0), _touchMoveDirection(TouchDirection::LEFT), -_touchStartLocation(0.0f), -_touchMoveStartLocation(0.0f), -_movePagePoint(Vec2::ZERO), _leftBoundaryChild(nullptr), _rightBoundaryChild(nullptr), _leftBoundary(0.0f), @@ -332,19 +329,18 @@ bool PageView::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Layout::onTouchBegan(touch, unusedEvent); if (_hitted) { - handlePressLogic(touch->getLocation()); + handlePressLogic(touch); } return pass; } void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) { - _touchMovePos = touch->getLocation(); - handleMoveLogic(_touchMovePos); + handleMoveLogic(touch); Widget* widgetParent = getWidgetParent(); if (widgetParent) { - widgetParent->interceptTouchEvent(TouchEventType::MOVED,this,_touchMovePos); + widgetParent->interceptTouchEvent(TouchEventType::MOVED,this,touch); } moveEvent(); } @@ -352,13 +348,13 @@ void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); - handleReleaseLogic(_touchEndPos); + handleReleaseLogic(touch); } void PageView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); - handleReleaseLogic(touch->getLocation()); + handleReleaseLogic(touch); } void PageView::doLayout() @@ -380,9 +376,8 @@ void PageView::movePages(float offset) { for (auto& page : this->getPages()) { - _movePagePoint.x = page->getPosition().x + offset; - _movePagePoint.y = page->getPosition().y; - page->setPosition(_movePagePoint); + page->setPosition(Vec2(page->getPosition().x + offset, + page->getPosition().y)); } } @@ -429,20 +424,18 @@ bool PageView::scrollPages(float touchOffset) return true; } -void PageView::handlePressLogic(const Vec2 &touchPoint) +void PageView::handlePressLogic(Touch *touch) { - Vec2 nsp = convertToNodeSpace(touchPoint); - _touchMoveStartLocation = nsp.x; - _touchStartLocation = nsp.x; + //no-op } -void PageView::handleMoveLogic(const Vec2 &touchPoint) +void PageView::handleMoveLogic(Touch *touch) { - Vec2 nsp = convertToNodeSpace(touchPoint); + Vec2 touchPoint = touch->getLocation(); + float offset = 0.0; - float moveX = nsp.x; - offset = moveX - _touchMoveStartLocation; - _touchMoveStartLocation = moveX; + offset = touchPoint.x - touch->getPreviousLocation().x; + if (offset < 0) { _touchMoveDirection = TouchDirection::LEFT; @@ -454,7 +447,7 @@ void PageView::handleMoveLogic(const Vec2 &touchPoint) scrollPages(offset); } -void PageView::handleReleaseLogic(const Vec2 &touchPoint) +void PageView::handleReleaseLogic(Touch *touch) { if (this->getPageCount() <= 0) { @@ -498,27 +491,29 @@ void PageView::handleReleaseLogic(const Vec2 &touchPoint) } -void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, const Vec2 &touchPoint) +void PageView::interceptTouchEvent(TouchEventType event, Widget *sender, Touch *touch) { + Vec2 touchPoint = touch->getLocation(); + switch (event) { case TouchEventType::BEGAN: - handlePressLogic(touchPoint); + handlePressLogic(touch); break; case TouchEventType::MOVED: { float offset = 0; - offset = fabs(sender->getTouchStartPos().x - touchPoint.x); + offset = fabs(sender->getTouchBeganPosition().x - touchPoint.x); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); - handleMoveLogic(touchPoint); + handleMoveLogic(touch); } } break; case TouchEventType::CANCELED: case TouchEventType::ENDED: - handleReleaseLogic(touchPoint); + handleReleaseLogic(touch); break; } } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index c5b62f0526..f3544f0a47 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -26,7 +26,6 @@ THE SOFTWARE. #define __UIPAGEVIEW_H__ #include "ui/UILayout.h" -#include "ui/UIScrollInterface.h" NS_CC_BEGIN @@ -138,8 +137,6 @@ public: CC_DEPRECATED_ATTRIBUTE void addEventListenerPageView(Ref *target, SEL_PageViewEvent selector); void addEventListener(const ccPageViewCallback& callback); - - virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; @@ -189,10 +186,10 @@ protected: void updateAllPagesPosition(); void autoScroll(float dt); - virtual void handlePressLogic(const Vec2 &touchPoint); - virtual void handleMoveLogic(const Vec2 &touchPoint) ; - virtual void handleReleaseLogic(const Vec2 &touchPoint) ; - virtual void interceptTouchEvent(TouchEventType event, Widget* sender, const Vec2 &touchPoint) ; + virtual void handlePressLogic(Touch *touch); + virtual void handleMoveLogic(Touch *touch) ; + virtual void handleReleaseLogic(Touch *touch) ; + virtual void interceptTouchEvent(TouchEventType event, Widget* sender,Touch *touch) ; virtual void onSizeChanged() override; @@ -217,18 +214,15 @@ protected: Vector _pages; TouchDirection _touchMoveDirection; - - float _touchStartLocation; - float _touchMoveStartLocation; - Vec2 _movePagePoint; + Widget* _leftBoundaryChild; Widget* _rightBoundaryChild; + float _leftBoundary; float _rightBoundary; float _childFocusCancelOffset; - Ref* _pageViewEventListener; #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index e0436e594f..e1c827199b 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -23,7 +23,9 @@ ****************************************************************************/ #include "UIRichText.h" - +#include "platform/CCFileUtils.h" +#include "2d/CCLabel.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -447,12 +449,12 @@ void RichText::pushToContainer(cocos2d::Node *renderer) _elementRenders[_elementRenders.size()-1]->pushBack(renderer); } -void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void RichText::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (_enabled) { formatText(); - Widget::visit(renderer, parentTransform, parentTransformUpdated); + Widget::visit(renderer, parentTransform, parentFlags); } } diff --git a/cocos/ui/UIRichText.h b/cocos/ui/UIRichText.h index b3893bef12..cab8927b5c 100644 --- a/cocos/ui/UIRichText.h +++ b/cocos/ui/UIRichText.h @@ -102,7 +102,7 @@ public: void pushBackElement(RichElement* element); void removeElement(int index); void removeElement(RichElement* element); - virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; void setVerticalSpace(float space); virtual void setAnchorPoint(const Vec2 &pt); virtual const Size& getVirtualRendererSize() const override; diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 97ac197faf..ad66c67a37 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -27,41 +27,6 @@ THE SOFTWARE. NS_CC_BEGIN namespace ui { - -ScrollInnerContainer::ScrollInnerContainer() -{ - -} - -ScrollInnerContainer::~ScrollInnerContainer() -{ - -} - -ScrollInnerContainer* ScrollInnerContainer::create() -{ - ScrollInnerContainer* widget = new ScrollInnerContainer(); - if (widget && widget->init()) - { - widget->autorelease(); - return widget; - } - CC_SAFE_DELETE(widget); - return nullptr; -} - -const Size& ScrollInnerContainer::getLayoutSize() -{ - Widget* parent = getWidgetParent(); - if (parent) - { - return parent->getSize(); - } - else - { - return _size; - } -} static const float AUTOSCROLLMAXSPEED = 1000.0f; @@ -75,10 +40,6 @@ IMPLEMENT_CLASS_GUI_INFO(ScrollView) ScrollView::ScrollView(): _innerContainer(nullptr), _direction(Direction::VERTICAL), -_touchBeganPoint(Vec2::ZERO), -_touchMovedPoint(Vec2::ZERO), -_touchEndedPoint(Vec2::ZERO), -_touchMovingPoint(Vec2::ZERO), _autoScrollDir(Vec2::ZERO), _topBoundary(0.0f), _bottomBoundary(0.0f), @@ -1438,7 +1399,7 @@ void ScrollView::endRecordSlidAction() switch (_direction) { case Direction::VERTICAL: - totalDis = _touchEndedPoint.y - _touchBeganPoint.y; + totalDis = _touchEndPosition.y - _touchBeganPosition.y; if (totalDis < 0.0f) { dir = SCROLLDIR_DOWN; @@ -1449,7 +1410,7 @@ void ScrollView::endRecordSlidAction() } break; case Direction::HORIZONTAL: - totalDis = _touchEndedPoint.x - _touchBeganPoint.x; + totalDis = _touchEndPosition.x - _touchBeganPosition.x; if (totalDis < 0.0f) { dir = SCROLLDIR_LEFT; @@ -1461,7 +1422,7 @@ void ScrollView::endRecordSlidAction() break; case Direction::BOTH: { - Vec2 subVector = _touchEndedPoint - _touchBeganPoint; + Vec2 subVector = _touchEndPosition - _touchBeganPosition; totalDis = subVector.getLength(); dir = subVector.getNormalized(); break; @@ -1475,19 +1436,15 @@ void ScrollView::endRecordSlidAction() } } -void ScrollView::handlePressLogic(const Vec2 &touchPoint) -{ - _touchBeganPoint = convertToNodeSpace(touchPoint); - _touchMovingPoint = _touchBeganPoint; +void ScrollView::handlePressLogic(Touch *touch) +{ startRecordSlidAction(); _bePressed = true; } -void ScrollView::handleMoveLogic(const Vec2 &touchPoint) +void ScrollView::handleMoveLogic(Touch *touch) { - _touchMovedPoint = convertToNodeSpace(touchPoint); - Vec2 delta = _touchMovedPoint - _touchMovingPoint; - _touchMovingPoint = _touchMovedPoint; + Vec2 delta = touch->getLocation() - touch->getPreviousLocation(); switch (_direction) { case Direction::VERTICAL: // vertical @@ -1510,9 +1467,8 @@ void ScrollView::handleMoveLogic(const Vec2 &touchPoint) } } -void ScrollView::handleReleaseLogic(const Vec2 &touchPoint) +void ScrollView::handleReleaseLogic(Touch *touch) { - _touchEndedPoint = convertToNodeSpace(touchPoint); endRecordSlidAction(); _bePressed = false; } @@ -1522,7 +1478,7 @@ bool ScrollView::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Layout::onTouchBegan(touch, unusedEvent); if (_hitted) { - handlePressLogic(_touchStartPos); + handlePressLogic(touch); } return pass; } @@ -1530,19 +1486,19 @@ bool ScrollView::onTouchBegan(Touch *touch, Event *unusedEvent) void ScrollView::onTouchMoved(Touch *touch, Event *unusedEvent) { Layout::onTouchMoved(touch, unusedEvent); - handleMoveLogic(_touchMovePos); + handleMoveLogic(touch); } void ScrollView::onTouchEnded(Touch *touch, Event *unusedEvent) { Layout::onTouchEnded(touch, unusedEvent); - handleReleaseLogic(_touchEndPos); + handleReleaseLogic(touch); } void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent) { Layout::onTouchCancelled(touch, unusedEvent); - handleReleaseLogic(touch->getLocation()); + handleReleaseLogic(touch); } void ScrollView::update(float dt) @@ -1566,29 +1522,29 @@ void ScrollView::recordSlidTime(float dt) } } -void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sender, const Vec2 &touchPoint) +void ScrollView::interceptTouchEvent(Widget::TouchEventType event, Widget *sender,Touch* touch) { + Vec2 touchPoint = touch->getLocation(); switch (event) { case TouchEventType::BEGAN: - handlePressLogic(touchPoint); + handlePressLogic(touch); break; case TouchEventType::MOVED: { - float offset = (sender->getTouchStartPos() - touchPoint).getLength(); + float offset = (sender->getTouchBeganPosition() - touchPoint).getLength(); if (offset > _childFocusCancelOffset) { sender->setHighlighted(false); - handleMoveLogic(touchPoint); + handleMoveLogic(touch); } } break; case TouchEventType::CANCELED: case TouchEventType::ENDED: - handleReleaseLogic(touchPoint); - handleReleaseLogic(touchPoint); + handleReleaseLogic(touch); break; } } diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index ff159a27da..a0994af4dc 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -26,22 +26,12 @@ THE SOFTWARE. #define __UISCROLLVIEW_H__ #include "ui/UILayout.h" -#include "ui/UIScrollInterface.h" NS_CC_BEGIN class EventFocusListener; namespace ui { - -class ScrollInnerContainer : public Layout -{ -public: - ScrollInnerContainer(); - virtual ~ScrollInnerContainer(); - static ScrollInnerContainer* create(); - virtual const Size& getLayoutSize() override; -}; CC_DEPRECATED_ATTRIBUTE typedef enum { @@ -60,7 +50,7 @@ CC_DEPRECATED_ATTRIBUTE typedef void (Ref::*SEL_ScrollViewEvent)(Ref*, Scrollvie #define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR) -class ScrollView : public Layout , public ScrollViewProtocol +class ScrollView : public Layout { DECLARE_CLASS_GUI_INFO @@ -87,6 +77,7 @@ public: BOUNCE_RIGHT }; typedef std::function ccScrollViewCallback; + /** * Default constructor */ @@ -96,7 +87,6 @@ public: * Default destructor */ virtual ~ScrollView(); - /** * Allocates and initializes. */ @@ -328,7 +318,7 @@ public: CC_CONSTRUCTOR_ACCESS: virtual bool init() override; - + protected: virtual void initRenderer() override; @@ -365,10 +355,11 @@ protected: virtual void endRecordSlidAction(); //ScrollViewProtocol - virtual void handlePressLogic(const Vec2 &touchPoint) override; - virtual void handleMoveLogic(const Vec2 &touchPoint) override; - virtual void handleReleaseLogic(const Vec2 &touchPoint) override; - virtual void interceptTouchEvent(Widget::TouchEventType event,Widget* sender,const Vec2 &touchPoint) override; + virtual void handlePressLogic(Touch *touch) ; + virtual void handleMoveLogic(Touch *touch) ; + virtual void handleReleaseLogic(Touch *touch) ; + + virtual void interceptTouchEvent(Widget::TouchEventType event,Widget* sender,Touch *touch) override; void recordSlidTime(float dt); @@ -387,11 +378,6 @@ protected: Layout* _innerContainer; Direction _direction; - - Vec2 _touchBeganPoint; - Vec2 _touchMovedPoint; - Vec2 _touchEndedPoint; - Vec2 _touchMovingPoint; Vec2 _autoScrollDir; float _topBoundary; diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 561c39e891..7a2e9f441b 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include "ui/UISlider.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "2d/CCSprite.h" NS_CC_BEGIN @@ -146,7 +147,9 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) default: break; } - updateRGBAToRenderer(_barRenderer); + _barRenderer->setColor(this->getColor()); + _barRenderer->setOpacity(this->getOpacity()); + _barRendererAdaptDirty = true; _progressBarRendererDirty = true; updateContentSizeWithTextureSize(_barRenderer->getContentSize()); @@ -185,7 +188,10 @@ void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType default: break; } - updateRGBAToRenderer(_progressBarRenderer); + + _progressBarRenderer->setColor(this->getColor()); + _progressBarRenderer->setOpacity(this->getOpacity()); + _progressBarRenderer->setAnchorPoint(Vec2(0.0f, 0.5f)); _progressBarTextureSize = _progressBarRenderer->getContentSize(); _progressBarRendererDirty = true; @@ -307,7 +313,8 @@ void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType default: break; } - updateRGBAToRenderer(_slidBallNormalRenderer); + _slidBallNormalRenderer->setColor(this->getColor()); + _slidBallNormalRenderer->setOpacity(this->getOpacity()); } void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType) @@ -329,7 +336,8 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp default: break; } - updateRGBAToRenderer(_slidBallPressedRenderer); + _slidBallPressedRenderer->setColor(this->getColor()); + _slidBallPressedRenderer->setOpacity(this->getOpacity()); } void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType) @@ -351,7 +359,8 @@ void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResTyp default: break; } - updateRGBAToRenderer(_slidBallDisabledRenderer); + _slidBallDisabledRenderer->setColor(this->getColor()); + _slidBallDisabledRenderer->setOpacity(this->getOpacity()); } void Slider::setPercent(int percent) @@ -397,7 +406,7 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent) bool pass = Widget::onTouchBegan(touch, unusedEvent); if (_hitted) { - Vec2 nsp = convertToNodeSpace(_touchStartPos); + Vec2 nsp = convertToNodeSpace(_touchBeganPosition); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } @@ -406,8 +415,8 @@ bool Slider::onTouchBegan(Touch *touch, Event *unusedEvent) void Slider::onTouchMoved(Touch *touch, Event *unusedEvent) { - _touchMovePos = touch->getLocation(); - Vec2 nsp = convertToNodeSpace(_touchMovePos); + _touchMovePosition = touch->getLocation(); + Vec2 nsp = convertToNodeSpace(_touchMovePosition); setPercent(getPercentWithBallPos(nsp.x)); percentChangedEvent(); } @@ -581,33 +590,6 @@ std::string Slider::getDescription() const { return "Slider"; } - -void Slider::updateTextureColor() -{ - updateColorToRenderer(_barRenderer); - updateColorToRenderer(_progressBarRenderer); - updateColorToRenderer(_slidBallNormalRenderer); - updateColorToRenderer(_slidBallPressedRenderer); - updateColorToRenderer(_slidBallDisabledRenderer); -} - -void Slider::updateTextureOpacity() -{ - updateOpacityToRenderer(_barRenderer); - updateOpacityToRenderer(_progressBarRenderer); - updateOpacityToRenderer(_slidBallNormalRenderer); - updateOpacityToRenderer(_slidBallPressedRenderer); - updateOpacityToRenderer(_slidBallDisabledRenderer); -} - -void Slider::updateTextureRGBA() -{ - updateRGBAToRenderer(_barRenderer); - updateRGBAToRenderer(_progressBarRenderer); - updateRGBAToRenderer(_slidBallNormalRenderer); - updateRGBAToRenderer(_slidBallPressedRenderer); - updateRGBAToRenderer(_slidBallDisabledRenderer); -} Widget* Slider::createCloneInstance() { diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index 76bb7463c4..451cd6ca2c 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Sprite; + namespace ui { CC_DEPRECATED_ATTRIBUTE typedef enum @@ -216,9 +218,7 @@ protected: virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + void barRendererScaleChangedWithSize(); void progressBarRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index 5d4efd57df..0ce8d0f57a 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ #include "ui/UIText.h" +#include "2d/CCLabel.h" +#include "platform/CCFileUtils.h" NS_CC_BEGIN @@ -322,19 +324,23 @@ std::string Text::getDescription() const return "Label"; } -void Text::updateTextureColor() -{ - updateColorToRenderer(_labelRenderer); + + +void Text::enableShadow(const Color4B& shadowColor,const Size &offset, int blurRadius) { + _labelRenderer->enableShadow(shadowColor, offset, blurRadius); } -void Text::updateTextureOpacity() -{ - updateOpacityToRenderer(_labelRenderer); +void Text::enableOutline(const Color4B& outlineColor,int outlineSize) { + _labelRenderer->enableOutline(outlineColor, outlineSize); +} + +void Text::enableGlow(const Color4B& glowColor) { + if (_type == Type::TTF) + _labelRenderer->enableGlow(glowColor); } -void Text::updateTextureRGBA() -{ - updateRGBAToRenderer(_labelRenderer); +void Text::disableEffect() { + _labelRenderer->disableEffect(); } Widget* Text::createCloneInstance() diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index b3cc3bd6b0..3c38101abd 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Label; + namespace ui { /** @@ -158,6 +160,25 @@ public: TextVAlignment getTextVerticalAlignment()const; + /** + * Enable shadow for the label + * + * @todo support blur for shadow effect + */ + void enableShadow(const Color4B& shadowColor = Color4B::BLACK,const Size &offset = Size(2,-2), int blurRadius = 0); + + /** + * Enable outline for the label + * It only works on IOS and Android when you use System fonts + */ + void enableOutline(const Color4B& outlineColor,int outlineSize = 1); + + /** only support for TTF */ + void enableGlow(const Color4B& glowColor); + + /** disable shadow/outline/glow rendering */ + void disableEffect(); + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& textContent, @@ -170,9 +191,7 @@ protected: virtual void onPressStateChangedToPressed() override; virtual void onPressStateChangedToDisabled() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + virtual void updateFlippedX() override; virtual void updateFlippedY() override; void labelScaleChangedWithSize(); diff --git a/cocos/ui/UITextAtlas.cpp b/cocos/ui/UITextAtlas.cpp index d249f4422b..e7bac16081 100644 --- a/cocos/ui/UITextAtlas.cpp +++ b/cocos/ui/UITextAtlas.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ui/UITextAtlas.h" +#include "2d/CCLabel.h" NS_CC_BEGIN @@ -170,21 +171,6 @@ std::string TextAtlas::getDescription() const { return "TextAtlas"; } - -void TextAtlas::updateTextureColor() -{ - updateColorToRenderer(_labelAtlasRenderer); -} - -void TextAtlas::updateTextureOpacity() -{ - updateOpacityToRenderer(_labelAtlasRenderer); -} - -void TextAtlas::updateTextureRGBA() -{ - updateRGBAToRenderer(_labelAtlasRenderer); -} Widget* TextAtlas::createCloneInstance() { diff --git a/cocos/ui/UITextAtlas.h b/cocos/ui/UITextAtlas.h index 4ffa93f927..8058aa4d7d 100644 --- a/cocos/ui/UITextAtlas.h +++ b/cocos/ui/UITextAtlas.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Label; + namespace ui { /** @@ -104,9 +106,7 @@ public: protected: virtual void initRenderer() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + void labelAtlasScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; diff --git a/cocos/ui/UITextBMFont.cpp b/cocos/ui/UITextBMFont.cpp index f6769ee2dc..4e4c7f34a7 100644 --- a/cocos/ui/UITextBMFont.cpp +++ b/cocos/ui/UITextBMFont.cpp @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ui/UITextBMFont.h" +#include "2d/CCLabel.h" NS_CC_BEGIN @@ -86,7 +87,9 @@ void TextBMFont::setFntFile(const std::string& fileName) } _fntFileName = fileName; _labelBMFontRenderer->setBMFontFilePath(fileName); - updateRGBAToRenderer(_labelBMFontRenderer); + + _labelBMFontRenderer->setColor(this->getColor()); + _labelBMFontRenderer->setOpacity(this->getOpacity()); _fntFileHasInit = true; setString(_stringValue); } @@ -164,21 +167,6 @@ std::string TextBMFont::getDescription() const { return "TextBMFont"; } - -void TextBMFont::updateTextureColor() -{ - updateColorToRenderer(_labelBMFontRenderer); -} - -void TextBMFont::updateTextureOpacity() -{ - updateOpacityToRenderer(_labelBMFontRenderer); -} - -void TextBMFont::updateTextureRGBA() -{ - updateRGBAToRenderer(_labelBMFontRenderer); -} Widget* TextBMFont::createCloneInstance() { diff --git a/cocos/ui/UITextBMFont.h b/cocos/ui/UITextBMFont.h index 5cca667916..707f42382c 100644 --- a/cocos/ui/UITextBMFont.h +++ b/cocos/ui/UITextBMFont.h @@ -29,6 +29,8 @@ THE SOFTWARE. NS_CC_BEGIN +class Label; + namespace ui { /** @@ -87,15 +89,13 @@ public: protected: virtual void initRenderer() override; virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + void labelBMFontScaleChangedWithSize(); virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void adaptRenderers() override; protected: - cocos2d::Label* _labelBMFontRenderer; + Label* _labelBMFontRenderer; bool _fntFileHasInit; std::string _fntFileName; std::string _stringValue; diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 49bc100eb3..7199783b69 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -564,6 +564,11 @@ const std::string& TextField::getStringValue()const { return _textFieldRenderer->getString(); } + +int TextField::getStringLength() const { + return _textFieldRenderer->getStringLength(); +} + bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent) { @@ -799,21 +804,6 @@ std::string TextField::getDescription() const { return "TextField"; } - -void TextField::updateTextureColor() -{ - updateColorToRenderer(_textFieldRenderer); -} - -void TextField::updateTextureOpacity() -{ - updateOpacityToRenderer(_textFieldRenderer); -} - -void TextField::updateTextureRGBA() -{ - updateRGBAToRenderer(_textFieldRenderer); -} void TextField::attachWithIME() { diff --git a/cocos/ui/UITextField.h b/cocos/ui/UITextField.h index 8c2ef01c9e..b343ed4a7d 100644 --- a/cocos/ui/UITextField.h +++ b/cocos/ui/UITextField.h @@ -26,6 +26,7 @@ THE SOFTWARE. #define __UITEXTFIELD_H__ #include "ui/UIWidget.h" +#include "2d/CCTextFieldTTF.h" NS_CC_BEGIN @@ -149,8 +150,9 @@ public: void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled()const; void setMaxLength(int length); + int getMaxLength()const; - + int getStringLength() const; void setPasswordEnabled(bool enable); bool isPasswordEnabled()const; void setPasswordStyleText(const char* styleText); @@ -196,9 +198,7 @@ protected: void insertTextEvent(); void deleteBackwardEvent(); virtual void onSizeChanged() override; - virtual void updateTextureColor() override; - virtual void updateTextureOpacity() override; - virtual void updateTextureRGBA() override; + void textfieldRendererScaleChangedWithSize(); virtual Widget* createCloneInstance() override; diff --git a/cocos/ui/UIVideoPlayer.h b/cocos/ui/UIVideoPlayer.h index fa3627b61c..81d0787236 100644 --- a/cocos/ui/UIVideoPlayer.h +++ b/cocos/ui/UIVideoPlayer.h @@ -74,7 +74,7 @@ namespace experimental{ virtual void addEventListener(const VideoPlayer::ccVideoPlayerCallback& callback); virtual void onPlayEvent(VideoPlayer::EventType event); - virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override; protected: virtual cocos2d::ui::Widget* createCloneInstance() override; diff --git a/cocos/ui/UIVideoPlayerAndroid.cpp b/cocos/ui/UIVideoPlayerAndroid.cpp index 2c8073c68c..a9deb991f3 100644 --- a/cocos/ui/UIVideoPlayerAndroid.cpp +++ b/cocos/ui/UIVideoPlayerAndroid.cpp @@ -30,6 +30,9 @@ #include #include #include "jni/JniHelper.h" +#include "base/CCDirector.h" +#include "CCGLView.h" +#include "base/CCEventListenerKeyboard.h" //----------------------------------------------------------------------------------------------------------- #define CLASS_NAME "org/cocos2dx/lib/Cocos2dxVideoHelper" @@ -195,11 +198,11 @@ void VideoPlayer::setURL(const std::string& videoUrl) setVideoURLJNI(_videoPlayerIndex,(int)Source::URL,_videoURL); } -void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated) +void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags) { - cocos2d::ui::Widget::draw(renderer,transform,transformUpdated); + cocos2d::ui::Widget::draw(renderer,transform,flags); - if (transformUpdated || _fullScreenDirty) + if ((flags&FLAGS_TRANSFORM_DIRTY) || _fullScreenDirty) { _fullScreenDirty = false; auto directorInstance = Director::getInstance(); @@ -209,7 +212,7 @@ void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transform if (_fullScreenEnabled) { setVideoRectJNI(_videoPlayerIndex,0,0,frameSize.width,frameSize.height); - } + } else { auto winSize = directorInstance->getWinSize(); @@ -223,7 +226,7 @@ void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transform setVideoRectJNI(_videoPlayerIndex,uiLeft,uiTop, (rightTop.x - leftBottom.x) * glView->getScaleX(), (rightTop.y - leftBottom.y) * glView->getScaleY()); - } + } } #if CC_VIDEOPLAYER_DEBUG_DRAW @@ -386,4 +389,4 @@ void executeVideoCallback(int index,int event) } } -#endif \ No newline at end of file +#endif diff --git a/cocos/ui/UIVideoPlayerIOS.mm b/cocos/ui/UIVideoPlayerIOS.mm index a38db66291..7bf359f822 100644 --- a/cocos/ui/UIVideoPlayerIOS.mm +++ b/cocos/ui/UIVideoPlayerIOS.mm @@ -29,7 +29,9 @@ using namespace cocos2d::experimental::ui; //------------------------------------------------------------------------------------- #include "CCEAGLView.h" +#include "CCGLView.h" #import +#include "base/CCDirector.h" @interface UIVideoViewWrapperIos : NSObject @@ -312,11 +314,11 @@ void VideoPlayer::setURL(const std::string& videoUrl) [((UIVideoViewWrapperIos*)_videoView) setURL:(int)_videoSource :_videoURL]; } -void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated) +void VideoPlayer::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags) { - cocos2d::ui::Widget::draw(renderer,transform,transformUpdated); + cocos2d::ui::Widget::draw(renderer,transform,flags); - if (transformUpdated) + if (flags & FLAGS_TRANSFORM_DIRTY) { auto directorInstance = Director::getInstance(); auto glView = directorInstance->getOpenGLView(); diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 38c3b61770..01139a0836 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -25,6 +25,10 @@ THE SOFTWARE. #include "ui/UIWidget.h" #include "ui/UILayout.h" #include "ui/UIHelper.h" +#include "base/CCEventListenerTouch.h" +#include "base/CCEventListenerKeyboard.h" +#include "base/CCDirector.h" +#include "base/CCEventFocus.h" NS_CC_BEGIN @@ -135,9 +139,9 @@ _bright(true), _touchEnabled(false), _highlight(false), _brightStyle(BrightStyle::NONE), -_touchStartPos(Vec2::ZERO), -_touchMovePos(Vec2::ZERO), -_touchEndPos(Vec2::ZERO), +_touchBeganPosition(Vec2::ZERO), +_touchMovePosition(Vec2::ZERO), +_touchEndPosition(Vec2::ZERO), _touchEventListener(nullptr), _touchEventSelector(nullptr), _name("default"), @@ -153,18 +157,13 @@ _positionPercent(Vec2::ZERO), _reorderWidgetChildDirty(true), _hitted(false), _touchListener(nullptr), -_color(Color3B::WHITE), -_opacity(255), _flippedX(false), _flippedY(false), _focused(false), _focusEnabled(true), _layoutParameterType(LayoutParameter::Type::NONE) { - onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this); - onNextFocusedWidget = nullptr; - this->setAnchorPoint(Vec2(0.5f, 0.5f)); - this->setTouchEnabled(true); + } Widget::~Widget() @@ -206,8 +205,15 @@ bool Widget::init() { initRenderer(); setBright(true); + //TODO: need refactor ignoreContentAdaptWithSize(true); - setAnchorPoint(Vec2(0.5f, 0.5f)); + onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this); + onNextFocusedWidget = nullptr; + this->setAnchorPoint(Vec2(0.5f, 0.5f)); + this->setTouchEnabled(true); + this->setCascadeColorEnabled(true); + this->setCascadeOpacityEnabled(true); + return true; } return false; @@ -225,12 +231,12 @@ void Widget::onExit() ProtectedNode::onExit(); } -void Widget::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Widget::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if (_visible) { adaptRenderers(); - ProtectedNode::visit(renderer, parentTransform, parentTransformUpdated); + ProtectedNode::visit(renderer, parentTransform, parentFlags); } } @@ -676,8 +682,8 @@ bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) _hitted = false; if (isVisible() && isEnabled() && isAncestorsEnabled() && isAncestorsVisible(this) ) { - _touchStartPos = touch->getLocation(); - if(hitTest(_touchStartPos) && clippingParentAreaContainPoint(_touchStartPos)) + _touchBeganPosition = touch->getLocation(); + if(hitTest(_touchBeganPosition) && isClippingParentContainsPoint(_touchBeganPosition)) { _hitted = true; } @@ -690,7 +696,7 @@ bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) Widget* widgetParent = getWidgetParent(); if (widgetParent) { - widgetParent->interceptTouchEvent(TouchEventType::BEGAN, this, _touchStartPos); + widgetParent->interceptTouchEvent(TouchEventType::BEGAN, this, touch); } pushDownEvent(); return true; @@ -698,27 +704,30 @@ bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) void Widget::onTouchMoved(Touch *touch, Event *unusedEvent) { - _touchMovePos = touch->getLocation(); - setHighlighted(hitTest(_touchMovePos)); + _touchMovePosition = touch->getLocation(); + setHighlighted(hitTest(_touchMovePosition)); Widget* widgetParent = getWidgetParent(); if (widgetParent) { - widgetParent->interceptTouchEvent(TouchEventType::MOVED, this, _touchMovePos); + widgetParent->interceptTouchEvent(TouchEventType::MOVED, this, touch); } moveEvent(); } void Widget::onTouchEnded(Touch *touch, Event *unusedEvent) { - _touchEndPos = touch->getLocation(); + _touchEndPosition = touch->getLocation(); Widget* widgetParent = getWidgetParent(); if (widgetParent) { - widgetParent->interceptTouchEvent(TouchEventType::ENDED, this, _touchEndPos); + widgetParent->interceptTouchEvent(TouchEventType::ENDED, this, touch); } - if (_highlight) + bool highlight = _highlight; + setHighlighted(false); + + if (highlight) { releaseUpEvent(); } @@ -726,9 +735,6 @@ void Widget::onTouchEnded(Touch *touch, Event *unusedEvent) { cancelUpEvent(); } - - setHighlighted(false); - } void Widget::onTouchCancelled(Touch *touch, Event *unusedEvent) @@ -811,7 +817,7 @@ bool Widget::hitTest(const Vec2 &pt) return false; } -bool Widget::clippingParentAreaContainPoint(const Vec2 &pt) +bool Widget::isClippingParentContainsPoint(const Vec2 &pt) { _affectByClipping = false; Widget* parent = getWidgetParent(); @@ -846,19 +852,19 @@ bool Widget::clippingParentAreaContainPoint(const Vec2 &pt) } if (bRet) { - return clippingParent->clippingParentAreaContainPoint(pt); + return clippingParent->isClippingParentContainsPoint(pt); } return false; } return true; } -void Widget::interceptTouchEvent(cocos2d::ui::Widget::TouchEventType event, cocos2d::ui::Widget *sender, const cocos2d::Vec2 &point) +void Widget::interceptTouchEvent(cocos2d::ui::Widget::TouchEventType event, cocos2d::ui::Widget *sender, Touch *touch) { Widget* widgetParent = getWidgetParent(); if (widgetParent) { - widgetParent->interceptTouchEvent(event,sender,point); + widgetParent->interceptTouchEvent(event,sender,touch); } } @@ -943,19 +949,19 @@ float Widget::getTopBoundary() const return getBottomBoundary() + _size.height; } -const Vec2& Widget::getTouchStartPos()const +const Vec2& Widget::getTouchBeganPosition()const { - return _touchStartPos; + return _touchBeganPosition; } -const Vec2& Widget::getTouchMovePos()const +const Vec2& Widget::getTouchMovePosition()const { - return _touchMovePos; + return _touchMovePosition; } -const Vec2& Widget::getTouchEndPos()const +const Vec2& Widget::getTouchEndPosition()const { - return _touchEndPos; + return _touchEndPosition; } void Widget::setName(const std::string& name) @@ -1071,18 +1077,6 @@ void Widget::copyProperties(Widget *widget) onSizeChanged(); } -void Widget::setColor(const Color3B& color) -{ - _color = color; - updateTextureColor(); -} - -void Widget::setOpacity(GLubyte opacity) -{ - _opacity = opacity; - updateTextureOpacity(); -} - void Widget::setFlippedX(bool flippedX) { _flippedX = flippedX; @@ -1095,21 +1089,6 @@ void Widget::setFlippedY(bool flippedY) updateFlippedY(); } -void Widget::updateColorToRenderer(Node* renderer) -{ - renderer->setColor(_color); -} - -void Widget::updateOpacityToRenderer(Node* renderer) -{ - renderer->setOpacity(_opacity); -} - -void Widget::updateRGBAToRenderer(Node* renderer) -{ - renderer->setColor(_color); - renderer->setOpacity(_opacity); -} /*temp action*/ void Widget::setActionTag(int tag) diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index 53a0bd5ff2..437068d613 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -28,10 +28,13 @@ THE SOFTWARE. #include "ui/CCProtectedNode.h" #include "ui/UILayoutParameter.h" #include "ui/GUIDefine.h" -#include "ui/UILayoutParameter.h" +#include "base/CCMap.h" NS_CC_BEGIN +class EventListenerTouchOneByOne; + + namespace ui { CC_DEPRECATED_ATTRIBUTE typedef enum @@ -104,18 +107,15 @@ public: typedef std::function ccWidgetTouchCallback; - - /** * Default constructor */ Widget(void); - + /** * Default destructor */ virtual ~Widget(); - /** * Allocates and initializes a widget. */ @@ -237,7 +237,7 @@ public: */ virtual Widget* getChildByName(const std::string& name) const; - virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; /** * Sets the touch event target/selector of the menu item @@ -331,14 +331,6 @@ public: * @return true if the widget is flipped vertically, flase otherwise. */ virtual bool isFlippedY()const{return _flippedY;}; - - virtual void setColor(const Color3B& color) override; - - virtual void setOpacity(GLubyte opacity) override; - - const Color3B& getColor() const override {return _color;}; - - GLubyte getOpacity() const override {return _opacity;}; /** @deprecated Use isFlippedX() instead */ CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); }; @@ -356,28 +348,32 @@ public: * * @return true if the point is in parent's area, flase otherwise. */ - bool clippingParentAreaContainPoint(const Vec2 &pt); + CC_DEPRECATED_ATTRIBUTE bool clippingParentAreaContainPoint(const Vec2 &pt){return this->isClippingParentContainsPoint(pt);} + bool isClippingParentContainsPoint(const Vec2& pt); /* * Gets the touch began point of widget when widget is selected. * * @return the touch began point. */ - const Vec2& getTouchStartPos()const; + CC_DEPRECATED_ATTRIBUTE const Vec2& getTouchStartPos()const{return this->getTouchBeganPosition();} + const Vec2& getTouchBeganPosition()const; /* * Gets the touch move point of widget when widget is selected. * * @return the touch move point. */ - const Vec2& getTouchMovePos()const; + CC_DEPRECATED_ATTRIBUTE const Vec2& getTouchMovePos()const{ return this->getTouchMovePosition();} + const Vec2& getTouchMovePosition()const; /* * Gets the touch end point of widget when widget is selected. * * @return the touch end point. */ - const Vec2& getTouchEndPos()const; + CC_DEPRECATED_ATTRIBUTE const Vec2& getTouchEndPos()const{return this->getTouchEndPosition();} + const Vec2& getTouchEndPosition()const; /** * Changes the name that is used to identify the widget easily. @@ -453,14 +449,6 @@ public: * @return true if the point is in widget's space, flase otherwise. */ virtual bool hitTest(const Vec2 &pt); - - /* - * Sends the touch event to widget's parent - * @param event the touch event type, it could be BEGAN/MOVED/CANCELED/ENDED - * @param parent - * @param point - */ - virtual void interceptTouchEvent(TouchEventType event,Widget* sender,const Vec2 &point); virtual bool onTouchBegan(Touch *touch, Event *unusedEvent); virtual void onTouchMoved(Touch *touch, Event *unusedEvent); @@ -602,13 +590,29 @@ public: */ static void enableDpadNavigation(bool enable); + /** + * When a widget lose/get focus, this method will be called. Be Caution when you provide your own version, + * you must call widget->setFocused(true/false) to change the focus state of the current focused widget; + */ std::function onFocusChanged; + /** + * use this function to manually specify the next focused widget regards to each direction + */ std::function onNextFocusedWidget; CC_CONSTRUCTOR_ACCESS: + //initializes state of widget. virtual bool init() override; - + + /* + * Sends the touch event to widget's parent + * @param event the touch event type, it could be BEGAN/MOVED/CANCELED/ENDED + * @param parent + * @param point + */ + virtual void interceptTouchEvent(TouchEventType event, Widget* sender, Touch *touch); + friend class PageView; /** * This method is called when a focus change event happens *@param widgetLostFocus The widget which lose its focus @@ -635,29 +639,20 @@ protected: //call back function called widget's state changed to normal. virtual void onPressStateChangedToNormal(); - //call back function called widget's state changed to selected. virtual void onPressStateChangedToPressed(); - //call back function called widget's state changed to dark. virtual void onPressStateChangedToDisabled(); + void pushDownEvent(); void moveEvent(); virtual void releaseUpEvent(); virtual void cancelUpEvent(); - - virtual void updateTextureColor(){}; - virtual void updateTextureOpacity(){}; - virtual void updateTextureRGBA(){}; + virtual void updateFlippedX(){}; virtual void updateFlippedY(){}; virtual void adaptRenderers(){}; - - - void updateColorToRenderer(Node* renderer); - void updateOpacityToRenderer(Node* renderer); - void updateRGBAToRenderer(Node* renderer); void copyProperties(Widget* model); virtual Widget* createCloneInstance(); @@ -678,67 +673,62 @@ protected: bool _bright; ///< is this widget bright bool _touchEnabled; ///< is this widget touch endabled bool _highlight; ///< is the widget on focus - BrightStyle _brightStyle; ///< bright style - Vec2 _touchStartPos; ///< touch began point - Vec2 _touchMovePos; ///< touch moved point - Vec2 _touchEndPos; ///< touch ended point - - //if use the old API, we must retain the _touchEventListener - Ref* _touchEventListener; - -#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#elif _MSC_VER >= 1400 //vs 2005 or higher -#pragma warning (push) -#pragma warning (disable: 4996) -#endif - SEL_TouchEvent _touchEventSelector; -#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#pragma GCC diagnostic warning "-Wdeprecated-declarations" -#elif _MSC_VER >= 1400 //vs 2005 or higher -#pragma warning (pop) -#endif - - ccWidgetTouchCallback _touchEventCallback; - - std::string _name; - int _actionTag; - Size _size; - Size _customSize; + bool _reorderWidgetChildDirty; + bool _affectByClipping; bool _ignoreSize; + BrightStyle _brightStyle; ///< bright style SizeType _sizeType; - Vec2 _sizePercent; - - bool _affectByClipping; - PositionType _positionType; + + //use + std::string _name; + int _actionTag; + + Size _size; + Size _customSize; + + Vec2 _sizePercent; Vec2 _positionPercent; - bool _reorderWidgetChildDirty; + bool _hitted; EventListenerTouchOneByOne* _touchListener; - Color3B _color; - GLubyte _opacity; + Vec2 _touchBeganPosition; ///< touch began point + Vec2 _touchMovePosition; ///< touch moved point + Vec2 _touchEndPosition; ///< touch ended point + bool _flippedX; bool _flippedY; + //use map to enble switch back and forth for user layout parameters Map _layoutParameterDictionary; LayoutParameter::Type _layoutParameterType; bool _focused; bool _focusEnabled; - - /** * store the only one focued widget */ static Widget *_focusedWidget; //both layout & widget will be stored in this variable + //if use the old API, we must retain the _touchEventListener + Ref* _touchEventListener; + #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #elif _MSC_VER >= 1400 //vs 2005 or higher + #pragma warning (push) + #pragma warning (disable: 4996) + #endif + SEL_TouchEvent _touchEventSelector; + #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #pragma GCC diagnostic warning "-Wdeprecated-declarations" + #elif _MSC_VER >= 1400 //vs 2005 or higher + #pragma warning (pop) + #endif + ccWidgetTouchCallback _touchEventCallback; private: class FocusNavigationController; static FocusNavigationController* _focusNavigationController; - - }; } diff --git a/cocos/ui/proj.win32/libGUI.vcxproj b/cocos/ui/proj.win32/libGUI.vcxproj index c236573262..862a4989c3 100644 --- a/cocos/ui/proj.win32/libGUI.vcxproj +++ b/cocos/ui/proj.win32/libGUI.vcxproj @@ -26,7 +26,6 @@ - diff --git a/cocos/ui/proj.win32/libGUI.vcxproj.filters b/cocos/ui/proj.win32/libGUI.vcxproj.filters index db58d827f6..a82d945c9f 100644 --- a/cocos/ui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/ui/proj.win32/libGUI.vcxproj.filters @@ -18,9 +18,6 @@ - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget diff --git a/cocos/ui/proj.wp8/libGUI.vcxproj b/cocos/ui/proj.wp8/libGUI.vcxproj index 55f544b422..c58030f74b 100644 --- a/cocos/ui/proj.wp8/libGUI.vcxproj +++ b/cocos/ui/proj.wp8/libGUI.vcxproj @@ -176,7 +176,6 @@ - @@ -186,6 +185,7 @@ + @@ -210,6 +210,7 @@ + - \ No newline at end of file + diff --git a/cocos/ui/proj.wp8/libGUI.vcxproj.filters b/cocos/ui/proj.wp8/libGUI.vcxproj.filters index 9a791f39e7..475c39565d 100644 --- a/cocos/ui/proj.wp8/libGUI.vcxproj.filters +++ b/cocos/ui/proj.wp8/libGUI.vcxproj.filters @@ -36,9 +36,6 @@ UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -84,6 +81,9 @@ Layouts + + Layouts + @@ -152,5 +152,8 @@ Layouts + + Layouts + - \ No newline at end of file + diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index ff618a8ac2..3a01b499bf 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -71,10 +71,10 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b { if (Control::init()) { - CCASSERT(node != nullptr, "Label must not be nil."); + CCASSERT(node != nullptr, "node must not be nil."); LabelProtocol* label = dynamic_cast(node); CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil."); - CCASSERT(label != nullptr || backgroundSprite != nullptr, ""); + CCASSERT(label != nullptr, "label must not be nil."); _parentInited = true; diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index 36a2c6ec31..6d342e7946 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -77,6 +77,7 @@ bool ControlColourPicker::init() // Add image _background=ControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, Vec2::ZERO, Vec2(0.5f, 0.5f)); + if(!_background) return false; CC_SAFE_RETAIN(_background); Vec2 backgroundPointZero = _background->getPosition() - Vec2(_background->getContentSize().width / 2, _background->getContentSize().height / 2); diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp index 8501d097a8..c959fdafcb 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp @@ -98,7 +98,8 @@ bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rec { this->updateWithBatchNode(batchnode, rect, rotated, capInsets); } - + this->setCascadeColorEnabled(true); + this->setCascadeOpacityEnabled(true); this->setAnchorPoint(Vec2(0.5f, 0.5f)); this->_positionsAreDirty = true; @@ -250,48 +251,48 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& o // Centre _centre = Sprite::createWithTexture(_scale9Image->getTexture(), centerbounds); _centre->retain(); - _scale9Image->addChild(_centre, 0, pCentre); + this->addChild(_centre, 0, pCentre); // Top _top = Sprite::createWithTexture(_scale9Image->getTexture(), centertopbounds); _top->retain(); - _scale9Image->addChild(_top, 1, pTop); + this->addChild(_top, 1, pTop); // Bottom _bottom = Sprite::createWithTexture(_scale9Image->getTexture(), centerbottombounds); _bottom->retain(); - _scale9Image->addChild(_bottom, 1, pBottom); + this->addChild(_bottom, 1, pBottom); // Left _left = Sprite::createWithTexture(_scale9Image->getTexture(), leftcenterbounds); _left->retain(); - _scale9Image->addChild(_left, 1, pLeft); + this->addChild(_left, 1, pLeft); // Right _right = Sprite::createWithTexture(_scale9Image->getTexture(), rightcenterbounds); _right->retain(); - _scale9Image->addChild(_right, 1, pRight); + this->addChild(_right, 1, pRight); // Top left _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), lefttopbounds); _topLeft->retain(); - _scale9Image->addChild(_topLeft, 2, pTopLeft); + this->addChild(_topLeft, 2, pTopLeft); // Top right _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), righttopbounds); _topRight->retain(); - _scale9Image->addChild(_topRight, 2, pTopRight); + this->addChild(_topRight, 2, pTopRight); // Bottom left _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), leftbottombounds); _bottomLeft->retain(); - _scale9Image->addChild(_bottomLeft, 2, pBottomLeft); + this->addChild(_bottomLeft, 2, pBottomLeft); // Bottom right _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rightbottombounds); _bottomRight->retain(); - _scale9Image->addChild(_bottomRight, 2, pBottomRight); + this->addChild(_bottomRight, 2, pBottomRight); } else { // set up transformation of coordinates // to handle the case where the sprite is stored rotated @@ -336,47 +337,47 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& o // Centre _centre = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbounds, true); _centre->retain(); - _scale9Image->addChild(_centre, 0, pCentre); + this->addChild(_centre, 0, pCentre); // Top _top = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcentertopbounds, true); _top->retain(); - _scale9Image->addChild(_top, 1, pTop); + this->addChild(_top, 1, pTop); // Bottom _bottom = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbottombounds, true); _bottom->retain(); - _scale9Image->addChild(_bottom, 1, pBottom); + this->addChild(_bottom, 1, pBottom); // Left _left = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftcenterbounds, true); _left->retain(); - _scale9Image->addChild(_left, 1, pLeft); + this->addChild(_left, 1, pLeft); // Right _right = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightcenterbounds, true); _right->retain(); - _scale9Image->addChild(_right, 1, pRight); + this->addChild(_right, 1, pRight); // Top left _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedlefttopbounds, true); _topLeft->retain(); - _scale9Image->addChild(_topLeft, 2, pTopLeft); + this->addChild(_topLeft, 2, pTopLeft); // Top right _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrighttopbounds, true); _topRight->retain(); - _scale9Image->addChild(_topRight, 2, pTopRight); + this->addChild(_topRight, 2, pTopRight); // Bottom left _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftbottombounds, true); _bottomLeft->retain(); - _scale9Image->addChild(_bottomLeft, 2, pBottomLeft); + this->addChild(_bottomLeft, 2, pBottomLeft); // Bottom right _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightbottombounds, true); _bottomRight->retain(); - _scale9Image->addChild(_bottomRight, 2, pBottomRight); + this->addChild(_bottomRight, 2, pBottomRight); } this->setContentSize(rect.size); @@ -764,14 +765,14 @@ void Scale9Sprite::setInsetBottom(float insetBottom) this->updateCapInset(); } -void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { if(this->_positionsAreDirty) { this->updatePositions(); this->_positionsAreDirty = false; } - Node::visit(renderer, parentTransform, parentTransformUpdated); + Node::visit(renderer, parentTransform, parentFlags); } void Scale9Sprite::setColor(const Color3B& color) diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h index da66186462..dc3c6b8696 100644 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ b/extensions/GUI/CCControlExtension/CCScale9Sprite.h @@ -261,7 +261,7 @@ public: * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; virtual void setOpacityModifyRGB(bool bValue) override; virtual bool isOpacityModifyRGB(void) const override; virtual void setOpacity(GLubyte opacity) override; diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp index 97b4b6c629..12572be246 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -318,9 +318,9 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint) } } -void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { - ControlButton::visit(renderer, parentTransform, parentTransformUpdated); + ControlButton::visit(renderer, parentTransform, parentFlags); if (_editBoxImpl != NULL) { _editBoxImpl->visit(); diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index 5b627ef498..f6a12dbf46 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -379,7 +379,7 @@ public: * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; /** * @js NA * @lua NA diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index f025eea458..c1397370fd 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -553,7 +553,7 @@ void ScrollView::onAfterDraw() } } -void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) +void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible if (!isVisible()) @@ -561,10 +561,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par return; } - bool dirty = parentTransformUpdated || _transformUpdated; - if(dirty) - _modelViewTransform = this->transform(parentTransform); - _transformUpdated = false; + uint32_t flags = processParentFlags(parentTransform, parentFlags); // IMPORTANT: // To ease the migration to v3.0, we still support the Mat4 stack, @@ -586,7 +583,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par Node *child = _children.at(i); if ( child->getLocalZOrder() < 0 ) { - child->visit(renderer, _modelViewTransform, dirty); + child->visit(renderer, _modelViewTransform, flags); } else { @@ -595,19 +592,19 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, bool par } // this draw - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); // draw children zOrder >= 0 for( ; i < _children.size(); i++ ) { Node *child = _children.at(i); - child->visit(renderer, _modelViewTransform, dirty); + child->visit(renderer, _modelViewTransform, flags); } } else { - this->draw(renderer, _modelViewTransform, dirty); + this->draw(renderer, _modelViewTransform, flags); } this->afterDraw(); diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index a232833ab0..3009619a8b 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -225,7 +225,7 @@ public: * @js NA * @lua NA */ - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; using Node::addChild; virtual void addChild(Node * child, int zOrder, int tag) override; diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.cpp b/extensions/physics-nodes/CCPhysicsDebugNode.cpp index 672895e9ef..18f55cefe4 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.cpp +++ b/extensions/physics-nodes/CCPhysicsDebugNode.cpp @@ -182,7 +182,7 @@ static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer) // implementation of PhysicsDebugNode -void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (! _spacePtr) { @@ -195,7 +195,7 @@ void PhysicsDebugNode::draw(Renderer *renderer, const Mat4 &transform, bool tran cpSpaceEachShape(_spacePtr, (cpSpaceShapeIteratorFunc)DrawShape, this); cpSpaceEachConstraint(_spacePtr, (cpSpaceConstraintIteratorFunc)DrawConstraint, this); - DrawNode::draw(renderer, transform, transformUpdated); + DrawNode::draw(renderer, transform, flags); #endif } diff --git a/extensions/physics-nodes/CCPhysicsDebugNode.h b/extensions/physics-nodes/CCPhysicsDebugNode.h index 300e796c50..390f24bfaa 100644 --- a/extensions/physics-nodes/CCPhysicsDebugNode.h +++ b/extensions/physics-nodes/CCPhysicsDebugNode.h @@ -61,7 +61,7 @@ public: void setSpace(cpSpace *space); // Overrides - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: cpSpace *_spacePtr; diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index 4ee1644382..0c896a5677 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -397,14 +397,14 @@ const Mat4& PhysicsSprite::getNodeToParentTransform() const return _transform; } -void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void PhysicsSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (isDirty()) { syncPhysicsTransform(); } - Sprite::draw(renderer, _transform, transformUpdated); + Sprite::draw(renderer, _transform, flags); } NS_CC_EXT_END diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index 3f87247deb..fa1f0489d0 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -116,7 +116,7 @@ public: virtual void syncPhysicsTransform() const; virtual const Mat4& getNodeToParentTransform() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: const Vec2& getPosFromPhysics() const; diff --git a/external/config.json b/external/config.json index 8bf90ee28a..94ea34592a 100644 --- a/external/config.json +++ b/external/config.json @@ -1,6 +1,6 @@ { - "version":"v3-deps-1", - "zip_file_size":"57164391", + "version":"v3-deps-2", + "zip_file_size":"57171285", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/" } diff --git a/external/xxtea/CMakeLists.txt b/external/xxtea/CMakeLists.txt new file mode 100644 index 0000000000..cf7ad364b2 --- /dev/null +++ b/external/xxtea/CMakeLists.txt @@ -0,0 +1,14 @@ +set(XXTEA + xxtea.cpp +) + +add_library(xxtea STATIC + ${XXTEA} +) + +set_target_properties(xxtea + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" +) + diff --git a/external/xxtea/xxtea.cpp b/external/xxtea/xxtea.cpp new file mode 100644 index 0000000000..935eaeafd8 --- /dev/null +++ b/external/xxtea/xxtea.cpp @@ -0,0 +1,176 @@ +/*********************************************************************** + + Copyright 2006-2009 Ma Bingyao + Copyright 2013 Gao Chunhui, Liu Tao + + These sources is free software. Redistributions of source code must + retain the above copyright notice. Redistributions in binary form + must reproduce the above copyright notice. You can redistribute it + freely. You can use it with any free or commercial software. + + These sources 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. + + github: https://github.com/liut/pecl-xxtea + + *************************************************************************/ + +#include "xxtea.h" +#include +#include + +static void xxtea_long_encrypt(xxtea_long *v, xxtea_long len, xxtea_long *k) +{ + xxtea_long n = len - 1; + xxtea_long z = v[n], y = v[0], p, q = 6 + 52 / (n + 1), sum = 0, e; + if (n < 1) { + return; + } + while (0 < q--) { + sum += XXTEA_DELTA; + e = sum >> 2 & 3; + for (p = 0; p < n; p++) { + y = v[p + 1]; + z = v[p] += XXTEA_MX; + } + y = v[0]; + z = v[n] += XXTEA_MX; + } +} + +static void xxtea_long_decrypt(xxtea_long *v, xxtea_long len, xxtea_long *k) +{ + xxtea_long n = len - 1; + xxtea_long z = v[n], y = v[0], p, q = 6 + 52 / (n + 1), sum = q * XXTEA_DELTA, e; + if (n < 1) { + return; + } + while (sum != 0) { + e = sum >> 2 & 3; + for (p = n; p > 0; p--) { + z = v[p - 1]; + y = v[p] -= XXTEA_MX; + } + z = v[n]; + y = v[0] -= XXTEA_MX; + sum -= XXTEA_DELTA; + } +} + +static unsigned char *fix_key_length(unsigned char *key, xxtea_long key_len) +{ + unsigned char *tmp = (unsigned char *)malloc(16); + memcpy(tmp, key, key_len); + memset(tmp + key_len, '\0', 16 - key_len); + return tmp; +} + +static xxtea_long *xxtea_to_long_array(unsigned char *data, xxtea_long len, int include_length, xxtea_long *ret_len) { + xxtea_long i, n, *result; + + n = len >> 2; + n = (((len & 3) == 0) ? n : n + 1); + if (include_length) { + result = (xxtea_long *)malloc((n + 1) << 2); + result[n] = len; + *ret_len = n + 1; + } else { + result = (xxtea_long *)malloc(n << 2); + *ret_len = n; + } + memset(result, 0, n << 2); + for (i = 0; i < len; i++) { + result[i >> 2] |= (xxtea_long)data[i] << ((i & 3) << 3); + } + + return result; +} + +static unsigned char *xxtea_to_byte_array(xxtea_long *data, xxtea_long len, int include_length, xxtea_long *ret_len) { + xxtea_long i, n, m; + unsigned char *result; + + n = len << 2; + if (include_length) { + m = data[len - 1]; + if ((m < n - 7) || (m > n - 4)) return NULL; + n = m; + } + result = (unsigned char *)malloc(n + 1); + for (i = 0; i < n; i++) { + result[i] = (unsigned char)((data[i >> 2] >> ((i & 3) << 3)) & 0xff); + } + result[n] = '\0'; + *ret_len = n; + + return result; +} + +static unsigned char *do_xxtea_encrypt(unsigned char *data, xxtea_long len, unsigned char *key, xxtea_long *ret_len) { + unsigned char *result; + xxtea_long *v, *k, v_len, k_len; + + v = xxtea_to_long_array(data, len, 1, &v_len); + k = xxtea_to_long_array(key, 16, 0, &k_len); + xxtea_long_encrypt(v, v_len, k); + result = xxtea_to_byte_array(v, v_len, 0, ret_len); + free(v); + free(k); + + return result; +} + +static unsigned char *do_xxtea_decrypt(unsigned char *data, xxtea_long len, unsigned char *key, xxtea_long *ret_len) { + unsigned char *result; + xxtea_long *v, *k, v_len, k_len; + + v = xxtea_to_long_array(data, len, 0, &v_len); + k = xxtea_to_long_array(key, 16, 0, &k_len); + xxtea_long_decrypt(v, v_len, k); + result = xxtea_to_byte_array(v, v_len, 1, ret_len); + free(v); + free(k); + + return result; +} + +unsigned char *xxtea_encrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length) +{ + unsigned char *result; + + *ret_length = 0; + + if (key_len < 16) { + unsigned char *key2 = fix_key_length(key, key_len); + result = do_xxtea_encrypt(data, data_len, key2, ret_length); + free(key2); + } + else + { + result = do_xxtea_encrypt(data, data_len, key, ret_length); + } + + return result; +} + +unsigned char *xxtea_decrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length) +{ + unsigned char *result; + + *ret_length = 0; + + if (key_len < 16) { + unsigned char *key2 = fix_key_length(key, key_len); + result = do_xxtea_decrypt(data, data_len, key2, ret_length); + free(key2); + } + else + { + result = do_xxtea_decrypt(data, data_len, key, ret_length); + } + + return result; +} + +/* }}} */ diff --git a/external/xxtea/xxtea.h b/external/xxtea/xxtea.h new file mode 100644 index 0000000000..ecdb32ceab --- /dev/null +++ b/external/xxtea/xxtea.h @@ -0,0 +1,47 @@ +/*********************************************************************** + + Copyright 2006-2009 Ma Bingyao + Copyright 2013 Gao Chunhui, Liu Tao + + These sources is free software. Redistributions of source code must + retain the above copyright notice. Redistributions in binary form + must reproduce the above copyright notice. You can redistribute it + freely. You can use it with any free or commercial software. + + These sources 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. + + github: https://github.com/liut/pecl-xxtea + + *************************************************************************/ + +#ifndef XXTEA_H +#define XXTEA_H + +#include /* for size_t & NULL declarations */ + +#if defined(_MSC_VER) + +typedef unsigned __int32 xxtea_long; + +#else + +#if defined(__FreeBSD__) && __FreeBSD__ < 5 +/* FreeBSD 4 doesn't have stdint.h file */ +#include +#else +#include +#endif + +typedef uint32_t xxtea_long; + +#endif /* end of if defined(_MSC_VER) */ + +#define XXTEA_MX (z >> 5 ^ y << 2) + (y >> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z) +#define XXTEA_DELTA 0x9e3779b9 + +unsigned char *xxtea_encrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length); +unsigned char *xxtea_decrypt(unsigned char *data, xxtea_long data_len, unsigned char *key, xxtea_long key_len, xxtea_long *ret_length); + +#endif diff --git a/plugin b/plugin index 4a8c94a85a..51ceded726 160000 --- a/plugin +++ b/plugin @@ -1 +1 @@ -Subproject commit 4a8c94a85a08cddbea5e1bc499c50cce7518fb15 +Subproject commit 51ceded726cc034cdc939e379e1b24249e0ebad4 diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 7ffef77193..89592354bf 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -324,6 +324,8 @@ "cocos/base/CCValue.h", "cocos/base/CCVector.h", "cocos/base/CMakeLists.txt", + "cocos/base/ObjectFactory.cpp", + "cocos/base/ObjectFactory.h", "cocos/base/TGAlib.cpp", "cocos/base/TGAlib.h", "cocos/base/ZipUtils.cpp", @@ -954,7 +956,6 @@ "cocos/ui/UIRelativeBox.h", "cocos/ui/UIRichText.cpp", "cocos/ui/UIRichText.h", - "cocos/ui/UIScrollInterface.h", "cocos/ui/UIScrollView.cpp", "cocos/ui/UIScrollView.h", "cocos/ui/UISlider.cpp", @@ -2194,6 +2195,9 @@ "external/xxhash/CMakeLists.txt", "external/xxhash/xxhash.c", "external/xxhash/xxhash.h", + "external/xxtea/CMakeLists.txt", + "external/xxtea/xxtea.cpp", + "external/xxtea/xxtea.h", "licenses/LICENSE_AA-EDT.txt", "licenses/LICENSE_CCBReader.txt", "licenses/LICENSE_CCControlExtension.txt", @@ -2323,6 +2327,10 @@ "plugin/plugins/googleplay/proj.android/src/org/cocos2dx/plugin/util/Purchase.java", "plugin/plugins/googleplay/proj.android/src/org/cocos2dx/plugin/util/Security.java", "plugin/plugins/googleplay/proj.android/src/org/cocos2dx/plugin/util/SkuDetails.java", + "plugin/plugins/iosiap/proj.ios/IOSIAP/IOSIAP.h", + "plugin/plugins/iosiap/proj.ios/IOSIAP/IOSIAP.m", + "plugin/plugins/iosiap/proj.ios/IOSIAP/PluginIAP-Prefix.pch", + "plugin/plugins/iosiap/proj.ios/PluginIAP.xcodeproj/project.pbxproj", "plugin/plugins/nd91/proj.android/.classpath", "plugin/plugins/nd91/proj.android/.project", "plugin/plugins/nd91/proj.android/AndroidManifest.xml", diff --git a/templates/cpp-template-default/cocos-project-template.json b/templates/cpp-template-default/cocos-project-template.json index 7246f50171..ab35bb7a12 100644 --- a/templates/cpp-template-default/cocos-project-template.json +++ b/templates/cpp-template-default/cocos-project-template.json @@ -11,7 +11,11 @@ "proj.win32/PROJECT_NAME.vcxproj.filters", "proj.win32/PROJECT_NAME.vcxproj.user", "proj.win32/PROJECT_NAME.sln", - "proj.ios_mac/PROJECT_NAME.xcodeproj" + "proj.ios_mac/PROJECT_NAME.xcodeproj", + "proj.wp8-xaml/PROJECT_NAME.sln", + "proj.wp8-xaml/App/PROJECT_NAME.csproj", + "proj.wp8-xaml/AppComponent/PROJECT_NAMEComponent.vcxproj", + "proj.wp8-xaml/AppComponent/PROJECT_NAMEComponent.vcxproj.filters" ] }, "project_replace_project_name":{ @@ -22,6 +26,8 @@ "proj.win32/PROJECT_NAME.vcxproj.user", "proj.win32/PROJECT_NAME.sln", "proj.win32/main.cpp", + "proj.wp8-xaml/App/PROJECT_NAME.csproj", + "proj.wp8-xaml/PROJECT_NAME.sln", "proj.android/.project", "proj.android/.cproject", "proj.android/AndroidManifest.xml", diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/App.xaml b/templates/cpp-template-default/proj.wp8-xaml/App/App.xaml similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/App.xaml rename to templates/cpp-template-default/proj.wp8-xaml/App/App.xaml diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/App.xaml.cs b/templates/cpp-template-default/proj.wp8-xaml/App/App.xaml.cs similarity index 88% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/App.xaml.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/App.xaml.cs index 1269fb1137..ce05496656 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/App.xaml.cs +++ b/templates/cpp-template-default/proj.wp8-xaml/App/App.xaml.cs @@ -140,12 +140,36 @@ namespace PhoneDirect3DXamlAppInterop RootFrame.Navigated -= CompleteInitializePhoneApplication; } + private bool _isResume = false; private void CheckForResetNavigation(object sender, NavigationEventArgs e) { - // If the app has received a 'reset' navigation, then we need to check - // on the next navigation to see if the page stack should be reset if (e.NavigationMode == NavigationMode.Reset) + { + RootFrame.Navigating += HandlerFotResetNavigating; + _isResume = true; + } + else + { + if (_isResume && e.NavigationMode == NavigationMode.Refresh) + { + RootFrame.Navigating -= HandlerFotResetNavigating; + _isResume = false; + } + } + } + + private void HandlerFotResetNavigating(object sender, NavigatingCancelEventArgs e) + { + RootFrame.Navigating -= HandlerFotResetNavigating; + if (e.Uri.OriginalString.Contains("MainPage.xaml")) + { + e.Cancel = true; + } + else + { RootFrame.Navigated += ClearBackStackAfterReset; + } + _isResume = false; } private void ClearBackStackAfterReset(object sender, NavigationEventArgs e) diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/AlignmentGrid.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/AlignmentGrid.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/AlignmentGrid.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/AlignmentGrid.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/ApplicationIcon.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/ApplicationIcon.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/ApplicationIcon.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/ApplicationIcon.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileLarge.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileLarge.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileLarge.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileLarge.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileMedium.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileMedium.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileMedium.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileMedium.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileSmall.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileSmall.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/FlipCycleTileSmall.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileSmall.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/IconicTileMediumLarge.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/IconicTileMediumLarge.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/IconicTileMediumLarge.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/IconicTileMediumLarge.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/IconicTileSmall.png b/templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/IconicTileSmall.png similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Assets/Tiles/IconicTileSmall.png rename to templates/cpp-template-default/proj.wp8-xaml/App/Assets/Tiles/IconicTileSmall.png diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/EditBox.xaml b/templates/cpp-template-default/proj.wp8-xaml/App/EditBox.xaml similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/EditBox.xaml rename to templates/cpp-template-default/proj.wp8-xaml/App/EditBox.xaml diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/EditBox.xaml.cs b/templates/cpp-template-default/proj.wp8-xaml/App/EditBox.xaml.cs similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/EditBox.xaml.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/EditBox.xaml.cs diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/HelloCpp.csproj b/templates/cpp-template-default/proj.wp8-xaml/App/HelloCpp.csproj similarity index 98% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/HelloCpp.csproj rename to templates/cpp-template-default/proj.wp8-xaml/App/HelloCpp.csproj index 8a4e7717a8..8d686b7879 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/HelloCpp.csproj +++ b/templates/cpp-template-default/proj.wp8-xaml/App/HelloCpp.csproj @@ -130,7 +130,7 @@ - + HelloCppComponent diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/LocalizedStrings.cs b/templates/cpp-template-default/proj.wp8-xaml/App/LocalizedStrings.cs similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/LocalizedStrings.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/LocalizedStrings.cs diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/MainPage.xaml b/templates/cpp-template-default/proj.wp8-xaml/App/MainPage.xaml similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/MainPage.xaml rename to templates/cpp-template-default/proj.wp8-xaml/App/MainPage.xaml diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/MainPage.xaml.cs b/templates/cpp-template-default/proj.wp8-xaml/App/MainPage.xaml.cs similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/MainPage.xaml.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/MainPage.xaml.cs diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/AppManifest.xml b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/AppManifest.xml similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/AppManifest.xml rename to templates/cpp-template-default/proj.wp8-xaml/App/Properties/AppManifest.xml diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/AssemblyInfo.cs b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/AssemblyInfo.cs similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/AssemblyInfo.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/Properties/AssemblyInfo.cs diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/WMAppManifest.xml b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml similarity index 97% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/WMAppManifest.xml rename to templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml index 92867a47d9..8437827d62 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Properties/WMAppManifest.xml +++ b/templates/cpp-template-default/proj.wp8-xaml/App/Properties/WMAppManifest.xml @@ -11,7 +11,7 @@ - + diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Resources/AppResources.Designer.cs b/templates/cpp-template-default/proj.wp8-xaml/App/Resources/AppResources.Designer.cs similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Resources/AppResources.Designer.cs rename to templates/cpp-template-default/proj.wp8-xaml/App/Resources/AppResources.Designer.cs diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Resources/AppResources.resx b/templates/cpp-template-default/proj.wp8-xaml/App/Resources/AppResources.resx similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/Resources/AppResources.resx rename to templates/cpp-template-default/proj.wp8-xaml/App/Resources/AppResources.resx diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp/SplashScreenImage.jpg b/templates/cpp-template-default/proj.wp8-xaml/App/SplashScreenImage.jpg similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCpp/SplashScreenImage.jpg rename to templates/cpp-template-default/proj.wp8-xaml/App/SplashScreenImage.jpg diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj similarity index 94% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj rename to templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj index 04098c2456..bedb6cbb2c 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj +++ b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj @@ -203,11 +203,11 @@ - - - - - + + + + + @@ -218,12 +218,12 @@ - - - - - - + + + + + + diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj.filters b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj.filters similarity index 65% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj.filters rename to templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj.filters index f742759eaf..645eb00360 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/HelloCppComponent.vcxproj.filters +++ b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/HelloCppComponent.vcxproj.filters @@ -1,11 +1,11 @@  - - - - - + + + + + Classes @@ -15,12 +15,12 @@ - - - - - - + + + + + + Classes diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/pch.cpp b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/pch.cpp similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/pch.cpp rename to templates/cpp-template-default/proj.wp8-xaml/AppComponent/pch.cpp diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/pch.h b/templates/cpp-template-default/proj.wp8-xaml/AppComponent/pch.h similarity index 100% rename from templates/cpp-template-default/proj.wp8-xaml/HelloCppComponent/pch.h rename to templates/cpp-template-default/proj.wp8-xaml/AppComponent/pch.h diff --git a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp.sln b/templates/cpp-template-default/proj.wp8-xaml/HelloCpp.sln index a0798281da..bbbc9ab846 100644 --- a/templates/cpp-template-default/proj.wp8-xaml/HelloCpp.sln +++ b/templates/cpp-template-default/proj.wp8-xaml/HelloCpp.sln @@ -1,8 +1,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloCpp", "HelloCpp\HelloCpp.csproj", "{83CC88FE-7E79-4E1E-A129-742987130B5C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloCpp", "App\HelloCpp.csproj", "{83CC88FE-7E79-4E1E-A129-742987130B5C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCppComponent", "HelloCppComponent\HelloCppComponent.vcxproj", "{60EC6889-C3C4-45AD-A006-47D9EE689212}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCppComponent", "AppComponent\HelloCppComponent.vcxproj", "{60EC6889-C3C4-45AD-A006-47D9EE689212}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\cocos2d_wp8.vcxproj", "{B5AF91B3-64EA-44E1-84B0-D759E93758FB}" EndProject diff --git a/templates/lua-template-default/frameworks/CMakeLists.txt b/templates/lua-template-default/frameworks/CMakeLists.txt index cb1df16d4c..c55979fd3d 100644 --- a/templates/lua-template-default/frameworks/CMakeLists.txt +++ b/templates/lua-template-default/frameworks/CMakeLists.txt @@ -75,6 +75,7 @@ include_directories( ${COCOS2D_ROOT}/external/freetype2/include/linux ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR} ${COCOS2D_ROOT}/external/xxhash + ${COCOS2D_ROOT}/external/xxtea ) link_directories( @@ -111,6 +112,9 @@ add_subdirectory(${COCOS2D_ROOT}/cocos) # extensions add_subdirectory(${COCOS2D_ROOT}/extensions) +# xxtea library +add_subdirectory(${COCOS2D_ROOT}/external/xxtea) + ## Editor Support # spine @@ -151,6 +155,7 @@ target_link_libraries(${APP_NAME} extensions audio cocos2d + xxtea ) set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") diff --git a/tests/cpp-empty-test/proj-wp8-xaml/cpp-empty-test/Properties/WMAppManifest.xml b/tests/cpp-empty-test/proj-wp8-xaml/cpp-empty-test/Properties/WMAppManifest.xml index e980dc34e6..e2147a3eeb 100644 --- a/tests/cpp-empty-test/proj-wp8-xaml/cpp-empty-test/Properties/WMAppManifest.xml +++ b/tests/cpp-empty-test/proj-wp8-xaml/cpp-empty-test/Properties/WMAppManifest.xml @@ -11,7 +11,7 @@ - + diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index 448a68b47b..608ce735d2 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -1350,15 +1350,15 @@ void ActionFollow::onEnter() this->runAction(Follow::create(_grossini, Rect(0, 0, s.width * 2 - 100, s.height))); } -void ActionFollow::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ActionFollow::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ActionFollow::onDraw(const Mat4 &transform, bool transformUpdated) +void ActionFollow::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1664,9 +1664,9 @@ ActionCatmullRomStacked::~ActionCatmullRomStacked() CC_SAFE_RELEASE(_array2); } -void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - ActionsDemo::draw(renderer, transform, transformUpdated); + ActionsDemo::draw(renderer, transform, flags); // move to 50,50 since the "by" path will start at 50,50 Director* director = Director::getInstance(); @@ -1684,11 +1684,11 @@ void ActionCatmullRomStacked::draw(Renderer *renderer, const Mat4 &transform, bo _modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ActionCatmullRomStacked::onDraw(const Mat4 &transform, bool transformUpdated) +void ActionCatmullRomStacked::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1784,9 +1784,9 @@ ActionCardinalSplineStacked::~ActionCardinalSplineStacked() CC_SAFE_RELEASE(_array); } -void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - ActionsDemo::draw(renderer, transform, transformUpdated); + ActionsDemo::draw(renderer, transform, flags); // move to 50,50 since the "by" path will start at 50,50 Director* director = Director::getInstance(); @@ -1814,11 +1814,11 @@ void ActionCardinalSplineStacked::draw(Renderer *renderer, const Mat4 &transform director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ActionCardinalSplineStacked::onDraw(const Mat4 &transform, bool transformUpdated) +void ActionCardinalSplineStacked::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -2198,9 +2198,9 @@ ActionCatmullRom::~ActionCatmullRom() _array2->release(); } -void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - ActionsDemo::draw(renderer, transform, transformUpdated); + ActionsDemo::draw(renderer, transform, flags); // move to 50,50 since the "by" path will start at 50,50 Director* director = Director::getInstance(); @@ -2218,12 +2218,12 @@ void ActionCatmullRom::draw(Renderer *renderer, const Mat4 &transform, bool tran _modelViewMV2 = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ActionCatmullRom::onDraw(const Mat4 &transform, bool transformUpdated) +void ActionCatmullRom::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -2303,9 +2303,9 @@ ActionCardinalSpline::~ActionCardinalSpline() _array->release(); } -void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - ActionsDemo::draw(renderer, transform, transformUpdated); + ActionsDemo::draw(renderer, transform, flags); // move to 50,50 since the "by" path will start at 50,50 Director* director = Director::getInstance(); @@ -2331,11 +2331,11 @@ void ActionCardinalSpline::draw(Renderer *renderer, const Mat4 &transform, bool director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ActionCardinalSpline::onDraw(const Mat4 &transform, bool transformUpdated) +void ActionCardinalSpline::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h index dafad5c774..8d281e237e 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h @@ -379,11 +379,11 @@ public: CREATE_FUNC(ActionFollow); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string subtitle() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _customCommand; }; @@ -454,13 +454,13 @@ public: CREATE_FUNC(ActionCatmullRomStacked); virtual ~ActionCatmullRomStacked(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); //cached data and callback Mat4 _modelViewMV1; @@ -476,13 +476,13 @@ public: CREATE_FUNC(ActionCardinalSplineStacked); virtual ~ActionCardinalSplineStacked(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags); virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); Mat4 _modelViewMV1; Mat4 _modelViewMV2; @@ -584,12 +584,12 @@ public: ~ActionCatmullRom(); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string subtitle() const override; virtual std::string title() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); Mat4 _modelViewMV1; Mat4 _modelViewMV2; @@ -606,12 +606,12 @@ public: ~ActionCardinalSpline(); virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string subtitle() const override; virtual std::string title() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); PointArray *_array; Mat4 _modelViewMV1; diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp index dafd39c8d4..5de4ba8bb6 100644 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp +++ b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.cpp @@ -137,14 +137,14 @@ void Box2DTestLayer::createResetButton() } -void Box2DTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Box2DTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // // IMPORTANT: // This is only for debug purposes // It is recommend to disable it // - Layer::draw(renderer, transform, transformUpdated); + Layer::draw(renderer, transform, flags); #if CC_ENABLE_BOX2D_INTEGRATION GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); diff --git a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h index 1109577a04..9a12dc7a13 100644 --- a/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h +++ b/tests/cpp-tests/Classes/Box2DTest/Box2dTest.h @@ -17,7 +17,7 @@ public: void initPhysics(); void createResetButton(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; void addNewSpriteAtPosition(Vec2 p); void update(float dt); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp index 28e0540835..dfadb55929 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.cpp @@ -202,16 +202,16 @@ std::string Box2DView::title() const return std::string(m_entry->name); } -void Box2DView::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Box2DView::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Layer::draw(renderer, transform, transformUpdated); + Layer::draw(renderer, transform, flags); _customCmd.init(_globalZOrder); - _customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, transformUpdated); + _customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this, transform, flags); renderer->addCommand(&_customCmd); } -void Box2DView::onDraw(const Mat4 &transform, bool transformUpdated) +void Box2DView::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h index 23446adbc9..0f484079e8 100644 --- a/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h +++ b/tests/cpp-tests/Classes/Box2DTestBed/Box2dView.h @@ -42,7 +42,7 @@ public: bool initWithEntryID(int entryId); std::string title() const; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; // virtual void registerWithTouchDispatcher(); bool onTouchBegan(Touch* touch, Event* event); @@ -55,7 +55,7 @@ public: static Box2DView* viewWithEntryID(int entryId); protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _customCmd; }; diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index c6ca186378..9e5aae0d4b 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -601,7 +601,7 @@ void RawStencilBufferTest::setup() Director::getInstance()->setAlphaBlending(true); } -void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { auto winPoint = Vec2(Director::getInstance()->getWinSize()); @@ -641,7 +641,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _modelViewTransform = this->transform(transform); - _spritesStencil.at(i)->visit(renderer, _modelViewTransform, transformUpdated); + _spritesStencil.at(i)->visit(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); iter->init(_globalZOrder); @@ -651,7 +651,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, bool director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); _modelViewTransform = this->transform(transform); - _sprites.at(i)->visit(renderer, _modelViewTransform, transformUpdated); + _sprites.at(i)->visit(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h index df93852059..cda23e9062 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -153,7 +153,7 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void setup(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void setupStencilForClippingOnPlane(GLint plane); virtual void setupStencilForDrawingOnPlane(GLint plane); diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 5687d00818..aa75920477 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -114,17 +114,16 @@ DrawPrimitivesTest::DrawPrimitivesTest() { } -void DrawPrimitivesTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void DrawPrimitivesTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void DrawPrimitivesTest::onDraw(const Mat4 &transform, bool transformUpdated) +void DrawPrimitivesTest::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); - CCASSERT(nullptr != director, "Director is null when seting matrix stack"); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); diff --git a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index a5c0041204..03b6e608c2 100644 --- a/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/tests/cpp-tests/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -27,10 +27,10 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _customCommand; }; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 03c7d031a1..89ee6992ad 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -842,7 +842,7 @@ void TestColliderDetector::onExit() ArmatureTestLayer::onExit(); } -void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); Director* director = Director::getInstance(); @@ -1065,14 +1065,14 @@ void TestColliderDetector::update(float delta) } } } -void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TestColliderDetector::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void TestColliderDetector::onDraw(const Mat4 &transform, bool transformUpdated) +void TestColliderDetector::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1106,15 +1106,15 @@ std::string TestBoundingBox::title() const { return "Test BoundingBox"; } -void TestBoundingBox::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TestBoundingBox::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void TestBoundingBox::onDraw(const Mat4 &transform, bool transformUpdated) +void TestBoundingBox::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 7d939d594a..227c77cd5c 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -211,7 +211,7 @@ public: virtual void onEnter() override; virtual void onExit() override; virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual void update(float delta); void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); @@ -270,8 +270,8 @@ public: virtual void onEnter() override; virtual std::string title() const override; virtual void update(float delta); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; - void onDraw(const Mat4 &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + void onDraw(const Mat4 &transform, uint32_t flags); void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); @@ -293,13 +293,13 @@ class TestBoundingBox : public ArmatureTestLayer public: virtual void onEnter() override; virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; cocostudio::Armature *armature; Rect rect; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _customCommand; }; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 6a7cf9c5fd..708a58e0ea 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -194,9 +194,9 @@ void SceneEditorTestLayer::backCallback(Ref *pSender) s->release(); } -void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void SceneEditorTestLayer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - Layer::draw(renderer, transform, transformUpdated); + Layer::draw(renderer, transform, flags); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 76a5ceedfa..b6d68a6593 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -43,7 +43,7 @@ public: virtual void nextCallback(cocos2d::Ref* pSender); virtual void backCallback(cocos2d::Ref* pSender); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: MenuItemImage *restartItem; diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp index 346395690b..a1a7df04c9 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp @@ -2,9 +2,9 @@ USING_NS_CC; -void CustomTableViewCell::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void CustomTableViewCell::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - TableViewCell::draw(renderer, transform, transformUpdated); + TableViewCell::draw(renderer, transform, flags); // draw bounding box // auto pos = getPosition(); // auto size = Size(178, 200); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h index 303a3b40bc..74555e1cd0 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.h @@ -7,7 +7,7 @@ class CustomTableViewCell : public cocos2d::extension::TableViewCell { public: - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override; + virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override; }; #endif /* __CUSTOMTABELVIEWCELL_H__ */ diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 331e262d60..2dc431e502 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -213,14 +213,14 @@ Atlas1::~Atlas1() _textureAtlas->release(); } -void Atlas1::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Atlas1::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void Atlas1::onDraw(const Mat4 &transform, bool transformUpdated) +void Atlas1::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -532,14 +532,14 @@ Atlas4::Atlas4() schedule( schedule_selector(Atlas4::step), 0.1f); } -void Atlas4::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void Atlas4::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void Atlas4::onDraw(const Mat4 &transform, bool transformUpdated) +void Atlas4::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1660,14 +1660,14 @@ std::string LabelBMFontBounds::subtitle() const return "You should see string enclosed by a box"; } -void LabelBMFontBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelBMFontBounds::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void LabelBMFontBounds::onDraw(const Mat4 &transform, bool transformUpdated) +void LabelBMFontBounds::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.h b/tests/cpp-tests/Classes/LabelTest/LabelTest.h index 40b2e74aee..68ac427bb5 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.h @@ -41,9 +41,9 @@ public: ~Atlas1(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); protected: CustomCommand _customCommand; }; @@ -108,12 +108,12 @@ public: Atlas4(); virtual void step(float dt); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); protected: CustomCommand _customCommand; }; @@ -383,11 +383,11 @@ public: LabelBMFontBounds(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); private: LabelBMFont *label1; CustomCommand _customCommand; diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index 2facddeafa..0d4dc898e6 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -62,7 +62,6 @@ static std::function createFunctions[] = CL(LabelTTFAlignmentNew), CL(LabelFNTBounds), CL(LabelTTFLongLineWrapping), - CL(LabelTTFLargeText), CL(LabelTTFColor), CL(LabelTTFFontsTestNew), CL(LabelTTFDynamicAlignment), @@ -309,15 +308,15 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() schedule( schedule_selector(LabelFNTSpriteActions::step), 0.1f); } -void LabelFNTSpriteActions::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelFNTSpriteActions::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void LabelFNTSpriteActions::onDraw(const Mat4 &transform, bool transformUpdated) +void LabelFNTSpriteActions::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -606,7 +605,7 @@ LabelTTFUnicodeChinese::LabelTTFUnicodeChinese() auto size = Director::getInstance()->getWinSize(); // Adding "啊" letter at the end of string to make VS2012 happy, otherwise VS will generate errors // like "Error 3 error C2146: syntax error : missing ')' before identifier 'label'"; - TTFConfig ttfConfig("fonts/wt021.ttf",28,GlyphCollection::CUSTOM, "美好的一天啊"); + TTFConfig ttfConfig("fonts/HKYuanMini.ttf",28,GlyphCollection::CUSTOM, "美好的一天啊"); auto label = Label::createWithTTF(ttfConfig,"美好的一天啊", TextHAlignment::CENTER, size.width); if(label) { @@ -908,14 +907,14 @@ std::string LabelFNTBounds::subtitle() const return "You should see string enclosed by a box"; } -void LabelFNTBounds::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelFNTBounds::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void LabelFNTBounds::onDraw(const Mat4 &transform, bool transformUpdated) +void LabelFNTBounds::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -962,30 +961,6 @@ std::string LabelTTFLongLineWrapping::subtitle() const return "Uses the new Label with TTF. Testing auto-wrapping"; } -LabelTTFLargeText::LabelTTFLargeText() -{ - auto size = Director::getInstance()->getWinSize(); - - // Long sentence - TTFConfig ttfConfig("fonts/wt021.ttf",18,GlyphCollection::DYNAMIC); - std::string text = FileUtils::getInstance()->getStringFromFile("commonly_used_words.txt"); - auto label = Label::createWithTTF(ttfConfig,text, TextHAlignment::CENTER, size.width); - if(label) { - label->setPosition( Vec2(size.width/2, size.height/2) ); - addChild(label); - } -} - -std::string LabelTTFLargeText::title() const -{ - return "New Label + .TTF"; -} - -std::string LabelTTFLargeText::subtitle() const -{ - return "Uses the new Label with TTF. Testing large text"; -} - LabelTTFColor::LabelTTFColor() { auto size = Director::getInstance()->getWinSize(); @@ -1093,7 +1068,7 @@ LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest() Vec2(size.width * 0.85, size.height * 0.8), Vec2(size.width * 0.85, 0), 1, Color4F(1, 0, 0, 1)); - TTFConfig ttfConfig("fonts/wt021.ttf", 25, GlyphCollection::DYNAMIC); + TTFConfig ttfConfig("fonts/HKYuanMini.ttf", 25, GlyphCollection::DYNAMIC); auto label1 = Label::createWithTTF(ttfConfig, "你好,Cocos2d-x v3的New Label.", TextHAlignment::LEFT, size.width * 0.75); if(label1) { @@ -1162,7 +1137,7 @@ LabelTTFUnicodeNew::LabelTTFUnicodeNew() addChild(label2); // chinese - ttfConfig.fontFilePath = "fonts/wt021.ttf"; + ttfConfig.fontFilePath = "fonts/HKYuanMini.ttf"; ttfConfig.glyphs = GlyphCollection::CUSTOM; ttfConfig.customGlyphs = chinese.c_str(); auto label3 = Label::createWithTTF(ttfConfig,chinese, TextHAlignment::CENTER,size.width); @@ -1533,7 +1508,7 @@ LabelTTFOldNew::LabelTTFOldNew() label2->setPosition(Vec2(s.width/2, delta * 2)); } -void LabelTTFOldNew::onDraw(const Mat4 &transform, bool transformUpdated) +void LabelTTFOldNew::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1577,10 +1552,10 @@ void LabelTTFOldNew::onDraw(const Mat4 &transform, bool transformUpdated) director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } -void LabelTTFOldNew::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void LabelTTFOldNew::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(LabelTTFOldNew::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index beb1fc816d..a79942b18a 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -58,14 +58,14 @@ public: LabelFNTSpriteActions(); virtual void step(float dt); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); }; class LabelFNTPadding : public AtlasDemoNew @@ -224,13 +224,13 @@ public: LabelFNTBounds(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); Label *label1; }; @@ -430,25 +430,14 @@ public: LabelTTFOldNew(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string title() const override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); -}; - -class LabelTTFLargeText : public AtlasDemoNew -{ -public: - CREATE_FUNC(LabelTTFLargeText); - - LabelTTFLargeText(); - - virtual std::string title() const override; - virtual std::string subtitle() const override; + void onDraw(const Mat4 &transform, uint32_t flags); }; class LabelFontNameTest : public AtlasDemoNew diff --git a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp index 2dd971a644..1c42b0a106 100644 --- a/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/cpp-tests/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -17,7 +17,7 @@ public: setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { DrawPrimitives::setDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255); glLineWidth(10); diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp index 3d60198ace..cd12b46e95 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp @@ -231,7 +231,7 @@ protected: public: static SpriteInGroupCommand* create(const std::string& filename); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; }; SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) @@ -242,13 +242,13 @@ SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) return sprite; } -void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { CCASSERT(renderer, "Render is null"); _spriteWrapperCommand.init(_globalZOrder); renderer->addCommand(&_spriteWrapperCommand); renderer->pushGroup(_spriteWrapperCommand.getRenderQueueID()); - Sprite::draw(renderer, transform, transformUpdated); + Sprite::draw(renderer, transform, flags); renderer->popGroup(); } diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 868f9a6c57..ec681eb5af 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -72,6 +72,8 @@ static std::function createFunctions[] = CL(NodeOpaqueTest), CL(NodeNonOpaqueTest), CL(NodeGlobalZValueTest), + CL(NodeNormalizedPositionTest1), + CL(NodeNormalizedPositionTest2), }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -993,22 +995,22 @@ public: sprite->setGLProgramState(shaderState); return sprite; } - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; - void onDraw(const Mat4 &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + void onDraw(const Mat4 &transform, uint32_t flags); protected: CustomCommand _customCommand; }; -void MySprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void MySprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void MySprite::onDraw(const Mat4 &transform, bool transformUpdated) +void MySprite::onDraw(const Mat4 &transform, uint32_t flags) { getGLProgram()->use(); getGLProgram()->setUniformsForBuiltins(transform); @@ -1087,6 +1089,7 @@ std::string CameraTest1::subtitle() const { return "Both images should rotate with a 3D effect"; } + //------------------------------------------------------------------ // // CameraTest2 @@ -1143,6 +1146,91 @@ std::string CameraTest2::subtitle() const return "Both images should look the same"; } +//------------------------------------------------------------------ +// +// NodeNormalizedPositionTest1 +// +//------------------------------------------------------------------ +NodeNormalizedPositionTest1::NodeNormalizedPositionTest1() +{ + Sprite *sprites[5]; + Vec2 positions[5]; + positions[0] = Vec2(0,0); + positions[1] = Vec2(0,1); + positions[2] = Vec2(0.5,0.5); + positions[3] = Vec2(1,0); + positions[4] = Vec2(1,1); + + for(int i=0; i<5; i++) { + sprites[i] = Sprite::create("Images/grossini.png"); + sprites[i]->setNormalizedPosition(positions[i]); + addChild(sprites[i]); + } +} + +std::string NodeNormalizedPositionTest1::title() const +{ + return "setNormalizedPositon()"; +} + +std::string NodeNormalizedPositionTest1::subtitle() const +{ + return "5 sprites: One in the center, the others on the corners"; +} + +//------------------------------------------------------------------ +// +// NodeNormalizedPositionTest2 +// +//------------------------------------------------------------------ +NodeNormalizedPositionTest2::NodeNormalizedPositionTest2() +: _accum(0) +{ + Sprite *sprites[5]; + Vec2 positions[5]; + positions[0] = Vec2(0,0); + positions[1] = Vec2(0,1); + positions[2] = Vec2(0.5,0.5); + positions[3] = Vec2(1,0); + positions[4] = Vec2(1,1); + + for(int i=0; i<5; i++) { + sprites[i] = Sprite::create("Images/grossini.png"); + sprites[i]->setNormalizedPosition(positions[i]); + addChild(sprites[i]); + } + scheduleUpdate(); + + setContentSize( Director::getInstance()->getWinSize()); + _copyContentSize = getContentSize(); + +// setAnchorPoint(Vec2(0.5,0.5)); +// setNormalizedPosition(Vec2(0.5,0.5)); +} + +std::string NodeNormalizedPositionTest2::title() const +{ + return "setNormalizedPositon() #2"; +} + +std::string NodeNormalizedPositionTest2::subtitle() const +{ + return "5 sprites: One in the center, the others on the corners of its parents"; +} + +void NodeNormalizedPositionTest2::update(float dt) +{ + _accum += dt; + + // for 5 seconds + float norm = sinf(_accum); + + Size s = Size(_copyContentSize.width*norm, _copyContentSize.height*norm); + setContentSize(s); + + CCLOG("s: %f,%f", s.width, s.height); +} + /// /// main /// diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 2d92576e37..6e8c9c7fef 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -269,6 +269,35 @@ protected: Sprite *_sprite; }; +class NodeNormalizedPositionTest1 : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeNormalizedPositionTest1); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: + NodeNormalizedPositionTest1(); +}; + +class NodeNormalizedPositionTest2 : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeNormalizedPositionTest2); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: + NodeNormalizedPositionTest2(); + + void update(float dt); + Size _copyContentSize; + float _accum; +}; + + + +// main class CocosNodeTestScene : public TestScene { public: diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index d96cecd29b..e78a9b133b 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -1841,9 +1841,7 @@ std::string PremultipliedAlphaTest::subtitle() const void PremultipliedAlphaTest::readdPaticle(float delta) { - static int count = 0; - - if (count++ % 2 == 0) + if (_hasEmitter) { _emitter->removeFromParent(); } @@ -1851,6 +1849,8 @@ void PremultipliedAlphaTest::readdPaticle(float delta) { this->addChild(_emitter); } + + _hasEmitter = !_hasEmitter; } void PremultipliedAlphaTest::onEnter() @@ -1880,6 +1880,7 @@ void PremultipliedAlphaTest::onEnter() _emitter->setEndColorVar(Color4F(0.0f, 0.0f, 0.0f, 0.0f)); this->addChild(_emitter, 10); + _hasEmitter = true; schedule(schedule_selector(PremultipliedAlphaTest::readdPaticle), 1.0f); } diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h index 19e511c82f..ba3adb9058 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h @@ -287,6 +287,7 @@ private: class PremultipliedAlphaTest : public ParticleDemo { + bool _hasEmitter; public: virtual void onEnter() override; void readdPaticle(float delta); diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index 8dd67b948a..81bb2afe37 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -20,6 +20,7 @@ namespace CL(PhysicsContactTest), CL(PhysicsPositionRotationTest), CL(PhysicsSetGravityEnableTest), + CL(Bug5482), #else CL(PhysicsDemoDisabled), #endif @@ -1569,9 +1570,9 @@ void PhysicsPositionRotationTest::onEnter() anchorNode->setAnchorPoint(Vec2(0.1f, 0.9f)); anchorNode->setPosition(100, 100); anchorNode->setScale(0.25); + addChild(anchorNode); anchorNode->setPhysicsBody(PhysicsBody::createBox(anchorNode->getContentSize()*anchorNode->getScale())); anchorNode->getPhysicsBody()->setTag(DRAG_BODYS_TAG); - addChild(anchorNode); //parent test auto parent = Sprite::create("Images/YellowSquare.png"); @@ -1660,4 +1661,68 @@ std::string PhysicsSetGravityEnableTest::subtitle() const return "only yellow box drop down"; } +void Bug5482::onEnter() +{ + PhysicsDemo::onEnter(); + + _scene->toggleDebug(); + + auto touchListener = EventListenerTouchOneByOne::create(); + touchListener->onTouchBegan = CC_CALLBACK_2(PhysicsDemo::onTouchBegan, this); + touchListener->onTouchMoved = CC_CALLBACK_2(PhysicsDemo::onTouchMoved, this); + touchListener->onTouchEnded = CC_CALLBACK_2(PhysicsDemo::onTouchEnded, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + + _bodyInA = false; + + // wall + auto wall = Node::create(); + wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1.0f, 0.0f))); + wall->setPosition(VisibleRect::center()); + addChild(wall); + + //button + MenuItemFont::setFontSize(18); + _button = MenuItemFont::create("Set Body To A", CC_CALLBACK_1(Bug5482::changeBodyCallback, this)); + + auto menu = Menu::create(_button, nullptr); + this->addChild(menu); + + _nodeA = Sprite::create("Images/YellowSquare.png"); + _nodeA->setPosition(VisibleRect::center().x - 150, 100); + this->addChild(_nodeA); + + _nodeB = Sprite::create("Images/YellowSquare.png"); + _nodeB->setPosition(VisibleRect::center().x + 150, 100); + this->addChild(_nodeB); + + _body = PhysicsBody::createBox(_nodeA->getContentSize()); + _body->setTag(DRAG_BODYS_TAG); + _body->retain(); +} + +void Bug5482::onExit() +{ + _body->release(); +} + +void Bug5482::changeBodyCallback(Ref* sender) +{ + Sprite* node = _bodyInA ? _nodeB : _nodeA; + + node->setPhysicsBody(_body); + + _bodyInA = !_bodyInA; +} + +std::string Bug5482::title() const +{ + return "bug 5482: setPhysicsBodyTest"; +} + +std::string Bug5482::subtitle() const +{ + return "change physics body to the other."; +} + #endif // ifndef CC_USE_PHYSICS diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h index 9e8fc8f01b..e32a1ebf16 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.h @@ -236,6 +236,25 @@ public: virtual std::string subtitle() const override; }; +class Bug5482 : public PhysicsDemo +{ +public: + CREATE_FUNC(Bug5482); + + void onEnter() override; + void onExit() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void changeBodyCallback(Ref* sender); +private: + Sprite* _nodeA; + Sprite* _nodeB; + PhysicsBody* _body; + MenuItemFont* _button; + bool _bodyInA; +}; + #endif #endif diff --git a/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp b/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp index 14e9b8dc6a..70e54dbc49 100644 --- a/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp +++ b/tests/cpp-tests/Classes/ReleasePoolTest/ReleasePoolTest.cpp @@ -75,6 +75,11 @@ void ReleasePoolTestScene::runThisTest() } // object in pool2 should be released + + { + new AutoreleasePool; + PoolManager::destroyInstance(); + } Director::getInstance()->replaceScene(this); } diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp index b86d503ba8..406514ff4b 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -515,7 +515,7 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil() CC_SAFE_RELEASE(_spriteDS); } -void RenderTextureTestDepthStencil::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void RenderTextureTestDepthStencil::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmds[0].init(_globalZOrder); _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this); @@ -685,7 +685,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea return sprite; } -void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { if (_rt == nullptr) { @@ -696,7 +696,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw(Renderer *renderer, const Mat4 & _rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f); _rt->end(); - Sprite::draw(renderer, transform, transformUpdated); + Sprite::draw(renderer, transform, flags); } diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h index dc2fd9db86..579dd414de 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -85,7 +85,7 @@ public: virtual ~RenderTextureTestDepthStencil(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; private: CustomCommand _renderCmds[4]; void onBeforeClear(); @@ -139,7 +139,7 @@ public: static SimpleSprite* create(const char* filename, const Rect &rect); SimpleSprite(); ~SimpleSprite(); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated); + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags); public: RenderTexture *_rt; }; diff --git a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp index 273fcf30c5..715bc91a87 100644 --- a/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp +++ b/tests/cpp-tests/Classes/SceneTest/SceneTest.cpp @@ -200,7 +200,8 @@ void SceneTestLayer3::testDealloc(float dt) void SceneTestLayer3::item0Clicked(Ref* sender) { - auto newScene = Scene::create(); + auto s = Director::getInstance()->getWinSize(); + auto newScene = Scene::createWithSize(s); newScene->addChild(SceneTestLayer3::create()); Director::getInstance()->pushScene(TransitionFade::create(0.5, newScene, Color3B(0,255,255))); } diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp index cf62c50397..33fae8fb89 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.cpp @@ -28,7 +28,8 @@ static std::function createFunctions[] = { CL(RescheduleSelector), CL(SchedulerDelayAndRepeat), CL(SchedulerIssue2268), - CL(ScheduleCallbackTest) + CL(ScheduleCallbackTest), + CL(ScheduleUpdatePriority) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -1148,6 +1149,47 @@ void ScheduleCallbackTest::callback(float dt) log("In the callback of schedule(CC_CALLBACK_1(XXX::member_function), this), this, ...), dt = %f", dt); } + +// ScheduleUpdatePriority + +std::string ScheduleUpdatePriority::title() const +{ + return "ScheduleUpdatePriorityTest"; +} + +std::string ScheduleUpdatePriority::subtitle() const +{ + return "click to change update priority with random value"; +} + +bool ScheduleUpdatePriority::onTouchBegan(Touch* touch, Event* event) +{ + int priority = static_cast(CCRANDOM_0_1() * 11) - 5; // -5 ~ 5 + CCLOG("change update priority to %d", priority); + scheduleUpdateWithPriority(priority); + return true; +} + +void ScheduleUpdatePriority::onEnter() +{ + SchedulerTestLayer::onEnter(); + + scheduleUpdate(); + + auto listener = EventListenerTouchOneByOne::create(); + listener->onTouchBegan = CC_CALLBACK_2(ScheduleUpdatePriority::onTouchBegan, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +} + +void ScheduleUpdatePriority::onExit() +{ + unscheduleUpdate(); +} + +void ScheduleUpdatePriority::update(float dt) +{ +} + //------------------------------------------------------------------ // // SchedulerTestScene diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h index 57efb807a9..5728f46a3a 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h @@ -302,6 +302,21 @@ public: private: }; +class ScheduleUpdatePriority : public SchedulerTestLayer +{ +public: + CREATE_FUNC(ScheduleUpdatePriority); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void onEnter(); + void onExit(); + + virtual void update(float dt); + + bool onTouchBegan(Touch* touch, Event* event); +}; + class SchedulerTestScene : public TestScene { public: diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index b8c2cc8237..9aa84d87e0 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -193,14 +193,14 @@ void ShaderNode::setPosition(const Vec2 &newPosition) getGLProgramState()->setUniformVec2("center", _center); } -void ShaderNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void ShaderNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _customCommand.init(_globalZOrder); - _customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this, transform, transformUpdated); + _customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this, transform, flags); renderer->addCommand(&_customCommand); } -void ShaderNode::onDraw(const Mat4 &transform, bool transformUpdated) +void ShaderNode::onDraw(const Mat4 &transform, uint32_t flags) { float w = SIZE_X, h = SIZE_Y; GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h}; @@ -732,7 +732,7 @@ bool ShaderGlow::init() // // ShaderMultiTexture // -ShaderMultiTexture::ShaderMultiTexture() +ShaderMultiTexture::ShaderMultiTexture():_changedTextureId(0) { init(); } @@ -785,27 +785,31 @@ bool ShaderMultiTexture::init() // Right: normal sprite auto right = Sprite::create("Images/grossinis_sister2.png"); - addChild(right); + addChild(right, 0, rightSpriteTag); right->setPosition(s.width*3/4, s.height/2); // Center: MultiTexture - _sprite = Sprite::create("Images/grossinis_sister1.png"); - Texture2D *texture1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png"); - + _sprite = Sprite::createWithTexture(left->getTexture()); addChild(_sprite); - _sprite->setPosition(Vec2(s.width/2, s.height/2)); auto glprogram = GLProgram::createWithFilenames("Shaders/example_MultiTexture.vsh", "Shaders/example_MultiTexture.fsh"); auto glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); _sprite->setGLProgramState(glprogramstate); - glprogramstate->setUniformTexture("u_texture1", texture1); + glprogramstate->setUniformTexture("u_texture1", right->getTexture()); glprogramstate->setUniformFloat("u_interpolate",0.5); // slider createSliderCtl(); + + // menu + auto label = Label::createWithTTF(TTFConfig("fonts/arial.ttf"), "change"); + auto mi = MenuItemLabel::create(label, CC_CALLBACK_1(ShaderMultiTexture::changeTexture, this)); + auto menu = Menu::create(mi, nullptr); + addChild(menu); + menu->setPosition(s.width * 7 / 8, s.height / 2); return true; } @@ -813,6 +817,21 @@ bool ShaderMultiTexture::init() return false; } +void ShaderMultiTexture::changeTexture(Ref*) +{ + static const int textureFilesCount = 3; + static const std::string textureFiles[textureFilesCount] = { + "Images/grossini.png", + "Images/grossinis_sister1.png", + "Images/grossinis_sister2.png" + }; + auto textrue = Director::getInstance()->getTextureCache()->addImage(textureFiles[_changedTextureId++ % textureFilesCount]); + Sprite* right = dynamic_cast(getChildByTag(rightSpriteTag)); + right->setTexture(textrue); + auto programState = _sprite->getGLProgramState(); + programState->setUniformTexture("u_texture1", right->getTexture()); +} + ///--------------------------------------- // diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h index 8e8f7d84c3..798466dae1 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.h @@ -119,7 +119,7 @@ public: virtual void update(float dt); virtual void setPosition(const Vec2 &newPosition); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: ShaderNode(); @@ -128,7 +128,7 @@ protected: bool initWithVertex(const std::string &vert, const std::string &frag); void loadShaderVertex(const std::string &vert, const std::string &frag); - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); Vec2 _center; Vec2 _resolution; @@ -166,9 +166,12 @@ public: class ShaderMultiTexture : public ShaderTestDemo { + static const int rightSpriteTag = 2014; public: ShaderMultiTexture(); ui::Slider* createSliderCtl(); + void changeTexture(Ref*); + int _changedTextureId; Sprite *_sprite; virtual std::string title() const override; diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index a697277c78..dfd250e781 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -148,10 +148,10 @@ public: std::sort(std::begin(_effects), std::end(_effects), tuple_sort); } - void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override + void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override { // Don't do calculate the culling if the transform was not updated - _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; + _insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; if(_insideBounds) { @@ -207,13 +207,43 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename) auto fragmentFullPath = fileUtiles->fullPathForFilename(fragmentFilename); auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str()); - + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _fragSource = fragSource; +#endif + _glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); _glprogramstate->retain(); return _glprogramstate != nullptr; } +Effect::Effect() +: _glprogramstate(nullptr) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _backgroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, + [this](EventCustom*) + { + auto glProgram = _glprogramstate->getGLProgram(); + glProgram->reset(); + glProgram->initWithByteArrays(ccPositionTextureColor_noMVP_vert, _fragSource.c_str()); + glProgram->link(); + glProgram->updateUniforms(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backgroundListener, -1); +#endif +} + +Effect::~Effect() +{ + CC_SAFE_RELEASE_NULL(_glprogramstate); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backgroundListener); +#endif +} + // Blur class EffectBlur : public Effect { diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index 2d7421fa80..0de6babe69 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -37,10 +37,13 @@ public: protected: bool initGLProgramState(const std::string &fragmentFilename); - Effect() : _glprogramstate(nullptr) - {} - virtual ~Effect() {} + Effect(); + virtual ~Effect(); GLProgramState *_glprogramstate; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + std::string _fragSource; + EventListenerCustom* _backgroundListener; +#endif }; class EffectSpriteTest : public ShaderTestDemo2 diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index a2eb9450c3..9ac518548c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -300,7 +300,7 @@ Effect3DOutline* Effect3DOutline::create() bool Effect3DOutline::init() { - GLProgram* glprogram = Effect3DOutline::getOrCreateProgram(); + GLProgram* glprogram = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile); if(nullptr == glprogram) { CC_SAFE_DELETE(glprogram); @@ -323,12 +323,27 @@ Effect3DOutline::Effect3DOutline() , _outlineColor(1, 1, 1) , _sprite(nullptr) { - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + _backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, + [this](EventCustom*) + { + auto glProgram = _glProgramState->getGLProgram(); + glProgram->reset(); + glProgram->initWithFilenames(_vertShaderFile, _fragShaderFile); + glProgram->link(); + glProgram->updateUniforms(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); +#endif } Effect3DOutline::~Effect3DOutline() { CC_SAFE_RELEASE_NULL(_sprite); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); +#endif } void Effect3DOutline::setOutlineColor(const Vec3& color) @@ -404,7 +419,7 @@ void Effect3DOutline::draw(const Mat4 &transform) } } -void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) +void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) { for(auto &effect : _effects) { @@ -418,7 +433,7 @@ void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &tran if(!_defaultEffect) { - Sprite3D::draw(renderer, transform, transformUpdated); + Sprite3D::draw(renderer, transform, flags); } else { diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index bc89dfd671..67a4671915 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -98,6 +98,9 @@ protected: Vec3 _outlineColor; float _outlineWidth; EffectSprite3D* _sprite; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + EventListenerCustom* _backToForegroundListener; +#endif protected: static const std::string _vertShaderFile; @@ -112,7 +115,7 @@ public: static EffectSprite3D* createFromObjFileAndTexture(const std::string& objFilePath, const std::string& textureFilePath); void setEffect3D(Effect3D* effect); void addEffect(Effect3DOutline* effect, ssize_t order); - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: EffectSprite3D(); virtual ~EffectSprite3D(); diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp index 02e3509ca1..8df33583ba 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp @@ -261,6 +261,27 @@ void TexturePNG::onEnter() img->setPosition(Vec2( s.width/2.0f, s.height/2.0f)); addChild(img); log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str()); + + // Test PNG files with different pixel formats + // grayscale without alpha + auto i8 = Sprite::create("Images/test_image_i8.png"); + i8->setPosition(s.width/4.0f, s.height/4.0f); + addChild(i8); + + // grayscale with alpha + auto ai88 = Sprite::create("Images/test_image_ai88.png"); + ai88->setPosition(s.width / 4.0f, s.height * 3.0f / 4.0f); + addChild(ai88); + + // rgb without alpha + auto rgb888 = Sprite::create("Images/test_image_rgb888.png"); + rgb888->setPosition(s.width * 3.0f / 4.0f, s.height / 4.0f); + addChild(rgb888); + + // rgba with alpha + auto rgba8888 = Sprite::create("Images/test_image_rgba8888.png"); + rgba8888->setPosition(s.width * 3.0f / 4.0f, s.height * 3.0f / 4.0f); + addChild(rgba8888); } std::string TexturePNG::title() const @@ -268,6 +289,11 @@ std::string TexturePNG::title() const return "PNG Test"; } +std::string TexturePNG::subtitle() const +{ + return "LB:I8, LT:AI8\nRB:RGB888, RT: RGBA8888"; +} + //------------------------------------------------------------------ // // TextureJPEG @@ -1794,17 +1820,17 @@ std::string TextureDrawAtPoint::subtitle() const return "draws 2 textures using drawAtPoint"; } -void TextureDrawAtPoint::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TextureDrawAtPoint::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - TextureDemo::draw(renderer, transform, transformUpdated); + TextureDemo::draw(renderer, transform, flags); _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void TextureDrawAtPoint::onDraw(const Mat4 &transform, bool transformUpdated) +void TextureDrawAtPoint::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1837,16 +1863,16 @@ TextureDrawInRect::~TextureDrawInRect() _Tex2F->release(); } -void TextureDrawInRect::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TextureDrawInRect::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - TextureDemo::draw(renderer, transform, transformUpdated); + TextureDemo::draw(renderer, transform, flags); _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void TextureDrawInRect::onDraw(const Mat4 &transform, bool transformUpdated) +void TextureDrawInRect::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1960,10 +1986,10 @@ void TextureMemoryAlloc::updateImage(cocos2d::Ref *sender) file = "Images/fire_rgba8888.pvr"; break; case 2: - file = "Images/grossini_prv_rgba8888.pvr"; + file = "Images/grossini_pvr_rgba8888.pvr"; break; case 3: - file = "Images/grossini_prv_rgba4444.pvr"; + file = "Images/grossini_pvr_rgba4444.pvr"; break; case 4: file = "Images/test_image_a8.pvr"; diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h index 814b2f01ba..2190dfbcd3 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h @@ -65,6 +65,7 @@ class TexturePNG : public TextureDemo public: CREATE_FUNC(TexturePNG); virtual std::string title() const override; + virtual std::string subtitle() const override; virtual void onEnter() override; }; @@ -465,9 +466,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _renderCmd; Texture2D* _tex1, *_Tex2F; @@ -481,9 +482,9 @@ public: virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter() override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); CustomCommand _renderCmd; Texture2D* _tex1, *_Tex2F; diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp index 8a129a3f93..016d5da895 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.cpp @@ -759,14 +759,14 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() CCLOG("%s", objectsVal.getDescription().c_str()); } -void TMXOrthoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TMXOrthoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void TMXOrthoObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) +void TMXOrthoObjectsTest::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -834,14 +834,14 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() CCLOG("%s", objectsVal.getDescription().c_str()); } -void TMXIsoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TMXIsoObjectsTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void TMXIsoObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) +void TMXIsoObjectsTest::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); @@ -1523,14 +1523,14 @@ TMXGIDObjectsTest::TMXGIDObjectsTest() } -void TMXGIDObjectsTest::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) +void TMXGIDObjectsTest::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { _renderCmd.init(_globalZOrder); - _renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this, transform, transformUpdated); + _renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this, transform, flags); renderer->addCommand(&_renderCmd); } -void TMXGIDObjectsTest::onDraw(const Mat4 &transform, bool transformUpdated) +void TMXGIDObjectsTest::onDraw(const Mat4 &transform, uint32_t flags) { Director* director = Director::getInstance(); CCASSERT(nullptr != director, "Director is null when seting matrix stack"); diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h index be8f3ec5ab..d2621fdd07 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest.h @@ -134,11 +134,11 @@ public: TMXOrthoObjectsTest(void); virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); }; class TMXIsoObjectsTest : public TileDemo @@ -147,11 +147,11 @@ public: TMXIsoObjectsTest(void); virtual std::string title() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; virtual std::string subtitle() const override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); }; class TMXResizeTest : public TileDemo @@ -292,11 +292,11 @@ public: TMXGIDObjectsTest(); virtual std::string title() const override; virtual std::string subtitle() const override; - virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override; + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; protected: CustomCommand _renderCmd; - void onDraw(const Mat4 &transform, bool transformUpdated); + void onDraw(const Mat4 &transform, uint32_t flags); }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp index fc78edbcec..7f3e2af5ea 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp @@ -1,6 +1,7 @@ #include "CustomImageView.h" +#include "2d/CCNode.h" USING_NS_CC; using namespace ui; @@ -48,7 +49,7 @@ void CustomImageView::initRenderer() ImageView::initRenderer(); _label = Label::create(); - CCNodeRGBA::addChild(_label, getLocalZOrder() + 1, -1); + ProtectedNode::addChild(_label, getLocalZOrder() + 1, -1); } void CustomImageView::setText(const std::string &text) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp index cfc0dee635..7e9aacd47c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp @@ -7,6 +7,8 @@ // #include "CustomParticleWidget.h" +#include "2d/CCParticleSystem.h" +#include "2d/CCParticleSystemQuad.h" USING_NS_CC; using namespace ui; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h index 1714e04a8a..0ff54f74d3 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h @@ -11,6 +11,10 @@ #include "ui/CocosGUI.h" +namespace cocos2d { + class ParticleSystem; +} + class CustomParticleWidget : public cocos2d::ui::Widget { public: diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index c826f9c8e5..d0ae96f33c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -74,9 +74,9 @@ static const char* s_testArray[] = "UITextAtlasTest", "UITextTest", "UITextTest_LineWrap", - /* + "UILabelTest_Effect", - */ + "UITextTest_TTF", "UITextBMFontTest", "UITextFieldTest", @@ -275,10 +275,10 @@ Scene *UISceneManager::currentUIScene() case kUITextTest_LineWrap: return UITextTest_LineWrap::sceneWithTitle(s_testArray[_currentUISceneId]); - /* + case kUILabelTest_Effect: return UILabelTest_Effect::sceneWithTitle(s_testArray[_currentUISceneId]); - */ + case kUITextTest_TTF: return UITextTest_TTF::sceneWithTitle(s_testArray[_currentUISceneId]); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index cdc551b0b4..8afdc9a83c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -64,9 +64,8 @@ enum kUITextAtlasTest, kUITextTest, kUITextTest_LineWrap, - /* + kUILabelTest_Effect, - */ kUITextTest_TTF, kUITextBMFontTest, kUITextFieldTest, diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index d64ba12a10..1857624525 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -54,7 +54,7 @@ bool UITextTest_LineWrap::init() // UILabelTest_Effect -/* + bool UILabelTest_Effect::init() { if (UIScene::init()) @@ -62,7 +62,7 @@ bool UILabelTest_Effect::init() Size widgetSize = _widget->getSize(); Text* alert = Text::create(); - alert->setText("Label Effect"); + alert->setString("Label Effect"); alert->setFontName("fonts/Marker Felt.ttf"); alert->setFontSize(30); alert->setColor(Color3B(159, 168, 176)); @@ -73,83 +73,40 @@ bool UILabelTest_Effect::init() // create the shadow only label Text* shadow_label = Text::create(); - Color3B tintColorRed = { 255, 0, 0 }; - Size shadowOffset(12.0f, 12.0f); - - FontDefinition shadowTextDef; - shadowTextDef._fontSize = 20; - shadowTextDef._fontName = std::string("fonts/Marker Felt.ttf"); - - shadowTextDef._shadow._shadowEnabled = true; - shadowTextDef._shadow._shadowOffset = shadowOffset; - shadowTextDef._shadow._shadowOpacity = 1.0f; - shadowTextDef._shadow._shadowBlur = 1.0f; - shadowTextDef._fontFillColor = tintColorRed; - - shadow_label->setTextDefinition(shadowTextDef); - shadow_label->setText("Shadow"); + shadow_label->enableShadow(); + shadow_label->setString("Shadow"); shadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + shadow_label->getSize().height)); _uiLayer->addChild(shadow_label); // create the stroke only label - Text* stroke_label = Text::create(); + Text* glow_label = Text::create(); + glow_label->setFontName("fonts/Marker Felt.ttf"); + + glow_label->setString("Glow"); + glow_label->enableGlow(Color4B::RED); + - Color3B tintColorYellow = { 255, 255, 0 }; - Color3B strokeColor = { 0, 10, 255 }; + glow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - FontDefinition strokeTextDef; - strokeTextDef._fontSize = 20; - strokeTextDef._fontName = std::string("fonts/Marker Felt.ttf"); - - strokeTextDef._stroke._strokeEnabled = true; - strokeTextDef._stroke._strokeColor = strokeColor; - strokeTextDef._stroke._strokeSize = 1.5f; - - strokeTextDef._fontFillColor = tintColorYellow; - - stroke_label->setTextDefinition(strokeTextDef); - stroke_label->setText("Stroke"); - stroke_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - - _uiLayer->addChild(stroke_label); + _uiLayer->addChild(glow_label); // create the label stroke and shadow - Text* strokeAndShadow_label = Text::create(); + Text* outline_label = Text::create(); + outline_label->enableOutline(Color4B::BLUE, 2); + outline_label->setString("Outline"); + outline_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getSize().height)); - Color3B tintColorBlue = { 0, 0, 255 }; - Color3B strokeShadowColor = { 255, 0, 0 }; - - FontDefinition strokeShaodwTextDef; - strokeShaodwTextDef._fontSize = 20; - strokeShaodwTextDef._fontName = std::string("fonts/Marker Felt.ttf"); - - strokeShaodwTextDef._stroke._strokeEnabled = true; - strokeShaodwTextDef._stroke._strokeColor = strokeShadowColor; - strokeShaodwTextDef._stroke._strokeSize = 1.5f; - - strokeShaodwTextDef._shadow._shadowEnabled = true; - strokeShaodwTextDef._shadow._shadowOffset = shadowOffset; - strokeShaodwTextDef._shadow._shadowOpacity = 1.0f; - strokeShaodwTextDef._shadow._shadowBlur = 1.0f; - - strokeShaodwTextDef._fontFillColor = tintColorBlue; - - strokeAndShadow_label->setTextDefinition(strokeShaodwTextDef); -// strokeAndShadow_label->setFontFillColor(tintColorRed); - strokeAndShadow_label->setText("Stroke and Shadow"); - strokeAndShadow_label->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - shadow_label->getSize().height)); - - _uiLayer->addChild(strokeAndShadow_label); + _uiLayer->addChild(outline_label); return true; } return false; } - */ + // UITextTest_TTF diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h index 8f8742ea65..0ae1f8e73e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h @@ -45,7 +45,7 @@ protected: UI_SCENE_CREATE_FUNC(UITextTest_LineWrap) }; -/* + class UILabelTest_Effect : public UIScene { public: @@ -54,7 +54,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UILabelTest_Effect) }; - */ + class UITextTest_TTF : public UIScene { diff --git a/tests/cpp-tests/Resources/commonly_used_words.txt b/tests/cpp-tests/Resources/commonly_used_words.txt deleted file mode 100755 index ede487b2c8..0000000000 --- a/tests/cpp-tests/Resources/commonly_used_words.txt +++ /dev/null @@ -1,60 +0,0 @@ -三画 -三于干亏士工土才寸下大丈与万上小口巾山千乞川亿个勺久凡及夕丸么广 -亡门义之尸弓己已子卫也女飞刃习叉马乡 - -四画 -丰王井开夫天无元专云扎艺木五支厅不太犬区历尤友匹车巨牙屯比互切瓦 -止少日中冈贝内水见午牛手毛气升长仁什片仆化仇币仍仅斤爪反介父从今 -凶分乏公仓月氏勿欠风丹匀乌凤勾文六方火为斗忆订计户认心尺引丑巴孔 -队办以允予劝双书幻 - -五画 -玉刊示末未击打巧正扑扒功扔去甘世古节本术可丙左厉右石布龙平灭轧东 -卡北占业旧帅归且旦目叶甲申叮电号田由史只央兄叼叫另叨叹四生失禾丘 -付仗代仙们仪白仔他斥瓜乎丛令用甩印乐句匆册犯外处冬鸟务包饥主市立 -闪兰半汁汇头汉宁穴它讨写让礼训必议讯记永司尼民出辽奶奴加召皮边发 -孕圣对台矛纠母幼丝 - -六画 -式刑动扛寺吉扣考托老执巩圾扩扫地扬场耳共芒亚芝朽朴机权过臣再协西 -压厌在有百存而页匠夸夺灰达列死成夹轨邪划迈毕至此贞师尘尖劣光当早 -吐吓虫曲团同吊吃因吸吗屿帆岁回岂刚则肉网年朱先丢舌竹迁乔伟传乒乓 -休伍伏优伐延件任伤价份华仰仿伙伪自血向似后行舟全会杀合兆企众爷伞 -创肌朵杂危旬旨负各名多争色壮冲冰庄庆亦刘齐交次衣产决充妄闭问闯羊 -并关米灯州汗污江池汤忙兴宇守宅字安讲军许论农讽设访寻那迅尽导异孙 -阵阳收阶阴防奸如妇好她妈戏羽观欢买红纤级约纪驰巡 - -七画 -寿弄麦形进戒吞远违运扶抚坛技坏扰拒找批扯址走抄坝贡攻赤折抓扮抢孝 -均抛投坟抗坑坊抖护壳志扭块声把报却劫芽花芹芬苍芳严芦劳克苏杆杠杜 -材村杏极李杨求更束豆两丽医辰励否还歼来连步坚旱盯呈时吴助县里呆园 -旷围呀吨足邮男困吵串员听吩吹呜吧吼别岗帐财针钉告我乱利秃秀私每兵 -估体何但伸作伯伶佣低你住位伴身皂佛近彻役返余希坐谷妥含邻岔肝肚肠 -龟免狂犹角删条卵岛迎饭饮系言冻状亩况床库疗应冷这序辛弃冶忘闲间闷 -判灶灿弟汪沙汽沃泛沟没沈沉怀忧快完宋宏牢究穷灾良证启评补初社识诉 -诊词译君灵即层尿尾迟局改张忌际陆阿陈阻附妙妖妨努忍劲鸡驱纯纱纳纲 -驳纵纷纸纹纺驴纽 - -八画 -奉玩环武青责现表规抹拢拔拣担坦押抽拐拖拍者顶拆拥抵拘势抱垃拉拦拌 -幸招坡披拨择抬其取苦若茂苹苗英范直茄茎茅林枝杯柜析板松枪构杰述枕 -丧或画卧事刺枣雨卖矿码厕奔奇奋态欧垄妻轰顷转斩轮软到非叔肯齿些虎 -虏肾贤尚旺具果味昆国昌畅明易昂典固忠咐呼鸣咏呢岸岩帖罗帜岭凯败贩 -购图钓制知垂牧物乖刮秆和季委佳侍供使例版侄侦侧凭侨佩货依的迫质欣 -征往爬彼径所舍金命斧爸采受乳贪念贫肤肺肢肿胀朋股肥服胁周昏鱼兔狐 -忽狗备饰饱饲变京享店夜庙府底剂郊废净盲放刻育闸闹郑券卷单炒炊炕炎 -炉沫浅法泄河沾泪油泊沿泡注泻泳泥沸波泼泽治怖性怕怜怪学宝宗定宜审 -宙官空帘实试郎诗肩房诚衬衫视话诞询该详建肃录隶居届刷屈弦承孟孤陕 -降限妹姑姐姓始驾参艰线练组细驶织终驻驼绍经贯 - -九画 -奏春帮珍玻毒型挂封持项垮挎城挠政赴赵挡挺括拴拾挑指垫挣挤拼挖按挥 -挪某甚革荐巷带草茧茶荒茫荡荣故胡南药标枯柄栋相查柏柳柱柿栏树要咸 -威歪研砖厘厚砌砍面耐耍牵残殃轻鸦皆背战点临览竖省削尝是盼眨哄显哑 -冒映星昨畏趴胃贵界虹虾蚁思蚂虽品咽骂哗咱响哈咬咳哪炭峡罚贱贴骨钞 -钟钢钥钩卸缸拜看矩怎牲选适秒香种秋科重复竿段便俩贷顺修保促侮俭俗 -俘信皇泉鬼侵追俊盾待律很须叙剑逃食盆胆胜胞胖脉勉狭狮独狡狱狠贸怨 -急饶蚀饺饼弯将奖哀亭亮度迹庭疮疯疫疤姿亲音帝施闻阀阁差养美姜叛送 -类迷前首逆总炼炸炮烂剃洁洪洒浇浊洞测洗活派洽染济洋洲浑浓津恒恢恰 -恼恨举觉宣室宫宪突穿窃客冠语扁袄祖神祝误诱说诵垦退既屋昼费陡眉孩 -除险院娃姥姨姻娇怒架贺盈勇怠柔垒绑绒结绕骄绘给络骆绝绞统 \ No newline at end of file diff --git a/tests/cpp-tests/Resources/fonts/HKYuanMini.ttf b/tests/cpp-tests/Resources/fonts/HKYuanMini.ttf new file mode 100644 index 0000000000..aa147af6d7 Binary files /dev/null and b/tests/cpp-tests/Resources/fonts/HKYuanMini.ttf differ diff --git a/tests/cpp-tests/proj.wp8-xaml/cpp-tests/Properties/WMAppManifest.xml b/tests/cpp-tests/proj.wp8-xaml/cpp-tests/Properties/WMAppManifest.xml index c9f4413365..33ee5c4b57 100644 --- a/tests/cpp-tests/proj.wp8-xaml/cpp-tests/Properties/WMAppManifest.xml +++ b/tests/cpp-tests/proj.wp8-xaml/cpp-tests/Properties/WMAppManifest.xml @@ -11,7 +11,7 @@ - + diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index e5d2dc1b89..49fe78134a 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -33,7 +33,6 @@ function UIScene:init() local function previousCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) end end @@ -43,7 +42,6 @@ function UIScene:init() local function restartCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) end end @@ -53,7 +51,6 @@ function UIScene:init() local function nextCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) end end @@ -63,7 +60,6 @@ function UIScene:init() local function menuCloseCallback( sender,eventType) if eventType == ccui.TouchEventType.ended then - self._uiLayer:removeFromParent() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -760,7 +756,6 @@ function UILoadingBarLeftTest:initExtend() local function previousCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) end end @@ -771,7 +766,6 @@ function UILoadingBarLeftTest:initExtend() local function restartCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) end end @@ -782,7 +776,6 @@ function UILoadingBarLeftTest:initExtend() local function nextCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) end end @@ -793,7 +786,6 @@ function UILoadingBarLeftTest:initExtend() local function menuCloseCallback( sender,eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -891,7 +883,6 @@ function UILoadingBarRightTest:initExtend() local function previousCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) end end @@ -902,7 +893,6 @@ function UILoadingBarRightTest:initExtend() local function restartCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) end end @@ -913,7 +903,6 @@ function UILoadingBarRightTest:initExtend() local function nextCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) end end @@ -924,7 +913,6 @@ function UILoadingBarRightTest:initExtend() local function menuCloseCallback( sender,eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -1024,7 +1012,6 @@ function UILoadingBarLeftScale9Test:initExtend() local function previousCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) end end @@ -1035,7 +1022,6 @@ function UILoadingBarLeftScale9Test:initExtend() local function restartCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) end end @@ -1046,7 +1032,6 @@ function UILoadingBarLeftScale9Test:initExtend() local function nextCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) end end @@ -1057,7 +1042,6 @@ function UILoadingBarLeftScale9Test:initExtend() local function menuCloseCallback( sender,eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -1158,7 +1142,6 @@ function UILoadingBarRightScale9Test:initExtend() local function previousCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) end end @@ -1169,7 +1152,6 @@ function UILoadingBarRightScale9Test:initExtend() local function restartCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) end end @@ -1180,7 +1162,6 @@ function UILoadingBarRightScale9Test:initExtend() local function nextCallback(sender, eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) end end @@ -1191,7 +1172,6 @@ function UILoadingBarRightScale9Test:initExtend() local function menuCloseCallback( sender,eventType) if eventType == ccui.TouchEventType.ended then self:unscheduleUpdate() - self._uiLayer:removeFromParent() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -2185,7 +2165,7 @@ function UIScrollViewVerticalTest:initExtend() textButton:setTouchEnabled(true) textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(innerWidth / 2, button:getBottomInParent() - button:getSize().height)) + textButton:setPosition(cc.p(innerWidth / 2, button:getBottomBoundary() - button:getSize().height)) scrollView:addChild(textButton) local button_scale9 = ccui.Button:create() @@ -2193,7 +2173,7 @@ function UIScrollViewVerticalTest:initExtend() button_scale9:setScale9Enabled(true) button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") button_scale9:setSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(innerWidth / 2, textButton:getBottomInParent() - textButton:getSize().height)) + button_scale9:setPosition(cc.p(innerWidth / 2, textButton:getBottomBoundary() - textButton:getSize().height)) scrollView:addChild(button_scale9) imageView:setPosition(cc.p(innerWidth / 2, imageView:getSize().height / 2)) @@ -2278,8 +2258,8 @@ function UIScrollViewHorizontalTest:initExtend() textButton:setTouchEnabled(true) textButton:loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "") textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(button:getRightInParent() + button:getSize().width / 2, - button:getBottomInParent() - button:getSize().height / 2)) + textButton:setPosition(cc.p(button:getRightBoundary() + button:getSize().width / 2, + button:getBottomBoundary() - button:getSize().height / 2)) scrollView:addChild(textButton) local button_scale9 = ccui.Button:create() @@ -2287,12 +2267,12 @@ function UIScrollViewHorizontalTest:initExtend() button_scale9:setScale9Enabled(true) button_scale9:loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "") button_scale9:setSize(cc.size(100, button_scale9:getVirtualRendererSize().height)) - button_scale9:setPosition(cc.p(textButton:getRightInParent() + textButton:getSize().width / 2, - textButton:getBottomInParent() - textButton:getSize().height / 2)) + button_scale9:setPosition(cc.p(textButton:getRightBoundary() + textButton:getSize().width / 2, + textButton:getBottomBoundary() - textButton:getSize().height / 2)) scrollView:addChild(button_scale9) imageView:setPosition(cc.p(innerWidth - imageView:getSize().width / 2, - button_scale9:getBottomInParent() - button_scale9:getSize().height / 2)) + button_scale9:getBottomBoundary() - button_scale9:getSize().height / 2)) scrollView:addChild(imageView) end diff --git a/tests/lua-tests/src/KeypadTest/KeypadTest.lua b/tests/lua-tests/src/KeypadTest/KeypadTest.lua index b7e36aefcd..2437595c46 100644 --- a/tests/lua-tests/src/KeypadTest/KeypadTest.lua +++ b/tests/lua-tests/src/KeypadTest/KeypadTest.lua @@ -16,7 +16,7 @@ local function KeypadMainLayer() local function onKeyReleased(keyCode, event) local label = event:getCurrentTarget() - if keyCode == cc.KeyCode.KEY_BACKSPACE then + if keyCode == cc.KeyCode.KEY_BACK then label:setString("BACK clicked!") elseif keyCode == cc.KeyCode.KEY_MENU then label:setString("MENU clicked!") diff --git a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua index 0637edd403..5664f938eb 100644 --- a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua +++ b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua @@ -665,13 +665,13 @@ function LabelKeyboardEventTest:onEnter() self:addChild(statusLabel) local function onKeyPressed(keyCode, event) - local buf = string.format("Key %s was pressed!",string.char(keyCode)) + local buf = string.format("Key %d was pressed!",keyCode) local label = event:getCurrentTarget() label:setString(buf) end local function onKeyReleased(keyCode, event) - local buf = string.format("Key %s was released!",string.char(keyCode)) + local buf = string.format("Key %d was released!",keyCode) local label = event:getCurrentTarget() label:setString(buf) end diff --git a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua index 85e27af590..680d3e77b1 100644 --- a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua +++ b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua @@ -1263,19 +1263,18 @@ local function TextureMemoryAlloc() end cc.Director:getInstance():getTextureCache():removeUnusedTextures() + local targetPlatform = cc.Application:getInstance():getTargetPlatform() local file = "" - local targetPlatform = cc.Application:getInstance():getTargetPlatform() - - if cc.PLATFORM_OS_ANDROID == targetPlatform then + if targetPlatform == cc.PLATFORM_OS_ANDROID then if tag == 0 then file = "Images/background.png" elseif tag == 1 then file = "Images/fire_rgba8888.pvr" elseif tag == 2 then - file = "Images/grossini_prv_rgba8888.pvr" + file = "Images/grossini_pvr_rgba8888.pvr" elseif tag == 3 then - file = "Images/grossini_prv_rgba4444.pvr" + file = "Images/grossini_pvr_rgba4444.pvr" elseif tag == 4 then file = "Images/test_image_a8.pvr" end diff --git a/tools/bindings-generator b/tools/bindings-generator index 5f3bf19c5d..79153cce44 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5f3bf19c5d59903662571c722fe4b34cae7e9404 +Subproject commit 79153cce443f3efbfd79c08835c63ec58a6c1462 diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 3164639ee4..498f24c168 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 3164639ee44570d7cd3efb3c511e52077560e6fb +Subproject commit 498f24c1683e4725ecaad6168a1aab21b283b8d5 diff --git a/tools/jenkins-scripts/job-comment-trigger.py b/tools/jenkins-scripts/job-comment-trigger.py index ddf1a14331..8ba9d710af 100644 --- a/tools/jenkins-scripts/job-comment-trigger.py +++ b/tools/jenkins-scripts/job-comment-trigger.py @@ -8,7 +8,9 @@ import sys import traceback import urllib2 -http_proxy = os.environ['HTTP_PROXY'] +http_proxy = '' +if(os.environ.has_key('HTTP_PROXY')): + http_proxy = os.environ['HTTP_PROXY'] proxyDict = {'http':http_proxy,'https':http_proxy} def main(): diff --git a/tools/jenkins-scripts/job-trigger.py b/tools/jenkins-scripts/job-trigger.py index 79973d6e93..54e566e94c 100755 --- a/tools/jenkins-scripts/job-trigger.py +++ b/tools/jenkins-scripts/job-trigger.py @@ -8,7 +8,9 @@ import sys import traceback from jenkinsapi.jenkins import Jenkins -http_proxy = os.environ['HTTP_PROXY'] +http_proxy = '' +if(os.environ.has_key('HTTP_PROXY')): + http_proxy = os.environ['HTTP_PROXY'] proxyDict = {'http':http_proxy,'https':http_proxy} def check_queue_build(action, pr_num, statuses_url): diff --git a/tools/jenkins-scripts/post-build.py b/tools/jenkins-scripts/post-build.py index 54d273f199..78f7ddf735 100644 --- a/tools/jenkins-scripts/post-build.py +++ b/tools/jenkins-scripts/post-build.py @@ -29,6 +29,8 @@ if(result == STATUS_SUCCESS): else: data['state'] = "failure" -http_proxy = os.environ['HTTP_PROXY'] +http_proxy = '' +if(os.environ.has_key('HTTP_PROXY')): + http_proxy = os.environ['HTTP_PROXY'] proxyDict = {'http':http_proxy,'https':http_proxy} requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies = proxyDict) diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index 8be309914b..d506bb0df5 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -61,7 +61,9 @@ def check_current_3rd_libs(branch): current_file = current_files[i] copy(current_file, backup_file) -http_proxy = os.environ['HTTP_PROXY'] +http_proxy = '' +if(os.environ.has_key('HTTP_PROXY')): + http_proxy = os.environ['HTTP_PROXY'] proxyDict = {'http':http_proxy,'https':http_proxy} def main(): #get payload from os env