diff --git a/CHANGELOG b/CHANGELOG index 6d1d15cd46..f811f77d6e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -cocos2d-x-3.2beta0 Jul.2 2014 +cocos2d-x-3.2rc0 ?? [NEW] FastTMXTiledMap: added fast tmx, which is much more faster for static tiled map [NEW] GLProgramState: can use uniform location to get/set uniform values [NEW] HttpClient: added sendImmediate() diff --git a/build/android-build.py b/build/android-build.py index 9cccd91fc8..781a0a9779 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -53,23 +53,7 @@ def check_environment_variables_sdk(): return SDK_ROOT def select_toolchain_version(): - '''Because ndk-r8e uses gcc4.6 as default. gcc4.6 doesn't support c++11. So we should select gcc4.7 when - using ndk-r8e. But gcc4.7 is removed in ndk-r9, so we should determine whether gcc4.7 exist. - Conclution: - ndk-r8e -> use gcc4.7 - ndk-r9 -> use gcc4.8 - ''' - - ndk_root = check_environment_variables() - if os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.8")): - os.environ['NDK_TOOLCHAIN_VERSION'] = '4.8' - print "The Selected NDK toolchain version was 4.8 !" - elif os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.7")): - os.environ['NDK_TOOLCHAIN_VERSION'] = '4.7' - print "The Selected NDK toolchain version was 4.7 !" - else: - print "Couldn't find the gcc toolchain." - exit(1) + pass def caculate_built_samples(args): ''' Compute the sampels to be built diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index ecf07d8ded..afffa6f339 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1025,23 +1025,12 @@ 373B912A187891FB00198F86 /* CCComBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 373B910718787C0B00198F86 /* CCComBase.h */; }; 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */; }; 3E6176691960F89B00DE83F5 /* CCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176561960F89B00DE83F5 /* CCController.h */; }; - 3E61766A1960F89B00DE83F5 /* CCControllerAxisInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */; }; - 3E61766B1960F89B00DE83F5 /* CCControllerAxisInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */; }; - 3E61766C1960F89B00DE83F5 /* CCControllerButtonInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */; }; - 3E61766D1960F89B00DE83F5 /* CCControllerButtonInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */; }; - 3E61766E1960F89B00DE83F5 /* CCControllerDirectionPad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */; }; - 3E61766F1960F89B00DE83F5 /* CCControllerDirectionPad.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */; }; - 3E6176701960F89B00DE83F5 /* CCControllerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */; }; - 3E6176711960F89B00DE83F5 /* CCControllerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765E1960F89B00DE83F5 /* CCControllerElement.h */; }; - 3E6176721960F89B00DE83F5 /* CCControllerThumbstick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */; }; - 3E6176731960F89B00DE83F5 /* CCControllerThumbstick.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */; }; 3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176611960F89B00DE83F5 /* CCEventController.cpp */; }; 3E6176751960F89B00DE83F5 /* CCEventController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176621960F89B00DE83F5 /* CCEventController.h */; }; 3E6176761960F89B00DE83F5 /* CCEventListenerController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */; }; 3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */; }; 3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176651960F89B00DE83F5 /* CCGameController.h */; }; - 3E6176791960F89B00DE83F5 /* CCGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176661960F89B00DE83F5 /* CCGamepad.cpp */; }; - 3E61767A1960F89B00DE83F5 /* CCGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176671960F89B00DE83F5 /* CCGamepad.h */; }; + 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61781C1966A5A300DE83F5 /* CCController.cpp */; }; 3EA0FB6B191C841D00B170C8 /* UIVideoPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */; }; 3EA0FB6C191C841D00B170C8 /* UIVideoPlayerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */; }; 3EA47870195478E00068D9D1 /* CCBundleReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */; }; @@ -2370,23 +2359,12 @@ 37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "CCController-iOS.mm"; path = "../base/CCController-iOS.mm"; sourceTree = ""; }; 3E6176561960F89B00DE83F5 /* CCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCController.h; path = ../base/CCController.h; sourceTree = ""; }; - 3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerAxisInput.cpp; path = ../base/CCControllerAxisInput.cpp; sourceTree = ""; }; - 3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerAxisInput.h; path = ../base/CCControllerAxisInput.h; sourceTree = ""; }; - 3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerButtonInput.cpp; path = ../base/CCControllerButtonInput.cpp; sourceTree = ""; }; - 3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerButtonInput.h; path = ../base/CCControllerButtonInput.h; sourceTree = ""; }; - 3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerDirectionPad.cpp; path = ../base/CCControllerDirectionPad.cpp; sourceTree = ""; }; - 3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerDirectionPad.h; path = ../base/CCControllerDirectionPad.h; sourceTree = ""; }; - 3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerElement.cpp; path = ../base/CCControllerElement.cpp; sourceTree = ""; }; - 3E61765E1960F89B00DE83F5 /* CCControllerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerElement.h; path = ../base/CCControllerElement.h; sourceTree = ""; }; - 3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerThumbstick.cpp; path = ../base/CCControllerThumbstick.cpp; sourceTree = ""; }; - 3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerThumbstick.h; path = ../base/CCControllerThumbstick.h; sourceTree = ""; }; 3E6176611960F89B00DE83F5 /* CCEventController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventController.cpp; path = ../base/CCEventController.cpp; sourceTree = ""; }; 3E6176621960F89B00DE83F5 /* CCEventController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventController.h; path = ../base/CCEventController.h; sourceTree = ""; }; 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventListenerController.cpp; path = ../base/CCEventListenerController.cpp; sourceTree = ""; }; 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventListenerController.h; path = ../base/CCEventListenerController.h; sourceTree = ""; }; 3E6176651960F89B00DE83F5 /* CCGameController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGameController.h; path = ../base/CCGameController.h; sourceTree = ""; }; - 3E6176661960F89B00DE83F5 /* CCGamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCGamepad.cpp; path = ../base/CCGamepad.cpp; sourceTree = ""; }; - 3E6176671960F89B00DE83F5 /* CCGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGamepad.h; path = ../base/CCGamepad.h; sourceTree = ""; }; + 3E61781C1966A5A300DE83F5 /* CCController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCController.cpp; path = ../base/CCController.cpp; sourceTree = ""; }; 3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayer.h; sourceTree = ""; }; 3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIVideoPlayerIOS.mm; sourceTree = ""; }; 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBundleReader.cpp; sourceTree = ""; }; @@ -3187,25 +3165,14 @@ 1A5700A2180BC5E60088DEC7 /* base */ = { isa = PBXGroup; children = ( + 3E61781C1966A5A300DE83F5 /* CCController.cpp */, 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */, 3E6176561960F89B00DE83F5 /* CCController.h */, - 3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */, - 3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */, - 3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */, - 3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */, - 3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */, - 3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */, - 3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */, - 3E61765E1960F89B00DE83F5 /* CCControllerElement.h */, - 3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */, - 3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */, 3E6176611960F89B00DE83F5 /* CCEventController.cpp */, 3E6176621960F89B00DE83F5 /* CCEventController.h */, 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */, 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */, 3E6176651960F89B00DE83F5 /* CCGameController.h */, - 3E6176661960F89B00DE83F5 /* CCGamepad.cpp */, - 3E6176671960F89B00DE83F5 /* CCGamepad.h */, 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */, 299754F3193EC95400A54AC3 /* ObjectFactory.h */, 50ABBDC11925AB6E00A911A9 /* atitc.cpp */, @@ -5571,7 +5538,6 @@ 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, - 3E61766B1960F89B00DE83F5 /* CCControllerAxisInput.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, @@ -5608,7 +5574,6 @@ 50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */, 2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */, 5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, - 3E6176711960F89B00DE83F5 /* CCControllerElement.h in Headers */, 50E6D33718E174130051CA34 /* UIHBox.h in Headers */, 1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, 50E6D33F18E174130051CA34 /* UIVBox.h in Headers */, @@ -5676,7 +5641,6 @@ 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, 50ABBE981925AB6F00A911A9 /* CCProtocols.h in Headers */, 2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */, - 3E6176731960F89B00DE83F5 /* CCControllerThumbstick.h in Headers */, 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, 50ABBD431925AB0000A911A9 /* CCMathBase.h in Headers */, 50ABBE441925AB6F00A911A9 /* CCDirector.h in Headers */, @@ -5695,7 +5659,6 @@ 50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */, 2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */, 50FCEB9A18C72017004AD434 /* CheckBoxReader.h in Headers */, - 3E61766D1960F89B00DE83F5 /* CCControllerButtonInput.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 2905FA7F18CF08D100240AA3 /* UIText.h in Headers */, 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, @@ -5708,7 +5671,6 @@ 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */, 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */, - 3E61766F1960F89B00DE83F5 /* CCControllerDirectionPad.h in Headers */, 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */, 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */, @@ -5815,7 +5777,6 @@ 1AD71ED0180E26E600808F54 /* Skeleton.h in Headers */, 50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */, 1AD71ED4180E26E600808F54 /* SkeletonData.h in Headers */, - 3E61767A1960F89B00DE83F5 /* CCGamepad.h in Headers */, 1AD71ED8180E26E600808F54 /* SkeletonJson.h in Headers */, 1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */, 1AD71EDC180E26E600808F54 /* Skin.h in Headers */, @@ -6752,7 +6713,6 @@ 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */, 2905FA8D18CF08D100240AA3 /* UIWidget.cpp in Sources */, 29E99D1F1957BA7000046604 /* CocoLoader.cpp in Sources */, - 3E61766C1960F89B00DE83F5 /* CCControllerButtonInput.cpp in Sources */, B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, 0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */, 50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */, @@ -6792,6 +6752,7 @@ 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, 503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */, 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, + 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */, 50ABC00E1926664800A911A9 /* CCFileUtils.cpp in Sources */, 50ABBE241925AB6F00A911A9 /* base64.cpp in Sources */, 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, @@ -6831,13 +6792,11 @@ 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, 1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, - 3E6176791960F89B00DE83F5 /* CCGamepad.cpp in Sources */, 1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, B24AA986195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */, 1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, 50ABBD901925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */, - 3E6176701960F89B00DE83F5 /* CCControllerElement.cpp in Sources */, 2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */, 2905FA7D18CF08D100240AA3 /* UIText.cpp in Sources */, 50E6D33D18E174130051CA34 /* UIVBox.cpp in Sources */, @@ -6853,7 +6812,6 @@ 1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, - 3E61766A1960F89B00DE83F5 /* CCControllerAxisInput.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */, 50ABBECC1925AB6F00A911A9 /* s3tc.cpp in Sources */, @@ -6966,7 +6924,6 @@ 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, 3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */, 50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */, - 3E61766E1960F89B00DE83F5 /* CCControllerDirectionPad.cpp in Sources */, 503DD8E51926736A00CD74DD /* CCDirectorCaller.mm in Sources */, 50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */, 50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */, @@ -7005,7 +6962,6 @@ 1A8C59D4180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */, 1A8C59D8180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */, 46C02E0818E91123004B7456 /* xxhash.c in Sources */, - 3E6176721960F89B00DE83F5 /* CCControllerThumbstick.cpp in Sources */, 50ABBED01925AB6F00A911A9 /* TGAlib.cpp in Sources */, 2905FA4118CF08D100240AA3 /* CocosGUI.cpp in Sources */, 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */, diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 2c889dbc87..003fb4fd48 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -827,8 +827,6 @@ 3E6177351960FB4000DE83F5 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176DE1960FA6300DE83F5 /* AppController.mm */; }; 3E6177361960FB5A00DE83F5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176EE1960FA6300DE83F5 /* main.m */; }; 3E6177371960FB5E00DE83F5 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176F01960FA6300DE83F5 /* RootViewController.mm */; }; - 3E6177391960FBB800DE83F5 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E6177381960FBB800DE83F5 /* SystemConfiguration.framework */; }; - 3E61773B1960FBC300DE83F5 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E61773A1960FBC300DE83F5 /* CFNetwork.framework */; }; 3E61773D1960FBD200DE83F5 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E61773C1960FBD100DE83F5 /* GameController.framework */; }; 3E6177F41960FEFE00DE83F5 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 3E6177F01960FEFE00DE83F5 /* fonts */; }; 3E6177F51960FEFE00DE83F5 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 3E6177F11960FEFE00DE83F5 /* ipad */; }; @@ -2132,8 +2130,6 @@ buildActionMask = 2147483647; files = ( 3E61773D1960FBD200DE83F5 /* GameController.framework in Frameworks */, - 3E61773B1960FBC300DE83F5 /* CFNetwork.framework in Frameworks */, - 3E6177391960FBB800DE83F5 /* SystemConfiguration.framework in Frameworks */, 3E6177211960FAED00DE83F5 /* libchipmunk iOS.a in Frameworks */, 3E6177221960FAED00DE83F5 /* libcocos2dx iOS.a in Frameworks */, 3E6177231960FAED00DE83F5 /* libCocosDenshion iOS.a in Frameworks */, @@ -5728,6 +5724,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; INFOPLIST_FILE = "$(SRCROOT)/../tests/game-controller-test/proj.ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PRODUCT_NAME = "game-controller-test IOS"; @@ -5745,6 +5742,7 @@ "$(inherited)", CC_TARGET_OS_IPHONE, ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; INFOPLIST_FILE = "$(SRCROOT)/../tests/game-controller-test/proj.ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; PRODUCT_NAME = "game-controller-test IOS"; diff --git a/cocos/2d/CCFastTMXLayer.cpp b/cocos/2d/CCFastTMXLayer.cpp index 1b456fc69b..15d5717330 100644 --- a/cocos/2d/CCFastTMXLayer.cpp +++ b/cocos/2d/CCFastTMXLayer.cpp @@ -237,7 +237,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect) else { //do nothing, do not support - CCASSERT(0, "TMX invalid value"); + //CCASSERT(0, "TMX invalid value"); } _indicesVertexZNumber.clear(); @@ -264,9 +264,8 @@ void FastTMXLayer::updateTiles(const Rect& culledRect) int offset = iter->second; iter->second++; - //CC_ASSERT(_tileToQuadIndex.find(tileIndex) != _tileToQuadIndex.end() && _tileToQuadIndex[tileIndex] <= _totalQuads.size()-1); - int quadIndex = (int)_tileToQuadIndex[tileIndex]; - + int quadIndex = _tileToQuadIndex[tileIndex]; + CC_ASSERT(-1 != quadIndex); _indices[6 * offset + 0] = quadIndex * 4 + 0; _indices[6 * offset + 1] = quadIndex * 4 + 1; _indices[6 * offset + 2] = quadIndex * 4 + 2; @@ -387,7 +386,13 @@ Mat4 FastTMXLayer::tileToNodeTransform() } case FAST_TMX_ORIENTATION_HEX: { - _tileToNodeTransform = Mat4::IDENTITY; + _tileToNodeTransform = Mat4 + ( + h * sqrtf(0.75), 0, 0, 0, + -h/2, -h, 0, offY, + 0, 0, 1, 0, + 0, 0, 0, 1 + ); return _tileToNodeTransform; } default: @@ -408,6 +413,7 @@ void FastTMXLayer::updateTotalQuads() _tileToQuadIndex.clear(); _totalQuads.resize(int(_layerSize.width * _layerSize.height)); _indices.resize(6 * int(_layerSize.width * _layerSize.height)); + _tileToQuadIndex.resize(int(_layerSize.width * _layerSize.height),-1); _indicesVertexZOffsets.clear(); int quadIndex = 0; @@ -617,7 +623,7 @@ int FastTMXLayer::getVertexZForPos(const Vec2& pos) ret = static_cast(-(_layerSize.height-pos.y)); break; case FAST_TMX_ORIENTATION_HEX: - CCASSERT(0, "TMX Hexa zOrder not supported"); + CCASSERT(0, "TMX Hexa vertexZ not supported"); break; default: CCASSERT(0, "TMX invalid value"); diff --git a/cocos/2d/CCFastTMXLayer.h b/cocos/2d/CCFastTMXLayer.h index f007c698a5..fa377bb0d0 100644 --- a/cocos/2d/CCFastTMXLayer.h +++ b/cocos/2d/CCFastTMXLayer.h @@ -239,7 +239,7 @@ protected: Mat4 _tileToNodeTransform; /** data for rendering */ bool _quadsDirty; - std::unordered_map _tileToQuadIndex; + std::vector _tileToQuadIndex; std::vector _totalQuads; std::vector _indices; std::map _indicesVertexZOffsets; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index a0905817e1..37edc2573c 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -861,25 +861,24 @@ void Node::enumerateChildren(const std::string &name, std::function 3 && -// name[length-3] == '/' && -// name[length-2] == '.' && -// name[length-1] == '.') -// { -// searchFromParent = true; -// subStrlength -= 3; -// } + bool searchFromParent = false; + if (length > 3 && + name[length-3] == '/' && + name[length-2] == '.' && + name[length-1] == '.') + { + searchFromParent = true; + subStrlength -= 3; + } - // Remove '/', '//' if exist + // Remove '/', '//', '/..' if exist std::string newName = name.substr(subStrStartPos, subStrlength); - // If search from parent, then add * at first to make it match its children, which will do make -// if (searchFromParent) -// { -// newName.insert(0, "[[:alnum:]]+/"); -// } + + if (searchFromParent) + { + newName.insert(0, "[[:alnum:]]+/"); + } if (searchFromRoot) { @@ -944,14 +943,10 @@ bool Node::doEnumerate(std::string name, std::function callback) needRecursive = true; } - std::hash h; - size_t hashOfName = h(searchName); bool ret = false; for (const auto& child : _children) { - // TODO: regular expression support - // Android doesn't support c++ 11 regular expression well, may use external lib - if (hashOfName == child->_hashOfName && searchName.compare(child->_name) == 0) + if (std::regex_match(child->_name, std::regex(searchName))) { if (!needRecursive) { diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 55a26ec113..6e70e85731 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -714,17 +714,20 @@ public: virtual Node* getChildByName(const std::string& name) const; /** Search the children of the receiving node to perform processing for nodes which share a name. * - * @param name The name to search for + * @param name The name to search for, supports c++11 regular expression * Search syntax options: * `/` : When placed at the start of the search string, this indicates that the search should be performed on the tree's node. * `//`: Can only be placed at the begin of the search string. This indicates that the search should be performed on the tree's node * and be performed recursively across the entire node tree. + * `..`: The search should move up to the node's parent. Can only be placed at the end of string * `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children * * @code * enumerateChildren("/MyName", ...): This searches the root's children and matches any node with the name `MyName`. * enumerateChildren("//MyName", ...): This searches the root's children recursively and matches any node with the name `MyName`. + * enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children. * enumerateChildren("/MyName", ...): This searches the node tree and matches the parent node of every node named `MyName`. + * enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9` * enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal` * and whose parent is named `Abby`. * enumerateChildren("//Abby/Normal", ...): This searches the node tree and returns any node whose name is `Normal` and whose diff --git a/cocos/Android.mk b/cocos/Android.mk index 7dbf29b159..219098f275 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -222,10 +222,10 @@ LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static # define the macro to compile through support/zip_support/ioapi.c -LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API -LOCAL_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations -LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API -LOCAL_EXPORT_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations +LOCAL_CFLAGS := -DUSE_FILE32API +LOCAL_CPPFLAGS := -Wno-deprecated-declarations +LOCAL_EXPORT_CFLAGS := -DUSE_FILE32API +LOCAL_EXPORT_CPPFLAGS := -Wno-deprecated-declarations include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/audio/android/Android.mk b/cocos/audio/android/Android.mk index e5f3261840..3854fa79d7 100644 --- a/cocos/audio/android/Android.mk +++ b/cocos/audio/android/Android.mk @@ -15,7 +15,4 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../../platform/android -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi - include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/base/CCController-android.cpp b/cocos/base/CCController-android.cpp index b138fb8d97..66aa5f02af 100644 --- a/cocos/base/CCController-android.cpp +++ b/cocos/base/CCController-android.cpp @@ -159,6 +159,10 @@ Controller::Controller() init(); } +void Controller::registerListeners() +{ +} + NS_CC_END extern "C" { diff --git a/cocos/base/CCController-iOS.mm b/cocos/base/CCController-iOS.mm index 69ecbf88ad..8daa45e47e 100644 --- a/cocos/base/CCController-iOS.mm +++ b/cocos/base/CCController-iOS.mm @@ -27,17 +27,12 @@ #include "base/CCPlatformConfig.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) -#include "CCGamepad.h" -#include "CCControllerDirectionPad.h" -#include "CCControllerButtonInput.h" -#include "CCControllerAxisInput.h" -#include "CCControllerThumbstick.h" - #include "ccMacros.h" #include "CCEventDispatcher.h" #include "CCEventController.h" #include "CCEventListenerController.h" #include "CCDirector.h" +#include "CCLabel.h" #import @@ -105,90 +100,50 @@ static GCControllerConnectionEventHandler* __instance = nil; NS_CC_BEGIN -#define sendEventButton(dstID, srcID) \ -dstID->setPressed(srcID.isPressed); \ -dstID->setValue(srcID.value); \ -dstID->setAnalog(srcID.isAnalog); \ -EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, _gamepad->_controller, dstID); \ -Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); - - -#define sendEventAxis(dstID, srcID) \ -\ -dstID->setValue(srcID.value); \ -dstID->setAnalog(srcID.isAnalog); \ -\ -EventController evt(EventController::ControllerEventType::AXIS_STATUS_CHANGED, _gamepad->_controller, dstID); \ -Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); - class ControllerImpl { public: ControllerImpl(Controller* controller) : _controller(controller) , _gcController(nil) - , _lazyRegisterListener(true) - { - - } - - ~ControllerImpl() { } Controller* _controller; GCController* _gcController; - bool _lazyRegisterListener; }; -std::vector Controller::_controllers; - -const std::vector& Controller::getControllers() -{ - return _controllers; -} +std::vector Controller::s_allController; void Controller::startDiscoveryController() { [GCController startWirelessControllerDiscoveryWithCompletionHandler: nil]; [[GCControllerConnectionEventHandler getInstance] observerConnection: ^(GCController* gcController) { + auto controller = new Controller(); controller->_impl->_gcController = gcController; - gcController.controllerPausedHandler = ^(GCController* gcCon){ - - auto iter = std::find_if(_controllers.begin(), _controllers.end(), [gcCon](Controller* c){ return c->_impl->_gcController == gcCon; }); - - CCASSERT(iter != _controllers.end(), "Could not find the controller"); - - auto button = (*iter)->getGamepad()->getButtonPause(); - button->setPressed(true); - EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, (*iter), button); - Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); - - // Reset the pause button status to unpressed. - button->setPressed(false); - }; + s_allController.push_back(controller); - _controllers.push_back(controller); + controller->registerListeners(); + controller->getDeviceName(); - - EventController evt(EventController::ControllerEventType::CONNECTION, controller, true); - Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); + controller->onConnected(); } disconnection: ^(GCController* gcController) { + auto iter = std::find_if(s_allController.begin(), s_allController.end(), [gcController](Controller* c){ return c->_impl->_gcController == gcController; }); - auto iter = std::find_if(_controllers.begin(), _controllers.end(), [gcController](Controller* c){ return c->_impl->_gcController == gcController; }); + if(iter == s_allController.end()) + { + log("disconnect:Could not find the controller"); + return; + } - CCASSERT(iter != _controllers.end(), "Could not find the controller"); + (*iter)->onDisconnected(); + s_allController.erase(iter); - EventController evt(EventController::ControllerEventType::CONNECTION, *iter, false); - Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); - - delete (*iter); - _controllers.erase(iter); }]; } @@ -198,26 +153,165 @@ void Controller::stopDiscoveryController() } Controller::Controller() +: _controllerTag(TAG_UNSET) +, _impl(new ControllerImpl(this)) +, _connectEvent(nullptr) +, _keyEvent(nullptr) +, _axisEvent(nullptr) +, _deviceId(0) { - _playerIndex = PLAYER_INDEX_UNSET; - _gamepad = new Gamepad(); - _gamepad->_controller = this; - _impl = new ControllerImpl(this); + init(); } Controller::~Controller() { - CC_SAFE_DELETE(_impl); - CC_SAFE_DELETE(_gamepad); + delete _impl; + + delete _connectEvent; + delete _keyEvent; + delete _axisEvent; } -const std::string& Controller::getVendorName() +void Controller::registerListeners() { - if (_vendorName.empty()) + if (_impl->_gcController.extendedGamepad != nil) { - _vendorName = [_impl->_gcController.vendorName UTF8String]; + _impl->_gcController.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_UP, pressed, value, button.isAnalog); + }; + + _impl->_gcController.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_DOWN, pressed, value, button.isAnalog); + }; + + _impl->_gcController.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_LEFT, pressed, value, button.isAnalog); + }; + + _impl->_gcController.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_RIGHT, pressed, value, button.isAnalog); + }; + + _impl->_gcController.extendedGamepad.leftThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ + onAxisEvent(Key::JOYSTICK_LEFT_X, value, axis.isAnalog); + }; + + _impl->_gcController.extendedGamepad.leftThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ + onAxisEvent(Key::JOYSTICK_LEFT_Y, value, axis.isAnalog); + }; + + _impl->_gcController.extendedGamepad.rightThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ + onAxisEvent(Key::JOYSTICK_RIGHT_X, value, axis.isAnalog); + }; + + _impl->_gcController.extendedGamepad.rightThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ + onAxisEvent(Key::JOYSTICK_RIGHT_Y, value, axis.isAnalog); + }; + + _impl->_gcController.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element){ + if (element == gamepad.buttonA) + { + onButtonEvent(Key::BUTTON_A, gamepad.buttonA.isPressed, gamepad.buttonA.value, gamepad.buttonA.isAnalog); + } + else if (element == gamepad.buttonB) + { + onButtonEvent(Key::BUTTON_B, gamepad.buttonB.isPressed, gamepad.buttonB.value, gamepad.buttonB.isAnalog); + } + else if (element == gamepad.buttonX) + { + onButtonEvent(Key::BUTTON_X, gamepad.buttonX.isPressed, gamepad.buttonX.value, gamepad.buttonX.isAnalog); + } + else if (element == gamepad.buttonY) + { + onButtonEvent(Key::BUTTON_Y, gamepad.buttonY.isPressed, gamepad.buttonY.value, gamepad.buttonY.isAnalog); + } + else if (element == gamepad.leftShoulder) + { + onButtonEvent(Key::BUTTON_LEFT_SHOULDER, gamepad.leftShoulder.isPressed, gamepad.leftShoulder.value, gamepad.leftShoulder.isAnalog); + } + else if (element == gamepad.rightShoulder) + { + onButtonEvent(Key::BUTTON_RIGHT_SHOULDER, gamepad.rightShoulder.isPressed, gamepad.rightShoulder.value, gamepad.rightShoulder.isAnalog); + } + else if (element == gamepad.leftTrigger) + { + onAxisEvent(Key::AXIS_LEFT_TRIGGER, gamepad.leftTrigger.value, gamepad.leftTrigger.isAnalog); + } + else if (element == gamepad.rightTrigger) + { + onAxisEvent(Key::AXIS_RIGHT_TRIGGER, gamepad.rightTrigger.value, gamepad.rightTrigger.isAnalog); + } + }; } - return _vendorName; + else + { + _impl->_gcController.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_UP, pressed, value, button.isAnalog); + }; + + _impl->_gcController.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_DOWN, pressed, value, button.isAnalog); + }; + + _impl->_gcController.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_LEFT, pressed, value, button.isAnalog); + }; + + _impl->_gcController.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ + onButtonEvent(Key::BUTTON_DPAD_RIGHT, pressed, value, button.isAnalog); + }; + + _impl->_gcController.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, GCControllerElement *element){ + + if (element == gamepad.buttonA) + { + onButtonEvent(Key::BUTTON_A, gamepad.buttonA.isPressed, gamepad.buttonA.value, gamepad.buttonA.isAnalog); + } + else if (element == gamepad.buttonB) + { + onButtonEvent(Key::BUTTON_B, gamepad.buttonB.isPressed, gamepad.buttonB.value, gamepad.buttonB.isAnalog); + } + else if (element == gamepad.buttonX) + { + onButtonEvent(Key::BUTTON_X, gamepad.buttonX.isPressed, gamepad.buttonX.value, gamepad.buttonX.isAnalog); + } + else if (element == gamepad.buttonY) + { + onButtonEvent(Key::BUTTON_Y, gamepad.buttonY.isPressed, gamepad.buttonY.value, gamepad.buttonY.isAnalog); + } + else if (element == gamepad.leftShoulder) + { + onButtonEvent(Key::BUTTON_LEFT_SHOULDER, gamepad.leftShoulder.isPressed, gamepad.leftShoulder.value, gamepad.leftShoulder.isAnalog); + } + else if (element == gamepad.rightShoulder) + { + onButtonEvent(Key::BUTTON_RIGHT_SHOULDER, gamepad.rightShoulder.isPressed, gamepad.rightShoulder.value, gamepad.rightShoulder.isAnalog); + } + }; + } + + _impl->_gcController.controllerPausedHandler = ^(GCController* gcCon){ + + auto iter = std::find_if(s_allController.begin(), s_allController.end(), [gcCon](Controller* c){ return c->_impl->_gcController == gcCon; }); + + if(iter == s_allController.end()) + { + log("Could not find the controller"); + return; + } + + onButtonEvent(Key::BUTTON_PAUSE, true, 1.0f, false); + onButtonEvent(Key::BUTTON_PAUSE, false, 0.0f, false); + }; +} + +const std::string& Controller::getDeviceName() +{ + if (_deviceName.empty()) + { + _deviceName = [_impl->_gcController.vendorName UTF8String]; + } + return _deviceName; } bool Controller::isConnected() const @@ -225,147 +319,6 @@ bool Controller::isConnected() const return _impl->_gcController.isAttachedToDevice == YES; } -int Controller::getPlayerIndex() const -{ - return _playerIndex; -} - -void Controller::setPlayerIndex(int playerIndex) -{ - _playerIndex = playerIndex; -} - -Gamepad* Controller::getGamepad() const -{ - if (_impl->_gcController == nil) - return nullptr; - if(_impl->_gcController.gamepad == nil && _impl->_gcController.extendedGamepad == nil) - { - CCASSERT(false, "No gamepad was found!"); - } - else if (_impl->_lazyRegisterListener) - { - _impl->_lazyRegisterListener = false; - if (_impl->_gcController.extendedGamepad != nil) - { - _impl->_gcController.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getUp(), button); - }; - - _impl->_gcController.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getDown(), button); - }; - - _impl->_gcController.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getLeft(), button); - }; - - _impl->_gcController.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getRight(), button); - }; - - _impl->_gcController.extendedGamepad.leftThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ - sendEventAxis(_gamepad->getLeftThumbstick()->getAxisX(), axis); - }; - - _impl->_gcController.extendedGamepad.leftThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ - sendEventAxis(_gamepad->getLeftThumbstick()->getAxisY(), axis); - }; - - _impl->_gcController.extendedGamepad.rightThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ - sendEventAxis(_gamepad->getRightThumbstick()->getAxisX(), axis); - }; - - _impl->_gcController.extendedGamepad.rightThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){ - sendEventAxis(_gamepad->getRightThumbstick()->getAxisY(), axis); - }; - - _impl->_gcController.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element){ - if (element == gamepad.buttonA) - { - sendEventButton(_gamepad->getButtonA(), gamepad.buttonA); - } - else if (element == gamepad.buttonB) - { - sendEventButton(_gamepad->getButtonB(), gamepad.buttonB); - } - else if (element == gamepad.buttonX) - { - sendEventButton(_gamepad->getButtonX(), gamepad.buttonX); - } - else if (element == gamepad.buttonY) - { - sendEventButton(_gamepad->getButtonY(), gamepad.buttonY); - } - else if (element == gamepad.leftShoulder) - { - sendEventButton(_gamepad->getLeftShoulder(), gamepad.leftShoulder); - } - else if (element == gamepad.rightShoulder) - { - sendEventButton(_gamepad->getRightShoulder(), gamepad.rightShoulder); - } - else if (element == gamepad.leftTrigger) - { - sendEventButton(_gamepad->getLeftTrigger(), gamepad.leftTrigger); - } - else if (element == gamepad.rightTrigger) - { - sendEventButton(_gamepad->getRightTrigger(), gamepad.rightTrigger); - } - }; - } - else - { - _impl->_gcController.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getUp(), button); - }; - - _impl->_gcController.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getDown(), button); - }; - - _impl->_gcController.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getLeft(), button); - }; - - _impl->_gcController.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){ - sendEventButton(_gamepad->getDirectionPad()->getRight(), button); - }; - - _impl->_gcController.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, GCControllerElement *element){ - - if (element == gamepad.buttonA) - { - sendEventButton(_gamepad->getButtonA(), gamepad.buttonA); - } - else if (element == gamepad.buttonB) - { - sendEventButton(_gamepad->getButtonB(), gamepad.buttonB); - } - else if (element == gamepad.buttonX) - { - sendEventButton(_gamepad->getButtonX(), gamepad.buttonX); - } - else if (element == gamepad.buttonY) - { - sendEventButton(_gamepad->getButtonY(), gamepad.buttonY); - } - else if (element == gamepad.leftShoulder) - { - sendEventButton(_gamepad->getLeftShoulder(), gamepad.leftShoulder); - } - else if (element == gamepad.rightShoulder) - { - sendEventButton(_gamepad->getRightShoulder(), gamepad.rightShoulder); - } - }; - } - } - - return _gamepad; -} - NS_CC_END #endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) diff --git a/cocos/base/CCController.cpp b/cocos/base/CCController.cpp index 58f6522b1a..566b80ad52 100644 --- a/cocos/base/CCController.cpp +++ b/cocos/base/CCController.cpp @@ -25,7 +25,7 @@ #include "CCController.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "ccMacros.h" #include "CCEventDispatcher.h" diff --git a/cocos/base/CCController.h b/cocos/base/CCController.h index 52feac5481..61013b8953 100644 --- a/cocos/base/CCController.h +++ b/cocos/base/CCController.h @@ -114,6 +114,7 @@ private: void onDisconnected(); void onButtonEvent(int keyCode, bool isPressed, float value, bool isAnalog); void onAxisEvent(int axisCode, float value, bool isAnalog); + void registerListeners(); std::unordered_map _allKeyStatus; std::unordered_map _allKeyPrevStatus; diff --git a/cocos/editor-support/cocosbuilder/Android.mk b/cocos/editor-support/cocosbuilder/Android.mk index 6cf80a9982..52863eda24 100644 --- a/cocos/editor-support/cocosbuilder/Android.mk +++ b/cocos/editor-support/cocosbuilder/Android.mk @@ -35,8 +35,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \ $(LOCAL_PATH) \ $(LOCAL_PATH)/../../.. -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp index 794e44cbce..3078dcd54a 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp @@ -45,6 +45,8 @@ static const char* ClassName_Button = "Button"; static const char* ClassName_CheckBox = "CheckBox"; static const char* ClassName_ImageView = "ImageView"; static const char* ClassName_TextAtlas = "TextAtlas"; +static const char* ClassName_LabelAtlas = "LabelAtlas"; +static const char* ClassName_LabelBMFont= "LabelBMFont"; static const char* ClassName_TextBMFont = "TextBMFont"; static const char* ClassName_Text = "Text"; static const char* ClassName_LoadingBar = "LoadingBar"; @@ -132,7 +134,8 @@ void NodeReader::init() _funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1))); _funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1))); _funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1))); - + _funcs.insert(Pair(ClassName_LabelAtlas,std::bind(&NodeReader::loadWidget, this, _1))); + _funcs.insert(Pair(ClassName_LabelBMFont,std::bind(&NodeReader::loadWidget, this, _1))); _funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1))); _funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1))); _funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1))); diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index 192f0e8f46..d5efa765b3 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -68,8 +68,8 @@ $(LOCAL_PATH)/../../../external \ $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../.. -LOCAL_CFLAGS += -Wno-psabi -fexceptions -LOCAL_EXPORT_CFLAGS += -Wno-psabi +LOCAL_CFLAGS += -fexceptions + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index 21dc78b04b..cf650bc7e2 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -83,7 +83,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V CCLOG("filename == %s",fileName.c_str()); cocos2d::Vector actionList; - stExpCocoNode *stChildArray = pCocoNode->GetChildArray(); + stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader); stExpCocoNode *actionNode = nullptr; for (int i=0; i < pCocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); @@ -99,7 +99,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V ActionObject* action = new ActionObject(); action->autorelease(); - action->initWithBinary(cocoLoader, actionNode->GetChildArray(), root); + action->initWithBinary(cocoLoader, actionNode->GetChildArray(cocoLoader), root); actionList.pushBack(action); } diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index eb68c98019..f0c6ee782e 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -195,11 +195,11 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) stExpCocoNode *stChildNode = cocoNode; int actionNodeCount = stChildNode->GetChildNum(); - stChildNode = stChildNode[0].GetChildArray(); + stChildNode = stChildNode[0].GetChildArray(cocoLoader); stExpCocoNode *frameListNode = nullptr; for (int i = 0; i < actionNodeCount; ++i) { std::string key = stChildNode[i].GetName(cocoLoader); - std::string value = stChildNode[i].GetValue(); + std::string value = stChildNode[i].GetValue(cocoLoader); if (key == "ActionTag") { setActionTag(valueToInt(value)); }else if (key == "actionframelist"){ @@ -208,7 +208,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) } int actionFrameCount = frameListNode->GetChildNum(); - stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray(); + stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray(cocoLoader); for (int i=0; i frameTweenParameter; int framesCount = stFrameChildNode[i].GetChildNum(); - stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray(); + stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray(cocoLoader); for (int j = 0; j < framesCount; j++) { std::string key = innerFrameNode[j].GetName(cocoLoader); - std::string value = innerFrameNode[j].GetValue(); + std::string value = innerFrameNode[j].GetValue(cocoLoader); if (key == "frameid") { frameIndex = valueToInt(value); @@ -237,10 +237,10 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) }else if (key == "tweenParameter"){ // There are no tweenParameter args in the json file int tweenParameterCount = innerFrameNode[j].GetChildNum(); - stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray(); + stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray(cocoLoader); for (int k = 0; k < tweenParameterCount; ++k) { std::string t_key = tweenParameterArray[j].GetName(cocoLoader); - std::string t_value = tweenParameterArray[j].GetValue(); + std::string t_value = tweenParameterArray[j].GetValue(cocoLoader); frameTweenParameter.push_back(valueToFloat(t_value)); } }else if (key == "positionx"){ diff --git a/cocos/editor-support/cocostudio/CCActionObject.cpp b/cocos/editor-support/cocostudio/CCActionObject.cpp index 0ab3dbdef8..b064cb2fc2 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.cpp +++ b/cocos/editor-support/cocostudio/CCActionObject.cpp @@ -132,12 +132,12 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Ref *root) { - stExpCocoNode *stChildNode = cocoNode->GetChildArray(); + stExpCocoNode *stChildNode = cocoNode->GetChildArray(cocoLoader); stExpCocoNode *actionNodeList = nullptr; int count = cocoNode->GetChildNum(); for (int i = 0; i < count; ++i) { std::string key = stChildNode[i].GetName(cocoLoader); - std::string value = stChildNode[i].GetValue(); + std::string value = stChildNode[i].GetValue(cocoLoader); if (key == "name") { setName(value.c_str()); }else if (key == "loop"){ @@ -152,7 +152,7 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader, if(nullptr != actionNodeList) { int actionNodeCount = actionNodeList->GetChildNum(); - stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray(); + stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray(cocoLoader); int maxLength = 0; for (int i=0; i_rData; stExpCocoNode *cocoNode = serData->_cocoNode; + CocoLoader *cocoLoader = serData->_cocoLoader; const char *className = nullptr; const char *comName = nullptr; const char *file = nullptr; @@ -170,14 +171,14 @@ bool ComAttribute::serialize(void* r) } else if (cocoNode != nullptr) { - className = cocoNode[1].GetValue(); + className = cocoNode[1].GetValue(cocoLoader); CC_BREAK_IF(className == nullptr); - comName = cocoNode[2].GetValue(); - stExpCocoNode *fileData = cocoNode[3].GetChildArray(); + comName = cocoNode[2].GetValue(cocoLoader); + stExpCocoNode *fileData = cocoNode[3].GetChildArray(cocoLoader); CC_BREAK_IF(!fileData); - file = fileData[0].GetValue(); + file = fileData[0].GetValue(cocoLoader); CC_BREAK_IF(file == nullptr); - resType = atoi(fileData[2].GetValue()); + resType = atoi(fileData[2].GetValue(cocoLoader)); CC_BREAK_IF(resType != 0); } if (comName != nullptr) diff --git a/cocos/editor-support/cocostudio/CCComAudio.cpp b/cocos/editor-support/cocostudio/CCComAudio.cpp index 717e8f701d..a370b68994 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.cpp +++ b/cocos/editor-support/cocostudio/CCComAudio.cpp @@ -76,6 +76,7 @@ bool ComAudio::serialize(void* r) SerData *serData = (SerData *)(r); const rapidjson::Value *v = serData->_rData; stExpCocoNode *cocoNode = serData->_cocoNode; + CocoLoader *cocoLoader = serData->_cocoLoader; const char *className = nullptr; const char *comName = nullptr; const char *file = nullptr; @@ -97,16 +98,16 @@ bool ComAudio::serialize(void* r) } else if (cocoNode != nullptr) { - className = cocoNode[1].GetValue(); + className = cocoNode[1].GetValue(cocoLoader); CC_BREAK_IF(className == nullptr); - comName = cocoNode[2].GetValue(); - stExpCocoNode *pfileData = cocoNode[4].GetChildArray(); + comName = cocoNode[2].GetValue(cocoLoader); + stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader); CC_BREAK_IF(!pfileData); - file = pfileData[0].GetValue(); + file = pfileData[0].GetValue(cocoLoader); CC_BREAK_IF(file == nullptr); - resType = atoi(pfileData[2].GetValue()); + resType = atoi(pfileData[2].GetValue(cocoLoader)); CC_BREAK_IF(resType != 0); - loop = atoi(cocoNode[5].GetValue()) != 0? true:false; + loop = atoi(cocoNode[5].GetValue(cocoLoader)) != 0? true:false; ret = true; } if (comName != nullptr) diff --git a/cocos/editor-support/cocostudio/CCComBase.h b/cocos/editor-support/cocostudio/CCComBase.h index 9467b7381a..6d526b60ce 100644 --- a/cocos/editor-support/cocostudio/CCComBase.h +++ b/cocos/editor-support/cocostudio/CCComBase.h @@ -50,10 +50,12 @@ struct SerData { const rapidjson::Value *_rData; cocostudio::stExpCocoNode *_cocoNode; + cocostudio::CocoLoader *_cocoLoader; SerData() { _rData = NULL; _cocoNode = NULL; + _cocoLoader = NULL; } }; diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index 3bc3b995b6..aee0d201f6 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -97,6 +97,7 @@ bool ComRender::serialize(void* r) SerData *serData = (SerData *)(r); const rapidjson::Value *v = serData->_rData; stExpCocoNode *cocoNode = serData->_cocoNode; + CocoLoader *cocoLoader = serData->_cocoLoader; const char *className = nullptr; const char *comName = nullptr; const char *file = nullptr; @@ -118,15 +119,15 @@ bool ComRender::serialize(void* r) } else if(cocoNode != nullptr) { - className = cocoNode[1].GetValue(); + className = cocoNode[1].GetValue(cocoLoader); CC_BREAK_IF(className == nullptr); - comName = cocoNode[2].GetValue(); - stExpCocoNode *pfileData = cocoNode[4].GetChildArray(); + comName = cocoNode[2].GetValue(cocoLoader); + stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader); CC_BREAK_IF(!pfileData); - file = pfileData[0].GetValue(); - plist = pfileData[1].GetValue(); + file = pfileData[0].GetValue(cocoLoader); + plist = pfileData[1].GetValue(cocoLoader); CC_BREAK_IF(file == nullptr && plist == nullptr); - resType = atoi(pfileData[2].GetValue()); + resType = atoi(pfileData[2].GetValue(cocoLoader)); } if (comName != nullptr) { @@ -195,7 +196,7 @@ bool ComRender::serialize(void* r) const char *actionName = nullptr; if (cocoNode != nullptr) { - actionName = cocoNode[6].GetValue();//DICTOOL->getStringValue_json(*v, "selectedactionname"); + actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname"); } else { @@ -222,25 +223,25 @@ bool ComRender::serialize(void* r) if (rapidjson::kObjectType == tType) { int count = tpRootCocoNode->GetChildNum(); - stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(); + stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); for (int i = 0; i < count; ++i) { std::string key = tpChildArray[i].GetName(&tCocoLoader); if (key.compare("armature_data") == 0) { int length = tpChildArray[i].GetChildNum(); - stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(); + stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(&tCocoLoader); if (length < 1) { continue; } length = armature_dataArray[0].GetChildNum(); - stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray(); + stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray(&tCocoLoader); for (int j = 0; j < length; ++j) { std::string key1 = armature_data[j].GetName(&tCocoLoader); - const char *str1 = armature_data[j].GetValue(); + const char *str1 = armature_data[j].GetValue(&tCocoLoader); if (key.compare("name") == 0) { if (str1 != nullptr) @@ -252,7 +253,7 @@ bool ComRender::serialize(void* r) const char *actionName = nullptr; if (cocoNode != nullptr) { - actionName = cocoNode[6].GetValue(); + actionName = cocoNode[6].GetValue(&tCocoLoader); } else { diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 24d5147f47..64ca8917b9 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -301,9 +301,9 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) // Read content from file std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath); - bool isbinarysrc = str==".csb"; + bool isbinaryfilesrc = str==".csb"; std::string filemode("r"); - if(isbinarysrc) + if(isbinaryfilesrc) filemode += "b"; ssize_t filesize; @@ -324,7 +324,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath) { DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo); } - else if(str == ".csb") + else if(isbinaryfilesrc) { DataReaderHelper::addDataFromBinaryCache(contentStr.c_str(),&dataInfo); } @@ -438,7 +438,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const { data->configType = CocoStudio_JSON; } - else if(str == ".csb") + else if(isbinaryfilesrc) { data->configType = CocoStudio_Binary; } @@ -474,7 +474,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt) if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "") { _getFileMutex.lock(); - ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str()); + ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str(), pDataInfo->filename.c_str()); _getFileMutex.unlock(); } @@ -482,7 +482,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt) { std::string configPath = pDataInfo->configFileQueue.front(); _getFileMutex.lock(); - ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str()); + ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str(),pDataInfo->filename.c_str()); _getFileMutex.unlock(); pDataInfo->configFileQueue.pop(); } @@ -1258,7 +1258,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data { _dataReaderHelper->_addDataMutex.lock(); } - ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData); + ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData, dataInfo->filename.c_str()); armatureData->release(); if (dataInfo->asyncStruct) { @@ -1277,7 +1277,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data { _dataReaderHelper->_addDataMutex.lock(); } - ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData); + ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData, dataInfo->filename.c_str()); animationData->release(); if (dataInfo->asyncStruct) { @@ -1296,7 +1296,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data { _dataReaderHelper->_addDataMutex.lock(); } - ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData); + ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData, dataInfo->filename.c_str()); textureData->release(); if (dataInfo->asyncStruct) { @@ -1330,7 +1330,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data std::string plistPath = filePath + ".plist"; std::string pngPath = filePath + ".png"; - ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str()); + ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str(), dataInfo->filename.c_str()); } } } @@ -1750,7 +1750,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); if (rapidjson::kObjectType == tType) { - stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(); + stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); int nCount = tpRootCocoNode->GetChildNum(); dataInfo->contentScale = 1.0f; @@ -1762,12 +1762,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, key = tpChildArray[i].GetName(&tCocoLoader); if (key.compare(CONTENT_SCALE) == 0) { - std::string value = tpChildArray[i].GetValue(); + std::string value = tpChildArray[i].GetValue(&tCocoLoader); dataInfo->contentScale = atof(value.c_str()); } else if ( 0 == key.compare(ARMATURE_DATA)) { - pDataArray = tpChildArray[i].GetChildArray(); + pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader); length = tpChildArray[i].GetChildNum(); ArmatureData * armatureData; for (int ii = 0; ii < length; ++ii) @@ -1787,7 +1787,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, } else if ( 0 == key.compare(ANIMATION_DATA)) { - pDataArray = tpChildArray[i].GetChildArray(); + pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader); length = tpChildArray[i].GetChildNum(); AnimationData *animationData; for (int ii = 0; ii < length; ++ii) @@ -1807,7 +1807,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, } else if (key.compare(TEXTURE_DATA) == 0) { - pDataArray = tpChildArray[i].GetChildArray(); + pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader); length = tpChildArray[i].GetChildNum(); for (int ii = 0; ii < length; ++ii) { @@ -1837,10 +1837,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, continue; } length = tpChildArray[i].GetChildNum(); - stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray(); + stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray(&tCocoLoader); for (int ii = 0; ii < length; ii++) { - const char *path = pConfigFilePath[ii].GetValue(); + const char *path = pConfigFilePath[ii].GetValue(&tCocoLoader); if (path == nullptr) { CCLOG("load CONFIG_FILE_PATH error."); @@ -1872,18 +1872,18 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { ArmatureData *armatureData = new ArmatureData(); armatureData->init(); - stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray(); - const char *name = pAramtureDataArray[2].GetValue(); //DICTOOL->getStringValue_json(json, A_NAME); + stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray(cocoLoader); + const char *name = pAramtureDataArray[2].GetValue(cocoLoader); //DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { armatureData->name = name; } - float version = atof(pAramtureDataArray[1].GetValue()); + float version = atof(pAramtureDataArray[1].GetValue(cocoLoader)); dataInfo->cocoStudioVersion = armatureData->dataVersion = version; //DICTOOL->getFloatValue_json(json, VERSION, 0.1f); int length = pAramtureDataArray[3].GetChildNum(); //DICTOOL->getArrayCount_json(json, BONE_DATA, 0); - stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray(); + stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray(cocoLoader); stExpCocoNode* child; for (int i = 0; i < length; i++) { @@ -1905,7 +1905,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, decodeNode(boneData, cocoLoader, cocoNode, dataInfo); int length = cocoNode->GetChildNum(); - stExpCocoNode *pBoneChildren = cocoNode->GetChildArray(); + stExpCocoNode *pBoneChildren = cocoNode->GetChildArray(cocoLoader); stExpCocoNode* child; const char *str = nullptr; std::string key; @@ -1913,7 +1913,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { child = &pBoneChildren[i]; key = child->GetName(cocoLoader); - str = child->GetValue(); + str = child->GetValue(cocoLoader); if (key.compare(A_NAME) == 0) { //DICTOOL->getStringValue_json(json, A_NAME); @@ -1933,7 +1933,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, else if (key.compare(DISPLAY_DATA) == 0) { int count = child->GetChildNum(); - stExpCocoNode *pDisplayData = child->GetChildArray(); + stExpCocoNode *pDisplayData = child->GetChildArray(cocoLoader); for (int ii = 0; ii < count; ++ii) { DisplayData *displayData = decodeBoneDisplay(cocoLoader, &pDisplayData[ii], dataInfo); @@ -1950,16 +1950,16 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, DisplayData* DataReaderHelper::decodeBoneDisplay(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, DataInfo *dataInfo) { - stExpCocoNode* children = cocoNode->GetChildArray(); + stExpCocoNode* children = cocoNode->GetChildArray(cocoLoader); stExpCocoNode* child = &children[1]; const char *str = nullptr; std::string key = child->GetName(cocoLoader); - str = child->GetValue(); + str = child->GetValue(cocoLoader); DisplayData *displayData = nullptr; if (key.compare(A_DISPLAY_TYPE) == 0) { - str = child->GetValue(); + str = child->GetValue(cocoLoader); DisplayType displayType = (DisplayType)(atoi(str)); int length = 0; @@ -1969,12 +1969,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { displayData = new SpriteDisplayData(); - const char *name = children[0].GetValue(); + const char *name = children[0].GetValue(cocoLoader); if(name != nullptr) { ((SpriteDisplayData *)displayData)->displayName = name; } - stExpCocoNode *pSkinDataArray = children[2].GetChildArray(); + stExpCocoNode *pSkinDataArray = children[2].GetChildArray(cocoLoader); if (pSkinDataArray != nullptr) { stExpCocoNode *pSkinData = &pSkinDataArray[0]; @@ -1982,11 +1982,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { SpriteDisplayData *sdd = (SpriteDisplayData *)displayData; length = pSkinData->GetChildNum(); - stExpCocoNode *SkinDataValue = pSkinData->GetChildArray(); + stExpCocoNode *SkinDataValue = pSkinData->GetChildArray(cocoLoader); for (int i = 0; i < length; ++i) { key = SkinDataValue[i].GetName(cocoLoader); - str = SkinDataValue[i].GetValue(); + str = SkinDataValue[i].GetValue(cocoLoader); if (key.compare(A_X) == 0) { sdd->skinData.x = atof(str) * s_PositionReadScale; @@ -2024,7 +2024,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { displayData = new ArmatureDisplayData(); - const char *name = cocoNode[0].GetValue(); + const char *name = cocoNode[0].GetValue(cocoLoader); if(name != nullptr) { ((ArmatureDisplayData *)displayData)->displayName = name; @@ -2035,11 +2035,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { displayData = new ParticleDisplayData(); length = cocoNode->GetChildNum(); - stExpCocoNode *pDisplayData = cocoNode->GetChildArray(); + stExpCocoNode *pDisplayData = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < length; ++i) { key = pDisplayData[i].GetName(cocoLoader); - str = pDisplayData[i].GetValue(); + str = pDisplayData[i].GetValue(cocoLoader); if (key.compare(A_PLIST) == 0) { const char *plist = str; @@ -2073,7 +2073,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, AnimationData *aniData = new AnimationData(); int length = cocoNode->GetChildNum(); - stExpCocoNode *pAnimationData = cocoNode->GetChildArray(); + stExpCocoNode *pAnimationData = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; std::string key; stExpCocoNode* child; @@ -2082,7 +2082,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { child = &pAnimationData[i]; key = child->GetName(cocoLoader); - str = child->GetValue(); + str = child->GetValue(cocoLoader); if (key.compare(A_NAME) == 0) { if(str != nullptr) @@ -2093,7 +2093,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, else if (key.compare(MOVEMENT_DATA) == 0) { int movcount = child->GetChildNum(); - stExpCocoNode* movArray = child->GetChildArray(); + stExpCocoNode* movArray = child->GetChildArray(cocoLoader); for( int movnum =0; movnum scale = 1.0f; int length = cocoNode->GetChildNum(); - stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray(); + stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; std::string key; @@ -2120,7 +2120,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { child = &pMoveDataArray[i]; key = child->GetName(cocoLoader); - str = child->GetValue(); + str = child->GetValue(cocoLoader); if (key.compare(A_NAME) == 0) { if(str != nullptr) @@ -2182,7 +2182,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, else if (key.compare(MOVEMENT_BONE_DATA) == 0) { int count = child->GetChildNum(); - stExpCocoNode *pMoveBoneData = child->GetChildArray(); + stExpCocoNode *pMoveBoneData = child->GetChildArray(cocoLoader); MovementBoneData *movementBoneData; for (int ii = 0; ii < count; ++ii) { @@ -2201,14 +2201,14 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, movementBoneData->init(); int length = cocoNode->GetChildNum(); - stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray(); + stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray(cocoLoader); stExpCocoNode* movebonechild; const char *str = nullptr; for (int i = 0; i < length; ++i) { movebonechild = &pMovementBoneDataArray[i]; std::string key = movebonechild->GetName(cocoLoader); - str = movebonechild->GetValue(); + str = movebonechild->GetValue(cocoLoader); if (key.compare(A_NAME) == 0) { if(str != nullptr) @@ -2226,7 +2226,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, else if (key.compare(FRAME_DATA) == 0) { int count =movebonechild->GetChildNum(); - stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray(); + stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray(cocoLoader); for (int ii = 0; ii < count; ++ii) { FrameData *frameData = decodeFrame(cocoLoader, &pFrameDataArray[ii], dataInfo); @@ -2296,12 +2296,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, decodeNode(frameData, cocoLoader, cocoNode, dataInfo); int length = cocoNode->GetChildNum(); - stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray(); + stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; for (int i = 0; i < length; ++i) { std::string key = pFrameDataArray[i].GetName(cocoLoader); - str = pFrameDataArray[i].GetValue(); + str = pFrameDataArray[i].GetValue(cocoLoader); if (key.compare(A_TWEEN_EASING) == 0) { frameData->tweenEasing = cocos2d::tweenfunc::Linear; @@ -2376,10 +2376,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, if (count != 0 ) { frameData->easingParams = new float[count]; - stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(); + stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader); for (int ii = 0; ii < count; ++ii) { - str = pFrameData[ii].GetValue(); + str = pFrameData[ii].GetValue(cocoLoader); if (str != nullptr) { frameData->easingParams[ii] = atof(str); @@ -2404,12 +2404,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, } int length = cocoNode->GetChildNum(); - stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray(); + stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; for (int i = 0; i < length; ++i) { std::string key = pTextureDataArray[i].GetName(cocoLoader); - str = pTextureDataArray[i].GetValue(); + str = pTextureDataArray[i].GetValue(cocoLoader); if (key.compare(A_NAME) == 0) { if(str != nullptr) @@ -2448,7 +2448,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, else if (key.compare(CONTOUR_DATA) == 0) { int count = pTextureDataArray[i].GetChildNum(); - stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray(); + stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray(cocoLoader); for (int ii = 0; ii < count; ++ii) { ContourData *contourData = decodeContour(cocoLoader, &pContourArray[ii]); @@ -2466,23 +2466,23 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, contourData->init(); int length = cocoNode->GetChildNum(); - stExpCocoNode *verTexPointArray = cocoNode->GetChildArray(); + stExpCocoNode *verTexPointArray = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; for (int i = 0; i < length; ++i) { std::string key = verTexPointArray[i].GetName(cocoLoader); - str = verTexPointArray[i].GetValue(); + str = verTexPointArray[i].GetValue(cocoLoader); if (key.compare(VERTEX_POINT) == 0) { int count = verTexPointArray[i].GetChildNum(); - stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray(); + stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray(cocoLoader); stExpCocoNode *pVerTexPoint; for (int ii = count - 1; ii >= 0; --ii) { - pVerTexPoint = pVerTexPointArray[ii].GetChildArray(); + pVerTexPoint = pVerTexPointArray[ii].GetChildArray(cocoLoader); Vec2 vertex; - vertex.x = atof(pVerTexPoint[0].GetValue()); - vertex.y = atof(pVerTexPoint[1].GetValue()); + vertex.x = atof(pVerTexPoint[0].GetValue(cocoLoader)); + vertex.y = atof(pVerTexPoint[1].GetValue(cocoLoader)); contourData->vertexList.push_back(vertex); } break; } @@ -2493,7 +2493,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, void DataReaderHelper::decodeNode(BaseData *node, CocoLoader *cocoLoader, stExpCocoNode* cocoNode, DataInfo *dataInfo) { int length = cocoNode->GetChildNum(); - stExpCocoNode *NodeArray = cocoNode->GetChildArray(); + stExpCocoNode *NodeArray = cocoNode->GetChildArray(cocoLoader); const char *str = nullptr; bool isVersionL = dataInfo->cocoStudioVersion < VERSION_COLOR_READING; @@ -2502,7 +2502,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { child = &NodeArray[i]; std::string key = child->GetName(cocoLoader); - str = child->GetValue(); + str = child->GetValue(cocoLoader); if (key.compare(A_X) == 0) { node->x = atof(str) * dataInfo->contentScale; @@ -2539,12 +2539,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { if(child->GetChildNum() == 4) { - stExpCocoNode *ChildArray = child->GetChildArray(); + stExpCocoNode *ChildArray = child->GetChildArray(cocoLoader); - node->a = atoi(ChildArray[0].GetValue()); - node->r = atoi(ChildArray[1].GetValue()); - node->g = atoi(ChildArray[2].GetValue()); - node->b = atoi(ChildArray[3].GetValue()); + node->a = atoi(ChildArray[0].GetValue(cocoLoader)); + node->r = atoi(ChildArray[1].GetValue(cocoLoader)); + node->g = atoi(ChildArray[2].GetValue(cocoLoader)); + node->b = atoi(ChildArray[3].GetValue(cocoLoader)); } } @@ -2566,12 +2566,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json, { if(NodeArray[0].GetChildNum() == 4) { - stExpCocoNode *ChildArray = NodeArray[0].GetChildArray(); + stExpCocoNode *ChildArray = NodeArray[0].GetChildArray(cocoLoader); - node->a = atoi(ChildArray[0].GetValue()); - node->r = atoi(ChildArray[1].GetValue()); - node->g = atoi(ChildArray[2].GetValue()); - node->b = atoi(ChildArray[3].GetValue()); + node->a = atoi(ChildArray[0].GetValue(cocoLoader)); + node->r = atoi(ChildArray[1].GetValue(cocoLoader)); + node->g = atoi(ChildArray[2].GetValue(cocoLoader)); + node->b = atoi(ChildArray[3].GetValue(cocoLoader)); } } diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 37f6605f48..9204b255de 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -361,13 +361,13 @@ Widget* GUIReader::widgetFromBinaryFile(const char *fileName) rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); if (rapidjson::kObjectType == tType || rapidjson::kArrayType == tType) { - stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(); + stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); for (int i = 0; i < tpRootCocoNode->GetChildNum(); ++i) { std::string key = tpChildArray[i].GetName(&tCocoLoader); if (key == "version") { - fileVersion = tpChildArray[i].GetValue(); + fileVersion = tpChildArray[i].GetValue(&tCocoLoader); break; } } @@ -1222,7 +1222,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c cocos2d::ui::Widget* WidgetPropertiesReader0300::createWidgetFromBinary(CocoLoader* cocoLoader,stExpCocoNode* cocoNode, const char* fileName) { - stExpCocoNode *tpChildArray = cocoNode->GetChildArray(); + stExpCocoNode *tpChildArray = cocoNode->GetChildArray(cocoLoader); float fileDesignWidth; float fileDesignHeight; @@ -1236,14 +1236,14 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c for (int j=0; jaddSpriteFramesWithFile(file); } }else if (key == "designWidth"){ - fileDesignWidth = atof(tpChildArray[i].GetValue()); + fileDesignWidth = atof(tpChildArray[i].GetValue(cocoLoader)); }else if (key == "designHeight"){ - fileDesignHeight = atof(tpChildArray[i].GetValue()); + fileDesignHeight = atof(tpChildArray[i].GetValue(cocoLoader)); }else if (key == "widgetTree"){ if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { @@ -1275,7 +1275,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c /* ********************** */ /* ********************** */ - stExpCocoNode *optionChildNode = cocoNode->GetChildArray(); + stExpCocoNode *optionChildNode = cocoNode->GetChildArray(cocoLoader); for (int k = 0; k < cocoNode->GetChildNum(); ++k) { std::string key = optionChildNode[k].GetName(cocoLoader); if (key == "animation") { @@ -1291,7 +1291,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, stExpCocoNode* cocoNode) { Widget* widget = nullptr; - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); stExpCocoNode *optionsNode = nullptr; stExpCocoNode *childrenNode = nullptr; int elementCount = cocoNode->GetChildNum(); @@ -1299,7 +1299,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st for (int i = 0; i < elementCount; ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); if (key == "classname" ) { @@ -1341,11 +1341,11 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st // 2nd., custom widget parse with custom reader //2nd. parse custom property const char* customProperty = NULL; - stExpCocoNode *optionChildNode = optionsNode->GetChildArray(); + stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader); for (int k = 0; k < optionsNode->GetChildNum(); ++k) { std::string key = optionChildNode[k].GetName(cocoLoader); if (key == "customProperty") { - customProperty = optionChildNode[k].GetValue(); + customProperty = optionChildNode[k].GetValue(cocoLoader); break; } } @@ -1369,7 +1369,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st if (tType22 == rapidjson::kArrayType) { int childrenCount = childrenNode->GetChildNum(); - stExpCocoNode* innerChildArray = childrenNode->GetChildArray(); + stExpCocoNode* innerChildArray = childrenNode->GetChildArray(cocoLoader); for (int i=0; i < childrenCount; ++i) { rapidjson::Type tType = innerChildArray[i].GetType(cocoLoader); diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 39bab7ef3c..c6ca142de4 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -91,7 +91,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); if (rapidjson::kObjectType == tType) { - stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(); + stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0); _node = Node::create(); int nCount = 0; @@ -102,19 +102,19 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, { nCount = tpChildArray[15].GetChildNum(); } - stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(); + stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader); SerData *data = new SerData(); for (int i = 0; i < nCount; i++) { - stExpCocoNode *subDict = pComponents[i].GetChildArray(); + stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader); if (subDict == nullptr) { continue; } - std::string key = subDict[1].GetName(&tCocoLoader); - const char *comName = subDict[1].GetValue(); + std::string key1 = subDict[1].GetName(&tCocoLoader); + const char *comName = subDict[1].GetValue(&tCocoLoader); Component *pCom = nullptr; - if (key == "classname" && comName != nullptr) + if (key1 == "classname" && comName != nullptr) { pCom = createComponent(comName); } @@ -123,6 +123,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, { data->_rData = nullptr; data->_cocoNode = subDict; + data->_cocoLoader = &tCocoLoader; if (pCom->serialize(data)) { ComRender *pTRender = dynamic_cast(pCom); @@ -152,7 +153,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, _node->addComponent(*iter); } - stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(); + stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader); int length = tpChildArray[11].GetChildNum(); for (int i = 0; i < length; ++i) { @@ -283,6 +284,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par { data->_rData = &subDict; data->_cocoNode = nullptr; + data->_cocoLoader = nullptr; if (com->serialize(data)) { ComRender *tRender = dynamic_cast(com); @@ -349,11 +351,11 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node* parent, AttachComponentType attachComponent) { const char *className = nullptr; - stExpCocoNode *pNodeArray = cocoNode->GetChildArray(); + stExpCocoNode *pNodeArray = cocoNode->GetChildArray(cocoLoader); std::string Key = pNodeArray[1].GetName(cocoLoader); if (Key == "classname") { - className = pNodeArray[1].GetValue(); + className = pNodeArray[1].GetValue(cocoLoader); } if(strcmp(className, "CCNode") == 0) { @@ -366,19 +368,19 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode * { count = pNodeArray[13].GetChildNum(); } - stExpCocoNode *pComponents = pNodeArray[13].GetChildArray(); + stExpCocoNode *pComponents = pNodeArray[13].GetChildArray(cocoLoader); SerData *data = new SerData(); for (int i = 0; i < count; ++i) { - stExpCocoNode *subDict = pComponents[i].GetChildArray(); + stExpCocoNode *subDict = pComponents[i].GetChildArray(cocoLoader); if (subDict == nullptr) { continue; } - std::string key = subDict[1].GetName(cocoLoader); - const char *comName = subDict[1].GetValue();//DICTOOL->getStringValue_json(subDict, "classname"); + std::string key1 = subDict[1].GetName(cocoLoader); + const char *comName = subDict[1].GetValue(cocoLoader); Component *pCom = nullptr; - if (key == "classname" && comName != nullptr) + if (key1 == "classname" && comName != nullptr) { pCom = createComponent(comName); } @@ -387,6 +389,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode * { data->_rData = nullptr; data->_cocoNode = subDict; + data->_cocoLoader = cocoLoader; if (pCom->serialize(data)) { ComRender *pTRender = dynamic_cast(pCom); @@ -436,7 +439,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode * gb->addComponent(*iter); } - stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray(); + stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray(cocoLoader); if (pGameObjects != nullptr) { int length = pNodeArray[12].GetChildNum(); @@ -495,7 +498,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d: void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node *node) { - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); float x = 0.0f, y = 0.0f, fScaleX = 1.0f, fScaleY = 1.0f, fRotationZ = 1.0f; bool bVisible = false; int nTag = 0, nZorder = -1; @@ -503,7 +506,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); if (key == "x") { diff --git a/cocos/editor-support/cocostudio/CocoLoader.cpp b/cocos/editor-support/cocostudio/CocoLoader.cpp index 90dfd12ecf..8a0aeced5b 100644 --- a/cocos/editor-support/cocostudio/CocoLoader.cpp +++ b/cocos/editor-support/cocostudio/CocoLoader.cpp @@ -1,5 +1,5 @@ #include "CocoLoader.h" - +#include "zlib.h" using namespace std; using namespace rapidjson; @@ -7,190 +7,222 @@ using namespace rapidjson; namespace cocostudio{ +char cTypeName[] = {'N','F','T','O','A','S','V'}; const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; const char* kObjKeyName[] = { "__type" , "classname" }; char g_Buff[2048]; -Type stExpCocoNode::GetType(CocoLoader* pCoco) +char* stExpCocoAttribDesc::GetName(CocoLoader* pCoco) { - Type tType = kObjectType; - if(m_ObjIndex >= 0) - { - stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray(); - if( m_AttribIndex >= 0 ) - { - stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray; - tType = tpAttribDescArray[m_AttribIndex].m_Type; - - if(kFalseType == tType || kTrueType == tType) - { - char* szValue = (char*)m_szValue; - if(szValue[0] == '0') - { - return kFalseType; - } - else - { - return kTrueType; - } - } + return ( pCoco->GetMemoryAddr_String() + m_szName ); +} - } - else - { - tType = kObjectType; - } - } - else - { - if(m_AttribIndex >= 0) - { - tType = (Type)m_ChildNum; +char* stExpCocoObjectDesc::GetName(CocoLoader* pCoco) +{ + return ( pCoco->GetMemoryAddr_String() + m_szName ); +} - if(kFalseType == tType || kTrueType == tType) - { - char* szValue = (char*)m_szValue; - if(szValue[0] == '0') - { - return kFalseType; - } - else - { - return kTrueType; - } - } - } - else - { - tType = kArrayType; - } - } - return tType; +int stExpCocoObjectDesc::GetAttribNum() +{ + return m_cAttribNum; +} + +stExpCocoAttribDesc* stExpCocoObjectDesc::GetAttribDescArray(CocoLoader* pCoco) +{ + return (stExpCocoAttribDesc*)( pCoco->GetMemoryAddr_AttribDesc() + m_pAttribDescArray ); +} + +Type stExpCocoNode::GetType(CocoLoader* pCoco) +{ + + Type tType = kObjectType; + if(m_ObjIndex >= 0) + { + stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray() ; + if( m_AttribIndex >= 0 ) + { + stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco); + tType = Type(tpAttribDescArray[m_AttribIndex].m_cTypeName - 'N' + kNullType); + + if(kFalseType == tType || kTrueType == tType) + { + char* szValue = (char*)GetValue(pCoco); + if(szValue[0] == '0') + { + return kFalseType; + } + else + { + return kTrueType; + } + } + + } + else + { + tType = kObjectType; + } + } + else + { + if(m_AttribIndex >= 0) + { + tType = (Type)m_ChildNum; + + if(kFalseType == tType || kTrueType == tType) + { + char* szValue = (char*)GetValue(pCoco); + if(szValue[0] == '0') + { + return kFalseType; + } + else + { + return kTrueType; + } + } + } + else + { + tType = kArrayType; + } + } + return tType; } char* stExpCocoNode::GetName(CocoLoader* pCoco) { - char* szName = NULL ; - if(m_ObjIndex >= 0) - { - stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray(); - if( m_AttribIndex >= 0 ) - { - stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray; - szName = (char*)tpAttribDescArray[m_AttribIndex].m_szName; - } - else - { - char* szValue = (char*)m_szValue; - if(szValue[0]) - { - szName = (char*)m_szValue; - } - else - { - szName = (char*)tpCocoObjectDesc[m_ObjIndex].m_szName; - } - } - } - else - { - if(m_AttribIndex >= 0) - { - char* pStringAddr = (char*)pCoco->GetCocoObjectDescArray() + pCoco->GetFileHeader()->m_lStringMemAddr ; - szName = m_ChildArray + pStringAddr; - } - else - { - szName = (char*)m_szValue; - } - } - return szName ; + char* szName = NULL ; + if(m_ObjIndex >= 0) + { + stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray(); + if( m_AttribIndex >= 0 ) + { + stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco); + szName = tpAttribDescArray[m_AttribIndex].GetName(pCoco); + } + else + { + char* szValue = GetValue(pCoco); + if(szValue[0]) + { + szName = GetValue(pCoco); + } + else + { + szName = tpCocoObjectDesc[m_ObjIndex].GetName(pCoco); + } + } + } + else + { + if(m_AttribIndex >= 0) + { + char* pStringAddr = (char*)pCoco->GetCocoObjectDescArray() + pCoco->GetFileHeader()->m_lStringMemAddr ; + szName = m_ChildArray + pStringAddr; + } + else + { + szName = (char*)GetValue(pCoco); + } + } + return szName ; + } -char* stExpCocoNode::GetValue() +char* stExpCocoNode::GetValue(CocoLoader* pCoco) { - return (char*)m_szValue; + return ( pCoco->GetMemoryAddr_String() + m_szValue ); } int stExpCocoNode::GetChildNum() { - return m_ChildNum; + return m_ChildNum; } -stExpCocoNode* stExpCocoNode::GetChildArray() +stExpCocoNode* stExpCocoNode::GetChildArray(CocoLoader* pCoco) { - return (stExpCocoNode*)m_ChildArray; -} - -void stExpCocoNode::ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr) -{ - m_szValue = m_szValue + (uint64_t)pStringMemoryAddr; - if( -1 == m_AttribIndex ) - { - if(m_ChildNum > 0) - { - m_ChildArray = m_ChildArray + (uint64_t)cocoNodeAddr; - - stExpCocoNode* tpChildArray = (stExpCocoNode*)m_ChildArray; - for(int i = 0 ; i < m_ChildNum ; i++) - { - tpChildArray[i].ReBuild(cocoNodeAddr,pStringMemoryAddr); - } - } - } - + return (stExpCocoNode*)( pCoco->GetMemoryAddr_CocoNode() + m_ChildArray ); } CocoLoader::CocoLoader() { - m_pRootNode = NULL; - m_pObjectDescArray = NULL; + m_pRootNode = NULL; + m_pObjectDescArray = NULL; + m_pMemoryBuff = NULL; } CocoLoader::~CocoLoader() { - + if(m_pMemoryBuff) + { + delete[] m_pMemoryBuff; + m_pMemoryBuff = NULL; + } + } -bool CocoLoader::ReadCocoBinBuff(char* pBinBuff) +bool CocoLoader::ReadCocoBinBuff(char* pBinBuff) { + if(m_pMemoryBuff)return true; char* pTempBuff = pBinBuff; - + m_pFileHeader = (stCocoFileHeader*)pTempBuff; pTempBuff += sizeof(stCocoFileHeader); - - char* pStartAddr = pTempBuff; - m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr; - - char* pAttrAddr = pStartAddr + m_pFileHeader->m_lAttribMemAddr ; - char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr; - char* pStringAddr = pStartAddr + m_pFileHeader->m_lStringMemAddr ; - - m_pRootNode = (stExpCocoNode*)pCocoMemAddr; - - if(1 == m_pFileHeader->m_nFirstUsed) - { - for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++) - { - m_pObjectDescArray[i].ReBuild(pAttrAddr,pStringAddr) ; - } - m_pRootNode->ReBuild(pCocoMemAddr,pStringAddr); - - m_pFileHeader->m_nFirstUsed = 0; + char* pStartAddr = m_pMemoryBuff = pTempBuff; + + if( m_pFileHeader->m_nCompressSize > 0 ) + { + char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; + uLongf dwSrcSize = m_pFileHeader->m_nCompressSize; + uLongf dwDestSize = m_pFileHeader->m_nDataSize; + int nRes = uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize); + pStartAddr = m_pMemoryBuff = pDestBuff; } - + + m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr; + + char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr; + + m_pRootNode = (stExpCocoNode*)pCocoMemAddr; + return true; } stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc) { - for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++) - { - if(0 == strcmp((char*)m_pObjectDescArray[i].m_szName,szObjDesc)) - { - return &m_pObjectDescArray[i]; - } - } - return NULL; + for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++) + { + if(0 == strcmp((char*)m_pObjectDescArray[i].m_szName,szObjDesc)) + { + return &m_pObjectDescArray[i]; + } + } + return NULL; +} + +stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex) +{ + if(vIndex >= 0 && vIndex < m_pFileHeader->m_ObjectCount) + { + return &m_pObjectDescArray[vIndex]; + } + return NULL; +} + +char* CocoLoader::GetMemoryAddr_AttribDesc() +{ + return m_pMemoryBuff + m_pFileHeader->m_lAttribMemAddr ; +} + +char* CocoLoader::GetMemoryAddr_CocoNode() +{ + return m_pMemoryBuff + m_pFileHeader->m_CocoNodeMemAddr; +} + +char* CocoLoader::GetMemoryAddr_String() +{ + return m_pMemoryBuff + m_pFileHeader->m_lStringMemAddr ; + } } diff --git a/cocos/editor-support/cocostudio/CocoLoader.h b/cocos/editor-support/cocostudio/CocoLoader.h index d728b0f396..4ead7b84b7 100644 --- a/cocos/editor-support/cocostudio/CocoLoader.h +++ b/cocos/editor-support/cocostudio/CocoLoader.h @@ -36,101 +36,80 @@ namespace cocostudio{ - +class CocoLoader; + struct stExpCocoAttribDesc { - rapidjson::Type m_Type; - uint64_t m_szName; - uint64_t m_szDefaultValue; + char m_cTypeName; + uint32_t m_szName; public: - - void ReBuild(char* pStringMemoryAddr) - { - m_szName = m_szName + (uint64_t)pStringMemoryAddr; - m_szDefaultValue = m_szDefaultValue + (uint64_t)pStringMemoryAddr; - } + char* GetName(CocoLoader* pCoco); }; struct stExpCocoObjectDesc { - uint32_t m_nAttribNum; - uint64_t m_szName; - uint64_t m_pAttribDescArray; - + unsigned char m_cAttribNum; + uint32_t m_szName; + uint32_t m_pAttribDescArray; public: - stExpCocoObjectDesc() - { - m_nAttribNum = 0; - m_szName = 0; - m_pAttribDescArray = 0; - } - void ReBuild(char* pAttribMemoryAddr,char* pStringMemoryAddr) - { - m_szName = m_szName + (uint64_t)pStringMemoryAddr; - m_pAttribDescArray = m_pAttribDescArray + (uint64_t)pAttribMemoryAddr; - stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*)m_pAttribDescArray; - for(uint32_t i = 0 ; i < m_nAttribNum ; i++) - { - tpAttribDescArray[i].ReBuild(pStringMemoryAddr); - } - } - + char* GetName(CocoLoader* pCoco); + int GetAttribNum(); + stExpCocoAttribDesc* GetAttribDescArray(CocoLoader* pCoco); }; - -class CocoLoader; -struct stExpCocoNode +struct stExpCocoNode { -protected: - int32_t m_ObjIndex; - int32_t m_AttribIndex; - uint32_t m_ChildNum; - uint64_t m_szValue; - uint64_t m_ChildArray; - public: - rapidjson::Type GetType(CocoLoader* pCoco); - char* GetName(CocoLoader* pCoco); - char* GetValue(); - int GetChildNum(); - stExpCocoNode* GetChildArray(); - + int16_t m_ObjIndex; + int16_t m_AttribIndex; + unsigned char m_ChildNum; + uint32_t m_szValue; + uint32_t m_ChildArray; public: - inline void ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr); - void WriteJson(CocoLoader* pCoco, void* pFileName = NULL, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false); + rapidjson::Type GetType(CocoLoader* pCoco); + char* GetName(CocoLoader* pCoco); + char* GetValue(CocoLoader* pCoco); + int GetChildNum(); + stExpCocoNode* GetChildArray(CocoLoader* pCoco); +public: + void WriteJson(CocoLoader* pCoco,void* pFileName = nullptr, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false); }; - struct stCocoFileHeader { - char m_FileDesc[32]; - char m_Version[32]; - uint32_t m_nFirstUsed; - uint32_t m_ObjectCount; - uint64_t m_lAttribMemAddr; - uint64_t m_CocoNodeMemAddr; - uint64_t m_lStringMemAddr; - + char m_FileDesc[32]; + char m_Version[32]; + uint32_t m_nDataSize; + uint32_t m_nCompressSize; + uint32_t m_ObjectCount; + uint32_t m_lAttribMemAddr; + uint32_t m_CocoNodeMemAddr; + uint32_t m_lStringMemAddr; + }; - class CocoLoader { -private: - stCocoFileHeader* m_pFileHeader; - stExpCocoNode* m_pRootNode; - stExpCocoObjectDesc* m_pObjectDescArray; - + stCocoFileHeader* m_pFileHeader; + stExpCocoNode* m_pRootNode; + stExpCocoObjectDesc* m_pObjectDescArray; + char* m_pMemoryBuff; + public: - CocoLoader(); - ~CocoLoader(); - + CocoLoader(); + ~CocoLoader(); public: - bool ReadCocoBinBuff(char* pBinBuff); - stCocoFileHeader* GetFileHeader(){return m_pFileHeader;} - stExpCocoNode* GetRootCocoNode(){return m_pRootNode;} - stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;} - stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc); + + bool ReadCocoBinBuff(char* pBinBuff); + stCocoFileHeader* GetFileHeader(){return m_pFileHeader;} + stExpCocoNode* GetRootCocoNode(){return m_pRootNode;} + stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;} + stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc); + stExpCocoObjectDesc* GetCocoObjectDesc(int vIndex); + char* GetMemoryAddr_AttribDesc(); + char* GetMemoryAddr_CocoNode(); + char* GetMemoryAddr_String(); + }; } diff --git a/cocos/editor-support/cocostudio/TriggerMng.cpp b/cocos/editor-support/cocostudio/TriggerMng.cpp index 2111a57e2e..5e90a13d71 100755 --- a/cocos/editor-support/cocostudio/TriggerMng.cpp +++ b/cocos/editor-support/cocostudio/TriggerMng.cpp @@ -111,7 +111,7 @@ void TriggerMng::parse(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCoc CCLOG("%s", triggerMngVersion()); int count = pCocoNode[13].GetChildNum(); - stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(); + stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader); #if CC_ENABLE_SCRIPT_BINDING ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); @@ -199,79 +199,78 @@ bool TriggerMng::isEmpty(void) const int size = 0; int extent = 0; int border = 0; - std::string key; - stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(); + std::string key0; + stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader); document.SetArray(); rapidjson::Document::AllocatorType& allocator = document.GetAllocator(); - for (int i = 0; i < count; ++i) + for (int i0 = 0; i0 < count; ++i0) { rapidjson::Value vElemItem(rapidjson::kObjectType); - border = pTriggersArray[i].GetChildNum(); - stExpCocoNode *pTriggerArray = pTriggersArray[i].GetChildArray(); - for (int i = 0; i < border; ++i) + border = pTriggersArray[i0].GetChildNum(); + stExpCocoNode *pTriggerArray = pTriggersArray[i0].GetChildArray(pCocoLoader); + for (int i1 = 0; i1 < border; ++i1) { - std::string key = pTriggerArray[i].GetName(pCocoLoader); - const char *str = pTriggerArray[i].GetValue(); - rapidjson::Type type = pTriggerArray[i].GetType(pCocoLoader); + std::string key1 = pTriggerArray[i1].GetName(pCocoLoader); + const char *str1 = pTriggerArray[i1].GetValue(pCocoLoader); - if (key.compare("actions") == 0) + if (key1.compare("actions") == 0) { rapidjson::Value actionsItem(rapidjson::kArrayType); - length = pTriggerArray[i].GetChildNum(); - stExpCocoNode *pActionsArray = pTriggerArray[i].GetChildArray(); - for (int i = 0; i < length; ++i) + length = pTriggerArray[i1].GetChildNum(); + stExpCocoNode *pActionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader); + for (int i2 = 0; i2 < length; ++i2) { rapidjson::Value action(rapidjson::kObjectType); - num = pActionsArray[i].GetChildNum(); - stExpCocoNode *pActionArray = pActionsArray[i].GetChildArray(); - for (int i = 0; i < num; ++i) + num = pActionsArray[i2].GetChildNum(); + stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader); + for (int i3 = 0; i3 < num; ++i3) { - std::string key = pActionArray[i].GetName(pCocoLoader); - const char *str = pActionArray[i].GetValue(); - if (key.compare("classname") == 0) + std::string key2 = pActionArray[i3].GetName(pCocoLoader); + const char *str2 = pActionArray[i3].GetValue(pCocoLoader); + if (key2.compare("classname") == 0) { - if (str != NULL) + if (str2 != NULL) { - action.AddMember("classname", str, allocator); + action.AddMember("classname", str2, allocator); } } - else if (key.compare("dataitems") == 0) + else if (key2.compare("dataitems") == 0) { rapidjson::Value dataitems(rapidjson::kArrayType); - size = pActionArray[i].GetChildNum(); - stExpCocoNode *pDataItemsArray = pActionArray[i].GetChildArray(); - for (int i = 0; i < size; ++i) + size = pActionArray[i3].GetChildNum(); + stExpCocoNode *pDataItemsArray = pActionArray[i3].GetChildArray(pCocoLoader); + for (int i4 = 0; i4 < size; ++i4) { rapidjson::Value dataitem(rapidjson::kObjectType); - extent = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - for (int i = 0; i < extent; ++i) + extent = pDataItemsArray[i4].GetChildNum(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i4].GetChildArray(pCocoLoader); + for (int i5 = 0; i5 < extent; ++i5) { - std::string key = pDataItemArray[i].GetName(pCocoLoader); - const char *str = pDataItemArray[i].GetValue(); - if (key.compare("key") == 0) + std::string key3 = pDataItemArray[i5].GetName(pCocoLoader); + const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader); + if (key3.compare("key") == 0) { - if (str != NULL) + if (str3 != NULL) { - dataitem.AddMember("key", str, allocator); + dataitem.AddMember("key", str3, allocator); } } else { - rapidjson::Type type = pDataItemArray[i].GetType(pCocoLoader); + rapidjson::Type type = pDataItemArray[i4].GetType(pCocoLoader); if (type == rapidjson::kStringType) { - dataitem.AddMember("value", str, allocator); + dataitem.AddMember("value", str3, allocator); } else if(type == rapidjson::kNumberType) { - int nV = atoi(str); - float fV = atof(str); + int nV = atoi(str3); + float fV = atof(str3); if (fabs(nV - fV) < 0.0000001) { dataitem.AddMember("value", nV, allocator); @@ -293,61 +292,61 @@ bool TriggerMng::isEmpty(void) const vElemItem.AddMember("actions", actionsItem, allocator); } - else if (key.compare("conditions") == 0) + else if (key1.compare("conditions") == 0) { rapidjson::Value condsItem(rapidjson::kArrayType); - length = pTriggerArray[i].GetChildNum(); - stExpCocoNode *pConditionsArray = pTriggerArray[i].GetChildArray(); - for (int i = 0; i < length; ++i) + length = pTriggerArray[i1].GetChildNum(); + stExpCocoNode *pConditionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader); + for (int i6 = 0; i6 < length; ++i6) { rapidjson::Value cond(rapidjson::kObjectType); - num = pConditionsArray[i].GetChildNum(); - stExpCocoNode *pConditionArray = pConditionsArray[i].GetChildArray(); - for (int i = 0; i < num; ++i) + num = pConditionsArray[i6].GetChildNum(); + stExpCocoNode *pConditionArray = pConditionsArray[i6].GetChildArray(pCocoLoader); + for (int i7 = 0; i7 < num; ++i7) { - std::string key = pConditionArray[i].GetName(pCocoLoader); - const char *str = pConditionArray[i].GetValue(); - if (key.compare("classname") == 0) + std::string key4 = pConditionArray[i7].GetName(pCocoLoader); + const char *str4 = pConditionArray[i7].GetValue(pCocoLoader); + if (key4.compare("classname") == 0) { - if (str != NULL) + if (str4 != NULL) { - cond.AddMember("classname", str, allocator); + cond.AddMember("classname", str4, allocator); } } - else if (key.compare("dataitems") == 0) + else if (key4.compare("dataitems") == 0) { rapidjson::Value dataitems(rapidjson::kArrayType); - size = pConditionArray[i].GetChildNum(); - stExpCocoNode *pDataItemsArray = pConditionArray[i].GetChildArray(); - for (int i = 0; i < size; ++i) + size = pConditionArray[i7].GetChildNum(); + stExpCocoNode *pDataItemsArray = pConditionArray[i7].GetChildArray(pCocoLoader); + for (int i8 = 0; i8 < size; ++i8) { rapidjson::Value dataitem(rapidjson::kObjectType); - extent = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - for (int i = 0; i < extent; ++i) + extent = pDataItemsArray[i8].GetChildNum(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i8].GetChildArray(pCocoLoader); + for (int i9 = 0; i9 < extent; ++i9) { - std::string key = pDataItemArray[i].GetName(pCocoLoader); - const char *str = pDataItemArray[i].GetValue(); - if (key.compare("key") == 0) + std::string key5 = pDataItemArray[i9].GetName(pCocoLoader); + const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader); + if (key5.compare("key") == 0) { - if (str != NULL) + if (str5 != NULL) { - dataitem.AddMember("key", str, allocator); + dataitem.AddMember("key", str5, allocator); } } else { - rapidjson::Type type = pDataItemArray[i].GetType(pCocoLoader); + rapidjson::Type type = pDataItemArray[i9].GetType(pCocoLoader); if (type == rapidjson::kStringType) { - dataitem.AddMember("value", str, allocator); + dataitem.AddMember("value", str5, allocator); } else if(type == rapidjson::kNumberType) { - int nV = atoi(str); - float fV = atof(str); + int nV = atoi(str5); + float fV = atof(str5); if (fabs(nV - fV) < 0.0000001) { dataitem.AddMember("value", nV, allocator); @@ -369,31 +368,31 @@ bool TriggerMng::isEmpty(void) const vElemItem.AddMember("conditions", condsItem, allocator); } - else if (key.compare("events") == 0) + else if (key1.compare("events") == 0) { rapidjson::Value eventsItem(rapidjson::kArrayType); - length = pTriggerArray[i].GetChildNum(); - stExpCocoNode *pEventsArray = pTriggerArray[i].GetChildArray(); - for (int i = 0; i < length; ++i) + length = pTriggerArray[i1].GetChildNum(); + stExpCocoNode *pEventsArray = pTriggerArray[i1].GetChildArray(pCocoLoader); + for (int i10 = 0; i10 < length; ++i10) { rapidjson::Value event(rapidjson::kObjectType); - stExpCocoNode *pEventArray = pEventsArray->GetChildArray(); - std::string key = pEventArray[0].GetName(pCocoLoader); - const char *str = pEventArray[0].GetValue(); - if (key.compare("id") == 0 && str != NULL) + stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader); + std::string key6 = pEventArray[0].GetName(pCocoLoader); + const char *str6 = pEventArray[0].GetValue(pCocoLoader); + if (key6.compare("id") == 0 && str6 != NULL) { - event.AddMember("id", atoi(str), allocator); + event.AddMember("id", atoi(str6), allocator); eventsItem.PushBack(event, allocator); } } vElemItem.AddMember("events", eventsItem, allocator); } - else if (key.compare("id") == 0) + else if (key1.compare("id") == 0) { - if (str != NULL) + if (str1 != NULL) { - vElemItem.AddMember("id", atoi(str), allocator); + vElemItem.AddMember("id", atoi(str1), allocator); } } } diff --git a/cocos/editor-support/cocostudio/TriggerObj.cpp b/cocos/editor-support/cocostudio/TriggerObj.cpp index c9ddd6dc35..444780de5e 100755 --- a/cocos/editor-support/cocostudio/TriggerObj.cpp +++ b/cocos/editor-support/cocostudio/TriggerObj.cpp @@ -246,33 +246,33 @@ void TriggerObj::serialize(const rapidjson::Value &val) int length = pCocoNode->GetChildNum(); int count = 0; int num = 0; - stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray(); - for (int i = 0; i < length; ++i) + stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray(pCocoLoader); + for (int i0 = 0; i0 < length; ++i0) { - std::string key = pTriggerObjArray[i].GetName(pCocoLoader); - const char* str = pTriggerObjArray[i].GetValue(); + std::string key = pTriggerObjArray[i0].GetName(pCocoLoader); + const char* str0 = pTriggerObjArray[i0].GetValue(pCocoLoader); if (key.compare("id") == 0) { - if (str != NULL) + if (str0 != NULL) { - _id = atoi(str); //(unsigned int)(DICTOOL->getIntValue_json(val, "id")); + _id = atoi(str0); //(unsigned int)(DICTOOL->getIntValue_json(val, "id")); } } else if (key.compare("conditions") == 0) { - count = pTriggerObjArray[i].GetChildNum(); - stExpCocoNode *pConditionsArray = pTriggerObjArray[i].GetChildArray(); - for (int i = 0; i < count; ++i) + count = pTriggerObjArray[i0].GetChildNum(); + stExpCocoNode *pConditionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader); + for (int i1 = 0; i1 < count; ++i1) { - num = pConditionsArray[i].GetChildNum(); - stExpCocoNode *pConditionArray = pConditionsArray[i].GetChildArray(); - const char *classname = pConditionArray[0].GetValue(); - if (classname == NULL) + num = pConditionsArray[i1].GetChildNum(); + stExpCocoNode *pConditionArray = pConditionsArray[i1].GetChildArray(pCocoLoader); + const char *classname = pConditionArray[0].GetValue(pCocoLoader); + if (classname == nullptr) { continue; } BaseTriggerCondition *con = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - CCAssert(con != NULL, "class named classname can not implement!"); + CCAssert(con != nullptr, "class named classname can not implement!"); con->serialize(pCocoLoader, &pConditionArray[1]); con->init(); _cons.pushBack(con); @@ -280,14 +280,14 @@ void TriggerObj::serialize(const rapidjson::Value &val) } else if (key.compare("actions") == 0) { - count = pTriggerObjArray[i].GetChildNum(); - stExpCocoNode *pActionsArray = pTriggerObjArray[i].GetChildArray(); - for (int i = 0; i < count; ++i) + count = pTriggerObjArray[i0].GetChildNum(); + stExpCocoNode *pActionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader); + for (int i2 = 0; i2 < count; ++i2) { - num = pActionsArray[i].GetChildNum(); - stExpCocoNode *pActionArray = pActionsArray[i].GetChildArray(); - const char *classname = pActionArray[0].GetValue(); - if (classname == NULL) + num = pActionsArray[i2].GetChildNum(); + stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader); + const char *classname = pActionArray[0].GetValue(pCocoLoader); + if (classname == nullptr) { continue; } @@ -300,18 +300,18 @@ void TriggerObj::serialize(const rapidjson::Value &val) } else if (key.compare("events") == 0) { - count = pTriggerObjArray[i].GetChildNum(); - stExpCocoNode *pEventsArray = pTriggerObjArray[i].GetChildArray(); - for (int i = 0; i < count; ++i) + count = pTriggerObjArray[i0].GetChildNum(); + stExpCocoNode *pEventsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader); + for (int i3 = 0; i3 < count; ++i3) { - num = pEventsArray[i].GetChildNum(); - stExpCocoNode *pEventArray = pEventsArray[i].GetChildArray(); - const char *str = pEventArray[0].GetValue(); - if (str == NULL) + num = pEventsArray[i3].GetChildNum(); + stExpCocoNode *pEventArray = pEventsArray[i3].GetChildArray(pCocoLoader); + const char *str1 = pEventArray[0].GetValue(pCocoLoader); + if (str1 == nullptr) { continue; } - int event = atoi(str); + int event = atoi(str1); if (event < 0) { continue; diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index 7fc1ea8177..c96a1dfbe7 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -63,7 +63,7 @@ namespace cocostudio Button *button = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); this->beginSetBasicProperties(widget); @@ -72,7 +72,7 @@ namespace cocostudio float scale9Width = 0.0f, scale9Height = 0.0f; for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); // CCLOG("Button: key = %s, value = %d", key.c_str(), i); //read all basic properties of widget @@ -86,8 +86,8 @@ namespace cocostudio } else if (key == P_NormalData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -98,8 +98,8 @@ namespace cocostudio } else if (key == P_PressedData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -110,8 +110,8 @@ namespace cocostudio } else if (key == P_DisabledData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -216,23 +216,18 @@ namespace cocostudio } } - bool cr = DICTOOL->checkObjectExist_json(options, P_TextColorR); - bool cg = DICTOOL->checkObjectExist_json(options, P_TextColorG); - bool cb = DICTOOL->checkObjectExist_json(options, P_TextColorB); - int cri = cr?DICTOOL->getIntValue_json(options, P_TextColorR):255; - int cgi = cg?DICTOOL->getIntValue_json(options, P_TextColorG):255; - int cbi = cb?DICTOOL->getIntValue_json(options, P_TextColorB):255; + + int cri = DICTOOL->getIntValue_json(options, P_TextColorR,255); + int cgi = DICTOOL->getIntValue_json(options, P_TextColorG,255); + int cbi = DICTOOL->getIntValue_json(options, P_TextColorB,255); button->setTitleColor(Color3B(cri,cgi,cbi)); - bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize); - if (fs) - { - button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize)); - } - bool fn = DICTOOL->checkObjectExist_json(options, P_FontName); - if (fn) - { - button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName)); - } + + + button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize,14)); + + + button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑")); + WidgetReader::setColorPropsFromJsonDictionary(widget, options); diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 6cf60f4f84..691097d1eb 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -43,11 +43,11 @@ namespace cocostudio CheckBox *checkBox = static_cast(widget); this->beginSetBasicProperties(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); // CCLOG("key = %s, index : %d", key.c_str(), i); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -56,8 +56,8 @@ namespace cocostudio else if (key == P_BackGroundBoxData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -65,8 +65,8 @@ namespace cocostudio checkBox->loadTextureBackGround(backgroundValue, imageFileNameType); }else if(key == P_BackGroundBoxSelectedData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -74,8 +74,8 @@ namespace cocostudio checkBox->loadTextureBackGroundSelected(backgroundValue, imageFileNameType); }else if(key == P_FrontCrossData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -83,8 +83,8 @@ namespace cocostudio checkBox->loadTextureFrontCross(backgroundValue, imageFileNameType); }else if(key == P_BackGroundBoxDisabledData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -92,8 +92,8 @@ namespace cocostudio checkBox->loadTextureBackGroundDisabled(backgroundValue, imageFileNameType); }else if (key == P_FrontCrossDisabledData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index bfc61f031e..4e8be4ac45 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -50,11 +50,11 @@ namespace cocostudio this->beginSetBasicProperties(widget); float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -65,8 +65,8 @@ namespace cocostudio imageView->setScale9Enabled(valueToBool(value)); } else if (key == P_FileNameData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -125,19 +125,16 @@ namespace cocostudio if (scale9Enable) { - bool sw = DICTOOL->checkObjectExist_json(options, P_Scale9Width); - bool sh = DICTOOL->checkObjectExist_json(options, P_Scale9Height); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width); - float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height); - imageView->setSize(Size(swf, shf)); - } + + float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f); + float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f); + imageView->setSize(Size(swf, shf)); + float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX); float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY); - float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth); - float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight); + float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1.0f); + float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1.0f); imageView->setCapInsets(Rect(cx, cy, cw, ch)); diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index b76c39f6b0..155e41d523 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -3,6 +3,9 @@ #include "LayoutReader.h" #include "ui/UILayout.h" #include "cocostudio/CocoLoader.h" +#include "ui/UIScrollView.h" +#include "ui/UIPageView.h" +#include "ui/UIListView.h" USING_NS_CC; using namespace ui; @@ -61,7 +64,7 @@ namespace cocostudio Layout* panel = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); this->beginSetBasicProperties(widget); int cr=0, cg = 0, cb = 0; @@ -69,12 +72,12 @@ namespace cocostudio int ecr=0, ecg=0, ecb= 0; float bgcv1 = 0.0f, bgcv2= 0.0f; float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; - Layout::Type layoutType; + Layout::Type layoutType = Layout::Type::ABSOLUTE; int bgColorOpacity = panel->getBackGroundColorOpacity(); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -120,9 +123,9 @@ namespace cocostudio panel->setBackGroundColorType(Layout::BackGroundColorType(valueToInt(value))); }else if (key == P_BackGroundImageData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); if (backGroundChildren) { - std::string resType = backGroundChildren[2].GetValue();; + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -194,26 +197,77 @@ namespace cocostudio bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, P_BackGroundScale9Enable); panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, P_BgColorR); - int cg = DICTOOL->getIntValue_json(options, P_BgColorG); - int cb = DICTOOL->getIntValue_json(options, P_BgColorB); - int scr = DICTOOL->getIntValue_json(options, P_BgStartColorR); - int scg = DICTOOL->getIntValue_json(options, P_BgStartColorG); - int scb = DICTOOL->getIntValue_json(options, P_BgStartColorB); - int ecr = DICTOOL->getIntValue_json(options, P_BgEndColorR); - int ecg = DICTOOL->getIntValue_json(options, P_BgEndColorG); - int ecb = DICTOOL->getIntValue_json(options, P_BgEndColorB); + int cr; + int cg; + int cb; + int scr; + int scg; + int scb; + int ecr; + int ecg; + int ecb; + + if (dynamic_cast(widget)) { + cr = DICTOOL->getIntValue_json(options, "bgColorR",150); + cg = DICTOOL->getIntValue_json(options, "bgColorG",150); + cb = DICTOOL->getIntValue_json(options, "bgColorB",100); + + scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255); + scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255); + scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255); + + ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",255); + ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150); + ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",100); + }else if(dynamic_cast(widget)){ + cr = DICTOOL->getIntValue_json(options, "bgColorR",150); + cg = DICTOOL->getIntValue_json(options, "bgColorG",150); + cb = DICTOOL->getIntValue_json(options, "bgColorB",255); + + scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255); + scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255); + scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255); + + ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",150); + ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150); + ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",255); + }else if(dynamic_cast(widget)){ + cr = DICTOOL->getIntValue_json(options, "bgColorR",255); + cg = DICTOOL->getIntValue_json(options, "bgColorG",150); + cb = DICTOOL->getIntValue_json(options, "bgColorB",100); + + scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255); + scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255); + scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255); + + ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",255); + ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150); + ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",100); + }else{ + cr = DICTOOL->getIntValue_json(options, "bgColorR",150); + cg = DICTOOL->getIntValue_json(options, "bgColorG",200); + cb = DICTOOL->getIntValue_json(options, "bgColorB",255); + + scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255); + scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255); + scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255); + + ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",150); + ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",200); + ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",255); + } float bgcv1 = DICTOOL->getFloatValue_json(options, P_VectorX); - float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY); + float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY,-0.5); panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2)); - int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity); + int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity,100); - int colorType = DICTOOL->getIntValue_json(options, P_ColorType); + int colorType = DICTOOL->getIntValue_json(options, P_ColorType,1); panel->setBackGroundColorType(Layout::BackGroundColorType(colorType)); + panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorOpacity(co); @@ -229,18 +283,21 @@ namespace cocostudio { float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX); float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY); - float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth); - float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight); + float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1); + float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1); panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, P_LayoutType)); - int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR); - int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG); - int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB); + int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR,255); + int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG,255); + int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB,255); panel->setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb)); + int bgimgopacity = DICTOOL->getIntValue_json(options, "opacity",255); + panel->setBackGroundImageOpacity(bgimgopacity); + WidgetReader::setColorPropsFromJsonDictionary(widget, options); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp index cf1bdbee4e..0870898954 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.cpp @@ -41,11 +41,11 @@ namespace cocostudio ListView* listView = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); if (key == P_Direction) { listView->setDirection((ScrollView::Direction)valueToInt(value)); @@ -66,10 +66,10 @@ namespace cocostudio ListView* listView = static_cast(widget); - int direction = DICTOOL->getFloatValue_json(options, P_Direction); + int direction = DICTOOL->getFloatValue_json(options, P_Direction,2); listView->setDirection((ScrollView::Direction)direction); - ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity); + ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity,3); listView->setGravity(gravity); float itemMargin = DICTOOL->getFloatValue_json(options, P_ItemMargin); diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp index 92c23aa86d..3c09400c96 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp @@ -51,11 +51,11 @@ namespace cocostudio float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; int percent = loadingBar->getPercent(); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -67,8 +67,8 @@ namespace cocostudio } else if (key == P_TextureData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -117,23 +117,25 @@ namespace cocostudio bool scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable); loadingBar->setScale9Enabled(scale9Enable); - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX); - float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY); - float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth); - float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight); - + + float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX); + float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY); + float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1); + float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1); + + if (scale9Enable) { loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); - - float width = DICTOOL->getFloatValue_json(options, P_Width); - float height = DICTOOL->getFloatValue_json(options, P_Height); - loadingBar->setSize(Size(width, height)); + } + + float width = DICTOOL->getFloatValue_json(options, P_Width); + float height = DICTOOL->getFloatValue_json(options, P_Height); + loadingBar->setSize(Size(width, height)); + /**/ loadingBar->setDirection(LoadingBar::Direction(DICTOOL->getIntValue_json(options, P_Direction))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent)); + loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent,100)); WidgetReader::setColorPropsFromJsonDictionary(widget, options); diff --git a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp index b2ab36cf47..6f03951944 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp @@ -44,12 +44,12 @@ namespace cocostudio ScrollView* scrollView = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); float innerWidth; float innerHeight; for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); if (key == P_InnerWidth) { innerWidth = valueToFloat(value); } @@ -72,10 +72,10 @@ namespace cocostudio ScrollView* scrollView = static_cast(widget); - float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth); - float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight); + float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth,200); + float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight,200); scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); - int direction = DICTOOL->getFloatValue_json(options, P_Direction); + int direction = DICTOOL->getFloatValue_json(options, P_Direction,1); scrollView->setDirection((ScrollView::Direction)direction); scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, P_BounceEnable)); diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index 311602e4fc..a4531be2e8 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -51,11 +51,11 @@ namespace cocostudio float barLength = 0.0f; int percent = slider->getPercent(); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -69,8 +69,8 @@ namespace cocostudio else if(key == P_Percent){ percent = valueToInt(value); }else if(key == P_BarFileNameData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -81,8 +81,8 @@ namespace cocostudio }else if(key == P_Length){ barLength = valueToFloat(value); }else if(key == P_BallNormalData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -91,8 +91,8 @@ namespace cocostudio slider->loadSlidBallTextureNormal(backgroundValue, imageFileNameType); }else if(key == P_BallPressedData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -101,8 +101,8 @@ namespace cocostudio slider->loadSlidBallTexturePressed(backgroundValue, imageFileNameType); }else if(key == P_BallDisabledData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -111,8 +111,8 @@ namespace cocostudio slider->loadSlidBallTextureDisabled(backgroundValue, imageFileNameType); }else if(key == P_ProgressBarData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -145,25 +145,24 @@ namespace cocostudio slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent)); - bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName); - float barLength = DICTOOL->getFloatValue_json(options, P_Length); - if (bt) - { - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType); - std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType); - slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType); +// bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName); + float barLength = DICTOOL->getFloatValue_json(options, P_Length,290); + const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData); + int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType); + std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType); + slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType); - if (barTextureScale9Enable) - { - slider->setContentSize(Size(barLength, slider->getContentSize().height)); - } + + + if (barTextureScale9Enable) + { + slider->setContentSize(Size(barLength, slider->getContentSize().height)); } //loading normal slider ball texture const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData); int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType); - std::string imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType); + imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType); slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp index d634c5cd39..b4ff2c7561 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp @@ -48,7 +48,7 @@ namespace cocostudio TextAtlas* labelAtlas = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); Widget::TextureResType type; std::string charMapFileName; std::string stringValue; @@ -57,7 +57,7 @@ namespace cocostudio float itemHeight; for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -68,8 +68,8 @@ namespace cocostudio stringValue = value; } else if(key == P_CharMapFileData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -101,34 +101,37 @@ namespace cocostudio std::string jsonPath = GUIReader::getInstance()->getFilePath(); TextAtlas* labelAtlas = static_cast(widget); - bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue); - bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile); - bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth); - bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight); - bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap); - if (sv && cmf && iw && ih && scm) +// bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue); +// bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile); +// bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth); +// bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight); +// bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap); + + const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData); + int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType); + switch (cmfType) { - const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData); - int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType); - switch (cmfType) + case 0: { - case 0: - { - std::string tp_c = jsonPath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path); - const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue),cmf_tp,DICTOOL->getIntValue_json(options, P_ItemWidth),DICTOOL->getIntValue_json(options,P_ItemHeight), DICTOOL->getStringValue_json(options, P_StartCharMap)); - break; - } - case 1: - CCLOG("Wrong res type of LabelAtlas!"); - break; - default: - break; + std::string tp_c = jsonPath; + const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path); + const char* cmf_tp = tp_c.append(cmfPath).c_str(); + labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue,"12345678"), + cmf_tp, + DICTOOL->getIntValue_json(options, P_ItemWidth,24), + DICTOOL->getIntValue_json(options,P_ItemHeight,32), + DICTOOL->getStringValue_json(options, P_StartCharMap)); + break; } + case 1: + CCLOG("Wrong res type of LabelAtlas!"); + break; + default: + break; } + WidgetReader::setColorPropsFromJsonDictionary(widget, options); } } diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp index f20326ba9b..99c6f3735a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp @@ -42,19 +42,19 @@ namespace cocostudio TextBMFont* labelBMFont = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER //read all color related properties of widget CC_COLOR_PROPERTY_BINARY_READER else if(key == P_FileNameData){ - stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); - std::string resType = backGroundChildren[2].GetValue();; + stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader); + std::string resType = backGroundChildren[2].GetValue(cocoLoader);; Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType); @@ -98,7 +98,7 @@ namespace cocostudio break; } - const char* text = DICTOOL->getStringValue_json(options, P_Text); + const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label"); labelBMFont->setString(text); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index 5f56526e03..5d844a5cff 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -49,11 +49,11 @@ namespace cocostudio TextField* textField = static_cast(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER @@ -94,19 +94,15 @@ namespace cocostudio bool ph = DICTOOL->checkObjectExist_json(options, P_PlaceHolder); if (ph) { - textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder)); - } - textField->setText(DICTOOL->getStringValue_json(options, P_Text)); - bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize); - if (fs) - { - textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize)); - } - bool fn = DICTOOL->checkObjectExist_json(options, P_FontName); - if (fn) - { - textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName)); + textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder,"input words here")); } + textField->setText(DICTOOL->getStringValue_json(options, P_Text,"Text Tield")); + + textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); + + + textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑")); + bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth); bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight); if (tsw && tsh) @@ -125,14 +121,14 @@ namespace cocostudio if (maxLengthEnable) { - int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength); + int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength,10); textField->setMaxLength(maxLength); } bool passwordEnable = DICTOOL->getBooleanValue_json(options, P_PasswordEnable); textField->setPasswordEnabled(passwordEnable); if (passwordEnable) { - textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText)); + textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText,"*")); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 808ab2002a..48c3d7dbfb 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -45,7 +45,7 @@ namespace cocostudio { this->beginSetBasicProperties(widget); - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); Text* label = static_cast(widget); @@ -54,7 +54,7 @@ namespace cocostudio for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); //read all basic properties of widget CC_BASIC_PROPERTY_BINARY_READER //read all color related properties of widget @@ -69,7 +69,12 @@ namespace cocostudio }else if(key == P_FontSize){ label->setFontSize(valueToInt(value)); }else if(key == P_FontName){ - std::string fontFilePath = jsonPath.append(value); + std::string fontFilePath; + if(FileUtils::getInstance()->isFileExist(value)){ + fontFilePath = jsonPath.append(value); + }else{ + fontFilePath = value; + } label->setFontName(fontFilePath); }else if(key == P_AreaWidth){ label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height)); @@ -95,20 +100,15 @@ namespace cocostudio Text* label = static_cast(widget); bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, P_TouchScaleEnable); label->setTouchScaleChangeEnabled(touchScaleChangeAble); - const char* text = DICTOOL->getStringValue_json(options, P_Text); + const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label"); label->setString(text); - bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize); - if (fs) - { - label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize)); - } - bool fn = DICTOOL->checkObjectExist_json(options, P_FontName); - if (fn) - { - std::string fontName = DICTOOL->getStringValue_json(options, P_FontName); - std::string fontFilePath = jsonPath.append(fontName); - label->setFontName(fontFilePath); - } + + label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20)); + + std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑"); + std::string fontFilePath = jsonPath.append(fontName); + label->setFontName(fontFilePath); + bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth); bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight); if (aw && ah) diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index aac6338629..06478699ae 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -113,11 +113,9 @@ namespace cocostudio void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) { - bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize); - if (ignoreSizeExsit) - { - widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize)); - } + + widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false)); + widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType)); widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType)); @@ -151,21 +149,15 @@ namespace cocostudio float x = DICTOOL->getFloatValue_json(options, P_X); float y = DICTOOL->getFloatValue_json(options, P_Y); widget->setPosition(Vec2(x,y)); - bool sx = DICTOOL->checkObjectExist_json(options, P_ScaleX); - if (sx) - { - widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX)); - } - bool sy = DICTOOL->checkObjectExist_json(options, P_ScaleY); - if (sy) - { - widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY)); - } - bool rt = DICTOOL->checkObjectExist_json(options, P_Rotation); - if (rt) - { - widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation)); - } + + widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX,1.0)); + + + widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY,1.0)); + + + widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation,0)); + bool vb = DICTOOL->checkObjectExist_json(options, P_Visbile); if (vb) { @@ -295,8 +287,8 @@ namespace cocostudio std::string WidgetReader::getResourcePath(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::ui::Widget::TextureResType texType) { - stExpCocoNode *backGroundChildren = cocoNode->GetChildArray(); - std::string backgroundValue = backGroundChildren[0].GetValue(); + stExpCocoNode *backGroundChildren = cocoNode->GetChildArray(cocoLoader); + std::string backgroundValue = backGroundChildren[0].GetValue(cocoLoader); if (backgroundValue.size() < 3) { return ""; @@ -346,13 +338,13 @@ namespace cocostudio void WidgetReader::setPropsFromBinary(cocos2d::ui::Widget *widget, cocostudio::CocoLoader *cocoLoader, cocostudio::stExpCocoNode *cocoNode) { - stExpCocoNode *stChildArray = cocoNode->GetChildArray(); + stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader); this->beginSetBasicProperties(widget); for (int i = 0; i < cocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(cocoLoader); - std::string value = stChildArray[i].GetValue(); + std::string value = stChildArray[i].GetValue(cocoLoader); CC_BASIC_PROPERTY_BINARY_READER } diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h index 25c5dbbe97..319b525190 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h @@ -176,14 +176,14 @@ namespace cocostudio }else if(key == P_ZOrder){ \ widget->setZOrder(valueToInt(value)); \ }else if(key == P_LayoutParameter){ \ - stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(); \ + stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(cocoLoader); \ ui::LinearLayoutParameter *linearParameter = ui::LinearLayoutParameter::create(); \ ui::RelativeLayoutParameter *relativeParameter = ui::RelativeLayoutParameter::create(); \ ui::Margin mg; \ int paramType = -1; \ for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) { \ std::string innerKey = layoutCocosNode[j].GetName(cocoLoader); \ - std::string innerValue = layoutCocosNode[j].GetValue(); \ + std::string innerValue = layoutCocosNode[j].GetValue(cocoLoader); \ if (innerKey == P_Type) { \ paramType = valueToInt(innerValue); \ }else if(innerKey == P_Gravity){ \ diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj index 272c82c41d..e7f9ef66f0 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj @@ -188,7 +188,7 @@ Disabled - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)external\win32-specific\zlib\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true 4267;4251;4244;%(DisableSpecificWarnings) diff --git a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj index 8002859cb3..f235f18d40 100644 --- a/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.wp8/libCocosStudio.vcxproj @@ -77,7 +77,7 @@ Use pch.h $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 4267;4251;4244;%(DisableSpecificWarnings) /Zm200 %(AdditionalOptions) diff --git a/cocos/editor-support/spine/Android.mk b/cocos/editor-support/spine/Android.mk index 144623d03e..afdbad89a3 100644 --- a/cocos/editor-support/spine/Android.mk +++ b/cocos/editor-support/spine/Android.mk @@ -36,9 +36,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/.. -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi - LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static include $(BUILD_STATIC_LIBRARY) diff --git a/cocos/network/Android.mk b/cocos/network/Android.mk index 1cdd0d5480..045a8d5eab 100644 --- a/cocos/network/Android.mk +++ b/cocos/network/Android.mk @@ -15,8 +15,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/.. -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static diff --git a/cocos/platform/android/ControllerAutoAdapter/.classpath b/cocos/platform/android/ControllerAutoAdapter/.classpath deleted file mode 100644 index 51769745b2..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/cocos/platform/android/ControllerAutoAdapter/.project b/cocos/platform/android/ControllerAutoAdapter/.project deleted file mode 100644 index c49a037939..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - libControllerAutoAdapter - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs b/cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b080d2ddc8..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml b/cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml deleted file mode 100644 index d1f4a837d8..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/cocos/platform/android/ControllerAutoAdapter/ant.properties b/cocos/platform/android/ControllerAutoAdapter/ant.properties deleted file mode 100644 index b0971e891e..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/ant.properties +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked into Version Control Systems, as it is -# integral to the build system of your project. - -# This file is only used by the Ant script. - -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. - -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. - diff --git a/cocos/platform/android/ControllerAutoAdapter/build.xml b/cocos/platform/android/ControllerAutoAdapter/build.xml deleted file mode 100644 index 413effd90c..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/build.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cocos/platform/android/ControllerAutoAdapter/libs/android-async-http-1.4.4.jar b/cocos/platform/android/ControllerAutoAdapter/libs/android-async-http-1.4.4.jar deleted file mode 100644 index 75af7015db..0000000000 Binary files a/cocos/platform/android/ControllerAutoAdapter/libs/android-async-http-1.4.4.jar and /dev/null differ diff --git a/cocos/platform/android/ControllerAutoAdapter/lint.xml b/cocos/platform/android/ControllerAutoAdapter/lint.xml deleted file mode 100644 index 55e8455701..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/lint.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cocos/platform/android/ControllerAutoAdapter/proguard-project.txt b/cocos/platform/android/ControllerAutoAdapter/proguard-project.txt deleted file mode 100644 index f2fe1559a2..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/cocos/platform/android/ControllerAutoAdapter/project.properties b/cocos/platform/android/ControllerAutoAdapter/project.properties deleted file mode 100644 index 9990d6c114..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/project.properties +++ /dev/null @@ -1,16 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -android.library=true -# Project target. -target=android-16 -android.library.reference.1=../java diff --git a/cocos/platform/android/ControllerAutoAdapter/res/.gitignore b/cocos/platform/android/ControllerAutoAdapter/res/.gitignore deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerActivity.java b/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerActivity.java deleted file mode 100644 index c38c34665c..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerActivity.java +++ /dev/null @@ -1,284 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2013 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ****************************************************************************/ -package org.cocos2dx.lib; - -import org.cocos2dx.lib.GameControllerDelegate.ControllerEventListener; -import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat; -import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListener; -import org.cocos2dx.lib.Cocos2dxActivity; - -import android.os.Bundle; -import android.view.InputDevice; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.util.Log; - -public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener { - // =========================================================== - // Constants - // =========================================================== - - private final static String TAG = GameControllerActivity.class.getSimpleName(); - - public static final int DRIVERTYPE_NIBIRU = 0; - public static final int DRIVERTYPE_MOGA = 1; - public static final int DRIVERTYPE_OUYA = 2; - public static final int DRIVERTYPE_STANDARD = 3; - public static final int DRIVERTYPE_UNKNOWN = 4; - - // =========================================================== - // Fields - // =========================================================== - private static GameControllerActivity sGameControllerActivity; - private InputManagerCompat mInputManager = null; - - protected GameControllerHelper mControllerHelper = null; - - protected GameControllerDelegate mControllerNibiru = null; - protected GameControllerDelegate mControllerMoga = null; - protected GameControllerDelegate mControllerOuya = null; - - public void connectController(){ - mControllerHelper.connectController(); - } - - public void setGameControllerInstance(GameControllerDelegate controllerDelegate, int driveType) { - if (driveType == DRIVERTYPE_NIBIRU) { - mControllerNibiru = controllerDelegate; - }else if (driveType == DRIVERTYPE_MOGA) { - mControllerMoga = controllerDelegate; - } - else if (driveType == DRIVERTYPE_OUYA) { - mControllerOuya = controllerDelegate; - } - controllerDelegate.setControllerEventListener(mControllerEventListener); - controllerDelegate.onCreate(sGameControllerActivity); - } - - public GameControllerDelegate getGameControllerDelegate(int driveType){ - if (driveType == DRIVERTYPE_NIBIRU) { - return mControllerNibiru; - }else if (driveType == DRIVERTYPE_MOGA) { - return mControllerMoga; - } - else if (driveType == DRIVERTYPE_OUYA) { - return mControllerOuya; - } - - return null; - } - - ControllerEventListener mControllerEventListener = new ControllerEventListener() { - - @Override - public void onButtonEvent(String vendorName, int controller, int button, - boolean isPressed, float value, boolean isAnalog) { - GameControllerAdapter.onButtonEvent(vendorName, controller, button, isPressed, value, isAnalog); - } - - @Override - public void onAxisEvent(String vendorName, int controller, int axisID, - float value, boolean isAnalog) { - GameControllerAdapter.onAxisEvent(vendorName, controller, axisID, value, isAnalog); - } - - @Override - public void onConnected(String vendorName, int controller) { - GameControllerAdapter.onConnected(vendorName, controller); - } - - @Override - public void onDisconnected(String vendorName, int controller) { - GameControllerAdapter.onDisconnected(vendorName, controller); - } - }; - - // =========================================================== - // Constructors - // =========================================================== - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - sGameControllerActivity = this; - mInputManager = InputManagerCompat.Factory.getInputManager(this); - mInputManager.registerInputDeviceListener(this, null); - - if (mControllerNibiru != null) { - mControllerNibiru.onCreate(this); - } - if (mControllerMoga != null) { - mControllerMoga.onCreate(this); - } - if (mControllerOuya != null) { - mControllerOuya.onCreate(this); - } - if (mControllerHelper == null) { - mControllerHelper = new GameControllerHelper(this); - } - } - - // =========================================================== - // Getter & Setter - // =========================================================== - - // =========================================================== - // Methods for/from SuperClass/Interfaces - // =========================================================== - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - boolean handled = false; - if (mControllerNibiru != null) { - handled |= mControllerNibiru.dispatchKeyEvent(event); - } - if (mControllerMoga != null) { - handled |= mControllerMoga.dispatchKeyEvent(event); - } - if (mControllerOuya != null) { - handled |= mControllerOuya.dispatchKeyEvent(event); - } - - handled |= mControllerHelper.dispatchKeyEvent(event); - Log.d(TAG, "dispatchKeyEvent:" + handled); - - return handled || super.dispatchKeyEvent(event); - } - - @Override - public boolean dispatchGenericMotionEvent(MotionEvent event) { - boolean handled = false; - if (mControllerNibiru != null) { - handled |= mControllerNibiru.dispatchGenericMotionEvent(event); - } - if (mControllerMoga != null) { - handled |= mControllerMoga.dispatchGenericMotionEvent(event); - } - if (mControllerOuya != null) { - handled |= mControllerOuya.dispatchGenericMotionEvent(event); - } - - handled |= mControllerHelper.dispatchGenericMotionEvent(event); - - return handled || super.dispatchGenericMotionEvent(event); - } - - @Override - public void onInputDeviceAdded(int deviceId) { - - Log.d(TAG,"onInputDeviceAdded:" + deviceId); - - InputDevice device = InputDevice.getDevice(deviceId); - int deviceSource = device.getSources(); - - if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ) - { - GameControllerAdapter.onConnected("Standard", deviceId); - } - } - /* - * This is an unusual case. Input devices don't typically change, but they - * certainly can --- for example a device may have different modes. We use - * this to make sure that the ship has an up-to-date InputDevice. - * - * @see - * com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener - * #onInputDeviceChanged(int) - */ - @Override - public void onInputDeviceChanged(int deviceId) { - Log.d(TAG,"onInputDeviceChanged:" + deviceId); - } - - /* - * Remove any ship associated with the ID. - * - * @see - * com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener - * #onInputDeviceRemoved(int) - */ - @Override - public void onInputDeviceRemoved(int deviceId) { - Log.d(TAG,"onInputDeviceRemoved:" + deviceId); - - InputDevice device = InputDevice.getDevice(deviceId); - int deviceSource = device.getSources(); - - if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ) - { - GameControllerAdapter.onDisconnected("Standard", deviceId); - } - } - - @Override - protected void onResume() { - super.onResume(); - - if (mControllerNibiru != null) { - mControllerNibiru.onResume(); - } - if (mControllerMoga != null) { - mControllerMoga.onResume(); - } - if (mControllerOuya != null) { - mControllerOuya.onResume(); - } - } - - @Override - protected void onPause() { - if (mControllerNibiru != null) { - mControllerNibiru.onPause(); - } - if (mControllerMoga != null) { - mControllerMoga.onPause(); - } - if (mControllerOuya != null) { - mControllerOuya.onPause(); - } - - super.onPause(); - } - - @Override - protected void onDestroy() { - if (mControllerNibiru != null) { - mControllerNibiru.onDestroy(); - } - if (mControllerMoga != null) { - mControllerMoga.onDestroy(); - } - if (mControllerOuya != null) { - mControllerOuya.onDestroy(); - } - - mControllerHelper.destrory(); - - super.onDestroy(); - } - -} \ No newline at end of file diff --git a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerHelper.java b/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerHelper.java deleted file mode 100644 index 52480b7524..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerHelper.java +++ /dev/null @@ -1,856 +0,0 @@ -package org.cocos2dx.lib; - -import java.io.File; -import java.io.FileOutputStream; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.apache.http.Header; - -import com.loopj.android.http.AsyncHttpClient; -import com.loopj.android.http.FileAsyncHttpResponseHandler; -import com.loopj.android.http.JsonHttpResponseHandler; - -import dalvik.system.DexClassLoader; -import android.bluetooth.BluetoothAdapter; -import android.bluetooth.BluetoothDevice; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.net.Uri; -import android.os.Environment; -import android.util.Log; -import android.util.SparseIntArray; -import android.view.InputDevice; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.widget.Toast; - -public class GameControllerHelper { - - private final static String TAG = GameControllerHelper.class.getSimpleName(); - - public static final String StandardControllerName = "Standard"; - public static final String[] DRIVERS_NAME = {"nibiru","moga","ouya",StandardControllerName}; - - public static final String SPP_UUID = "00001101-0000-1000-8000-00805F9B34FB"; - - SparseIntArray ControllerKeyMap; - - private static final String COCOS_CONTROLLER_URL = "http://115.28.134.83:9000/download/cocoscontroller/"; - private static final String COCOS_CONTROLLER_CONFIG = "controller.json"; - - private static final String NIBIRU_DEP_PACKAGE = "com.nibiru"; - private static final String MOGA__DEP_PACKAGE = "com.bda.pivot.mogapgp"; - - private static GameControllerActivity sGameControllerActivity; - private static GameControllerHelper sControllerHelper; - - private String mLibAdapterFileName; - private int mLibAdapterFileSize; - - private List mNibiruSupportedDrives; - private String mNibiruDepFileName; - private int mNibiruDepFileSize; - - private List mMogaSupportedDrives; - private String mMogaDepFileName; - private int mMogaDepFileSize; - - private List mOuyaSupportedDrives; - - private AsyncHttpClient mDownDepsHttpClient = null; - - private BluetoothAdapter mBluetoothAdapter = null; - private ArrayList mBluetoothDevices = null; - private SparseIntArray mDevicesDriver; - private int mClearDevices = 0; - - private String mConfigFilePath; - private String mLocalSavePath = null; - - private boolean mLazyInit = true; - private boolean mLazyConfigInit = true; - private static ControllerListener mControllerListener = null; - - public static interface ControllerListener{ - void onDownloadConfigStarted(); - void onDownloadConfigFinished(boolean isSuccess); - - void onControllerDiscoveryStarted(); - // - void onControllerDiscoveryFinish(ArrayList devices); - - void onDownloadDepsStarted(); - void onDownloadDepsProgress(int bytesWritten, int totalSize); - void onDownloadDepsFinished(boolean isSuccess); - - void onInstallDriver(String filePath); - void onConnectController(); - } - - public void setControllerListener(ControllerListener listener){ - mControllerListener = listener; - } - - private static final int AXIS_X = 0; - private static final int AXIS_Y = 1; - private static final int AXIS_Z = 11; - private static final int AXIS_RZ = 14; - public static final int AXIS_LTRIGGER = 17; - public static final int AXIS_RTRIGGER = 18; - public static final int AXIS_BRAKE = 23; - public static final int AXIS_THROTTLE = 19; - - public GameControllerHelper(GameControllerActivity activity){ - sGameControllerActivity = activity; - sControllerHelper = this; - - ControllerKeyMap = new SparseIntArray(25); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_A, GameControllerDelegate.BUTTON_A); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_B, GameControllerDelegate.BUTTON_B); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_C, GameControllerDelegate.BUTTON_C); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_X, GameControllerDelegate.BUTTON_X); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_Y, GameControllerDelegate.BUTTON_Y); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_Z, GameControllerDelegate.BUTTON_Z); - - ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_UP, GameControllerDelegate.BUTTON_DPAD_UP); - ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_DOWN, GameControllerDelegate.BUTTON_DPAD_DOWN); - ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_LEFT, GameControllerDelegate.BUTTON_DPAD_LEFT); - ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, GameControllerDelegate.BUTTON_DPAD_RIGHT); - ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_CENTER, GameControllerDelegate.BUTTON_DPAD_CENTER); - - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_THUMBL, GameControllerDelegate.BUTTON_LEFT_THUMBSTICK); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_THUMBR, GameControllerDelegate.BUTTON_RIGHT_THUMBSTICK); - - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_L1, GameControllerDelegate.BUTTON_LEFT_SHOULDER); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_R1, GameControllerDelegate.BUTTON_RIGHT_SHOULDER); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_L2, GameControllerDelegate.BUTTON_LEFT_TRIGGER); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_R2, GameControllerDelegate.BUTTON_RIGHT_TRIGGER); - - ControllerKeyMap.put(AXIS_X, GameControllerDelegate.THUMBSTICK_LEFT_X); - ControllerKeyMap.put(AXIS_Y, GameControllerDelegate.THUMBSTICK_LEFT_Y); - ControllerKeyMap.put(AXIS_Z, GameControllerDelegate.THUMBSTICK_RIGHT_X); - ControllerKeyMap.put(AXIS_RZ, GameControllerDelegate.THUMBSTICK_RIGHT_Y); - - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_START, GameControllerDelegate.BUTTON_START); - ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GameControllerDelegate.BUTTON_SELECT); - //KEYCODE_BUTTON_MODE - mDownDepsHttpClient = new AsyncHttpClient(); - mDownDepsHttpClient.setTimeout(360 * 1000); - } - - public void connectController(){ - if (mLazyInit) { - mLazyInit = false; - mNibiruSupportedDrives = new ArrayList(30); - mMogaSupportedDrives = new ArrayList(5); - mOuyaSupportedDrives = new ArrayList(5); - - mLocalSavePath = Environment.getExternalStorageDirectory() + File.separator + "CocosGameController" + File.separator; - Log.i(TAG, "mLocalSavePath:" + mLocalSavePath); - mConfigFilePath = sGameControllerActivity.getFilesDir().getAbsolutePath() + File.separator + COCOS_CONTROLLER_CONFIG; - Log.i(TAG, "mConfigFilePath:" + mConfigFilePath); - - } - - if (mControllerListener != null) { - mControllerListener.onDownloadConfigStarted(); - } - if (mLazyConfigInit) { - //if (mDownDepsHttpClient != null) { - // mDownDepsHttpClient.cancelRequests(sGameControllerActivity, true); - //} - requestControllerConfig(); - } - else { - scanBluetoothDrive(); - } - } - - public Set getBondedDevices(){ - if (mBluetoothAdapter == null) { - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (mBluetoothAdapter == null) { - return null; - } - } - - return mBluetoothAdapter.getBondedDevices(); - } - - public void destrory(){ - if (mDownDepsHttpClient != null) { - mDownDepsHttpClient.cancelRequests(sGameControllerActivity, true); - } - } - - private boolean scanBluetoothDrive(){ - if (mControllerListener != null) { - mControllerListener.onDownloadConfigFinished(true); - } - - if (mBluetoothAdapter == null) { - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (mBluetoothAdapter == null) { - return false; - } - - if (mBluetoothDevices == null) { - mBluetoothDevices = new ArrayList(5); - mDevicesDriver = new SparseIntArray(); - } - - IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); - //filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); - //filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); - //filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); - filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); - filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); - sGameControllerActivity.registerReceiver(mBluetoothReceiver, filter); - - IntentFilter appFilter = new IntentFilter(); - appFilter.addAction("android.intent.action.PACKAGE_ADDED"); - appFilter.addDataScheme("package"); - sGameControllerActivity.registerReceiver(mAppReceiver, appFilter); - } - - if (!mBluetoothAdapter.isEnabled()) { - mBluetoothAdapter.enable(); - } - - if (mBluetoothAdapter.isDiscovering()) { - mBluetoothAdapter.cancelDiscovery(); - } - - mBluetoothAdapter.startDiscovery(); - - return true; - } - - public int checkDriverType(BluetoothDevice device){ - String deviceName = device.getName(); - - if (mNibiruSupportedDrives.contains(deviceName)) { - return GameControllerActivity.DRIVERTYPE_NIBIRU; - } - else if (mMogaSupportedDrives.contains(deviceName)) { - return GameControllerActivity.DRIVERTYPE_MOGA; - } - else if (mOuyaSupportedDrives.contains(deviceName)) { - return GameControllerActivity.DRIVERTYPE_OUYA; - } - else { - - } - - return GameControllerActivity.DRIVERTYPE_UNKNOWN; - } - - public static void installApplication(String filePath){ - if (sGameControllerActivity != null) { - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive"); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - sGameControllerActivity.startActivity(intent); - } - } - - public static boolean checkApplication(String packName){ - try { - ApplicationInfo applicationInfo = sGameControllerActivity.getPackageManager().getApplicationInfo(packName, PackageManager.GET_UNINSTALLED_PACKAGES); - Log.d(TAG, applicationInfo.toString()); - return true; - } catch (NameNotFoundException e) { - return false; - } - } - - private BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - - if (BluetoothDevice.ACTION_FOUND.equals(action)) { - BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); - if (mBluetoothDevices.contains(device)) { - return; - } - Log.d(TAG, "Remote device discovered :" + device.getName()); - //We can't ensure non-controller can be filtered out.Some game controller marked with computer class. - /*String deviceName = device.getName(); - - if(device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.COMPUTER - || device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.PHONE) - { - Log.w(TAG, "Remote device discovered :" + deviceName + " is computer or phone." + device.getBluetoothClass().getMajorDeviceClass()); - return; - }*/ - - mBluetoothDevices.add(device); - int type = checkDriverType(device); - if (type != GameControllerActivity.DRIVERTYPE_UNKNOWN) { - mTargetDriverType = type; - mClearDevices += 1; - } - mDevicesDriver.append(mBluetoothDevices.size() - 1, type); - } - else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { - Log.d(TAG, "The local Bluetooth adapter has finished the device discovery process."); - - if (mControllerListener != null) { - mControllerListener.onControllerDiscoveryFinish(mBluetoothDevices); - } - else { - if (mBluetoothDevices.size() == 0) { - if (checkApplication(NIBIRU_DEP_PACKAGE)) { - downControllerDeps(GameControllerActivity.DRIVERTYPE_NIBIRU); - } - Log.w(TAG, "Not found any supported bluetooth game controller!"); - }else { - if (mClearDevices == 1 ) { - downControllerDeps(mTargetDriverType); - } - else { - Log.i(TAG, "Not clear target!"); - if (checkApplication(NIBIRU_DEP_PACKAGE)) { - downControllerDeps(GameControllerActivity.DRIVERTYPE_NIBIRU); - } - //todo:show sel - } - } - } - } - else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) { - Log.d(TAG, "The local Bluetooth adapter has started the remote device discovery process."); - if(mControllerListener != null){ - mControllerListener.onControllerDiscoveryStarted(); - } - - mBluetoothDevices.clear(); - mDevicesDriver.clear(); - mClearDevices = 0; - mTargetDriverType = GameControllerActivity.DRIVERTYPE_UNKNOWN; - - //check moga controller - Iterator it = mBluetoothAdapter.getBondedDevices().iterator(); - while (it.hasNext()) { - BluetoothDevice device = it.next(); - //if(device.getBluetoothClass().getMajorDeviceClass() != BluetoothClass.Device.Major.COMPUTER - // && device.getBluetoothClass().getMajorDeviceClass() != BluetoothClass.Device.Major.PHONE) - { - if (!mBluetoothDevices.contains(device)) { - mBluetoothDevices.add(device); - int type = checkDriverType(device); - Log.d(TAG, "BluetoothDevice objects that are bonded (paired) to the local adapter :" + device.getName()); - if (type != GameControllerActivity.DRIVERTYPE_UNKNOWN) { - mClearDevices += 1; - mTargetDriverType = type; - } - mDevicesDriver.append(mBluetoothDevices.size() - 1, type); - } - } - } - } - } - }; - - private static int depsCount = 0; - private static int mTargetDriverType = GameControllerActivity.DRIVERTYPE_UNKNOWN; - - private static int mDownloadTotalSize; - private static int mDownloadLibSize; - private static int mLibDownloadCompletedSize; - private static int mDepDownloadCompletedSize; - - public void downControllerDeps(int driverType){ - if (driverType != GameControllerActivity.DRIVERTYPE_NIBIRU - && driverType != GameControllerActivity.DRIVERTYPE_MOGA - && driverType != GameControllerActivity.DRIVERTYPE_OUYA) { - return; - } - - if (mControllerListener != null) { - mControllerListener.onDownloadDepsStarted(); - } - - mDownloadTotalSize = 0; - mLibDownloadCompletedSize = 0; - mDepDownloadCompletedSize = 0; - - mTargetDriverType = driverType; - depsCount = 1; - - GameControllerUtils.ensureDirectoryExist(mLocalSavePath); - - String remoteDir = COCOS_CONTROLLER_URL + DRIVERS_NAME[driverType] + File.separator; - - if (driverType == GameControllerActivity.DRIVERTYPE_NIBIRU) { - if (!checkApplication(NIBIRU_DEP_PACKAGE)) { - depsCount += 1; - mDownloadTotalSize += mNibiruDepFileSize; - mDownDepsHttpClient.get(remoteDir + mNibiruDepFileName, new MyDepsAsyncHandler( - new File(mLocalSavePath + mNibiruDepFileName), MyDepsAsyncHandler.FILETYPE_DEP_APK)); - } - } - else if (driverType == GameControllerActivity.DRIVERTYPE_MOGA) { - if (!checkApplication(MOGA__DEP_PACKAGE)) { - mDownloadTotalSize += mMogaDepFileSize; - depsCount += 1; - mDownDepsHttpClient.get(remoteDir + mMogaDepFileName, new MyDepsAsyncHandler( - new File(mLocalSavePath + mMogaDepFileName), MyDepsAsyncHandler.FILETYPE_DEP_APK)); - } - } - else if(driverType == GameControllerActivity.DRIVERTYPE_OUYA){ - - } - - File libFile = new File(mLocalSavePath + mLibAdapterFileName); - if (libFile.exists() && libFile.length() == mLibAdapterFileSize) { - depsCount -= 1; - if (depsCount == 0) { - onDepsReady(); - } - }else { - mDownloadLibSize = mLibAdapterFileSize; - mDownloadTotalSize += mDownloadLibSize; - mDownDepsHttpClient.get(COCOS_CONTROLLER_URL + mLibAdapterFileName, new MyDepsAsyncHandler( - new File(mLocalSavePath + mLibAdapterFileName), MyDepsAsyncHandler.FILETYPE_JAR)); - } - } - - static class MyDepsAsyncHandler extends FileAsyncHttpResponseHandler{ - - public static final int FILETYPE_DEP_APK = 0; - public static final int FILETYPE_JAR = 1; - - private int mFileType = FILETYPE_DEP_APK; - - public MyDepsAsyncHandler(File file, int fileType) { - super(file); - mFileType = fileType; - } - - @Override - public void onFailure(int statusCode, Header[] headers, - Throwable e, File file) { - if (mFileType == FILETYPE_JAR) { - if (file.exists() && file.length() == mDownloadLibSize) { - depsCount -= 1; - if (depsCount == 0) { - if (mControllerListener != null) { - mControllerListener.onDownloadDepsFinished(true); - } - sControllerHelper.onDepsReady(); - } - } - } - else if (mFileType == FILETYPE_DEP_APK) { - if (mControllerListener != null) { - mControllerListener.onDownloadDepsFinished(false); - } - } - - Log.e(TAG,"Failed to download:" + file.getName()); - } - - @Override - public void onProgress(int bytesWritten, int totalSize) { - if (mFileType == FILETYPE_JAR) { - mLibDownloadCompletedSize = bytesWritten; - } else { - mDepDownloadCompletedSize = bytesWritten; - } - if (mControllerListener != null) { - - mControllerListener.onDownloadDepsProgress(mLibDownloadCompletedSize + mDepDownloadCompletedSize, mDownloadTotalSize); - } - Log.d(TAG, "totalSize:" + totalSize + ", bytesWritten:" + bytesWritten); - } - - - public void onSuccess(File file) { - Log.d(TAG, "11Down file success:" + file.getName()); - - depsCount -= 1; - if (depsCount == 0) { - if (mControllerListener != null) { - mControllerListener.onDownloadDepsFinished(true); - } - sControllerHelper.onDepsReady(); - } - super.onSuccess(file); - } - - /*@Override - public void onSuccess(int arg0, Header[] arg1, File file) { - Log.d(TAG, "22Down file success:" + file.getName()); - - depsCount -= 1; - if (depsCount == 0) { - if (mControllerListener != null) { - mControllerListener.onDownloadDepsFinished(true); - } - sControllerHelper.onDepsReady(); - } - }*/ - } - - private void onDepsReady(){ - Log.d(TAG, "onDepsReady:" + mTargetDriverType); - - if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_NIBIRU) { - if (checkApplication(NIBIRU_DEP_PACKAGE)) { - createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType); - } - else { - if (mControllerListener != null) { - mControllerListener.onInstallDriver(mLocalSavePath + mMogaDepFileName); - } - installApplication(mLocalSavePath + mNibiruDepFileName); - } - } - else if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_MOGA) { - if (checkApplication(MOGA__DEP_PACKAGE)) { - createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType); - } - else { - if (mControllerListener != null) { - mControllerListener.onInstallDriver(mLocalSavePath + mMogaDepFileName); - } - installApplication(mLocalSavePath + mMogaDepFileName); - } - } - else if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_OUYA) { - createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType); - } - } - - private static final String CONFIGKEY_DRIVES = "drives"; - private static final String CONFIGKEY_LIBADAPTER_FILENAME = "adapter-file"; - private static final String CONFIGKEY_LIBADAPTER_FILESIZE = "adapter-filesize"; - private static final String CONFIGKEY_DEP_FILENAME = "dep-apk"; - private static final String CONFIGKEY_DEP_FILESIZE = "dep-size"; - - private boolean parseConfig(String jsonString){ - mMogaSupportedDrives.clear(); - mNibiruSupportedDrives.clear(); - mOuyaSupportedDrives.clear(); - - try { - int tint = 9879; - JSONObject jsonObject = new JSONObject(); - jsonObject.put("intvalue",tint); - Log.w(TAG, "intJson:" + jsonObject); - - JSONObject configObject = new JSONObject(jsonString); - mLibAdapterFileName = configObject.getString(CONFIGKEY_LIBADAPTER_FILENAME); - mLibAdapterFileSize = configObject.getInt(CONFIGKEY_LIBADAPTER_FILESIZE); - - JSONObject nibiruObject = configObject.getJSONObject("nibiru"); - JSONArray drives = nibiruObject.getJSONArray(CONFIGKEY_DRIVES); - int count = drives.length(); - for (int i = 0; i < count; i++) { - mNibiruSupportedDrives.add(drives.getString(i)); - } - mNibiruDepFileName = nibiruObject.getString(CONFIGKEY_DEP_FILENAME); - mNibiruDepFileSize = nibiruObject.getInt(CONFIGKEY_DEP_FILESIZE); - - JSONObject mogaObject = configObject.getJSONObject("moga"); - drives = mogaObject.getJSONArray(CONFIGKEY_DRIVES); - count = drives.length(); - for (int i = 0; i < count; i++) { - mMogaSupportedDrives.add(drives.getString(i)); - } - mMogaDepFileName = mogaObject.getString(CONFIGKEY_DEP_FILENAME); - mMogaDepFileSize = mogaObject.getInt(CONFIGKEY_DEP_FILESIZE); - - JSONObject ouyaObject = configObject.getJSONObject("ouya"); - drives = ouyaObject.getJSONArray(CONFIGKEY_DRIVES); - count = drives.length(); - for (int i = 0; i < count; i++) { - mOuyaSupportedDrives.add(drives.getString(i)); - } - - mLazyConfigInit = false; - return true; - } catch (Exception e1) { - e1.printStackTrace(); - return false; - } - } - - private void requestControllerConfig() { - - final JsonHttpResponseHandler configResponseHandler = new JsonHttpResponseHandler() { - - @Override - public void onFailure(int statusCode, Header[] headers, - String responseBody, Throwable e) { - - Log.e(TAG, "Failed to download game controller config!"); - - String configJSON = GameControllerUtils.readJsonFile(mConfigFilePath); - if (configJSON != null) { - if (parseConfig(configJSON)) { - scanBluetoothDrive(); - return; - } - } - if (mControllerListener != null) { - mControllerListener.onDownloadConfigFinished(false); - } - /*new AlertDialog.Builder(sCocos2dxActivity) - .setTitle("Loading controller config failed!") - .setMessage( - "Please make sure internet connection works ok!") - .setPositiveButton("Retry", - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - dialog.dismiss(); - requestControllerConfig(); - } - }).setCancelable(false).show();*/ - } - - @Override - public void onSuccess(int statusCode, Header[] headers, - String responseBody) { - - String jsonString = responseBody.trim(); - - try { - if (parseConfig(jsonString)) { - scanBluetoothDrive(); - showToast("Get controller config succeed!"); - - File configFile = new File(mConfigFilePath); - FileOutputStream outputStream = new FileOutputStream(configFile); - byte[] contentString = jsonString.getBytes(); - outputStream.write(contentString, 0, contentString.length); - outputStream.flush(); - outputStream.close(); - return; - } - else { - String jsonStr = GameControllerUtils.readJsonFile(mConfigFilePath); - if (jsonStr != null) { - if (parseConfig(jsonStr)) { - scanBluetoothDrive(); - showToast("Get controller config succeed!"); - return; - } - } - } - } catch (Exception e1) { - e1.printStackTrace(); - } - - if (mControllerListener != null) { - mControllerListener.onDownloadConfigFinished(false); - } - } - }; - - mDownDepsHttpClient.get(COCOS_CONTROLLER_URL + COCOS_CONTROLLER_CONFIG, configResponseHandler); - } - - private static void showToast(String message){ - Toast.makeText(sGameControllerActivity, message, Toast.LENGTH_SHORT).show(); - } - - private static void createControllerInstance(String libFilePath,int driveType) { - //if (sGameControllerActivity.getGameControllerDelegate(driveType) != null) { - // return; - //} - - File libFile = new File(libFilePath); - if (! libFile.exists()) { - Log.w(TAG, libFile.toString() + "not exist!"); - return; - } - - DexClassLoader classLoader = null; - - try { - File dexOutputDir = sGameControllerActivity.getDir("dex", Context.MODE_PRIVATE); - classLoader = new DexClassLoader(libFile.getCanonicalPath(), dexOutputDir.getCanonicalPath(), - null, sGameControllerActivity.getClassLoader()); - } catch (Exception e1) { - e1.printStackTrace(); - } - - try { - Class controllerDelegate = null; - if (driveType == GameControllerActivity.DRIVERTYPE_MOGA) { - controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerMoga"); - } else if (driveType == GameControllerActivity.DRIVERTYPE_NIBIRU) { - controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerNibiru"); - } else if (driveType == GameControllerActivity.DRIVERTYPE_OUYA) { - controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerOuya"); - } - - GameControllerDelegate instance = (GameControllerDelegate)controllerDelegate.newInstance(); - - if (mControllerListener != null) { - mControllerListener.onConnectController(); - } - sGameControllerActivity.setGameControllerInstance(instance, driveType); - if (driveType == GameControllerActivity.DRIVERTYPE_NIBIRU) { - Method method = controllerDelegate.getDeclaredMethod("onResume"); - method.invoke(instance); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private BroadcastReceiver mAppReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - String packageName = intent.getDataString(); - Log.d(TAG, "mAppReceiver:" + intent); - if (packageName.contains(NIBIRU_DEP_PACKAGE)) { - createControllerInstance(mLocalSavePath + mLibAdapterFileName, GameControllerActivity.DRIVERTYPE_NIBIRU); - } - else if (packageName.contains(MOGA__DEP_PACKAGE)) { - createControllerInstance(mLocalSavePath + mLibAdapterFileName, GameControllerActivity.DRIVERTYPE_MOGA); - } - } - }; - - private float mOldLeftThumbstickX = 0.0f; - private float mOldLeftThumbstickY = 0.0f; - private float mOldRightThumbstickX = 0.0f; - private float mOldRightThumbstickY = 0.0f; - - private float mOldLeftTrigger = 0.0f; - private float mOldRightTrigger = 0.0f; - private float mOldThrottle = 0.0f; - private float mOldBrake = 0.0f; - - public boolean dispatchGenericMotionEvent(MotionEvent event) { - boolean handled = false; - - int eventSource = event.getSource(); - - if ( ((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ) - { - if (event.getAction() == MotionEvent.ACTION_MOVE) { - int devicedId = event.getDeviceId(); - - float newAXIS_LX = event.getAxisValue(AXIS_X); - if (Float.compare(newAXIS_LX , mOldLeftThumbstickX) != 0) { - GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true); - mOldLeftThumbstickX = newAXIS_LX; - handled = true; - } - - float newAXIS_LY = event.getAxisValue(AXIS_Y); - if (Float.compare(newAXIS_LY , mOldLeftThumbstickY) != 0) { - GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true); - mOldLeftThumbstickY = newAXIS_LY; - handled = true; - } - - float newAXIS_RX = event.getAxisValue(AXIS_Z); - if (Float.compare(newAXIS_RX , mOldRightThumbstickX) != 0) { - GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true); - mOldRightThumbstickX = newAXIS_RX; - handled = true; - } - - float newAXIS_RY = event.getAxisValue(AXIS_RZ); - if (Float.compare(newAXIS_RY , mOldRightThumbstickY) != 0) { - GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true); - mOldRightThumbstickY = newAXIS_RY; - handled = true; - } - - float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER); - if (Float.compare(newAXIS_LTRIGGER , mOldLeftTrigger) != 0) { - if (Float.compare(newAXIS_LTRIGGER, 0.0f) == 0) { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, false, 0.0f, true); - }else { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, true, newAXIS_LTRIGGER, true); - } - mOldLeftTrigger = newAXIS_LTRIGGER; - handled = true; - } - - float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER); - if (Float.compare(newAXIS_RTRIGGER , mOldRightTrigger) != 0) { - if (Float.compare(newAXIS_RTRIGGER, 0.0f) == 0) { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, false, 0.0f, true); - }else { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, true, newAXIS_RTRIGGER, true); - } - mOldRightTrigger = newAXIS_RTRIGGER; - handled = true; - } - - float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE); - if (Float.compare(newAXIS_BRAKE , mOldBrake) != 0) { - if (Float.compare(newAXIS_BRAKE, 0.0f) == 0) { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, false, 0.0f, true); - }else { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, true, newAXIS_BRAKE, true); - } - mOldBrake = newAXIS_BRAKE; - handled = true; - } - - float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE); - if (Float.compare(newAXIS_THROTTLE , mOldThrottle) != 0) { - if (Float.compare(newAXIS_THROTTLE, 0.0f) == 0) { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, false, 0.0f, true); - }else { - GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, true, newAXIS_THROTTLE, true); - } - mOldThrottle = newAXIS_THROTTLE; - handled = true; - } - } - } - - return handled; - } - - public boolean dispatchKeyEvent(KeyEvent event) { - boolean handled = false; - - int eventSource = event.getSource(); - int controllerKey = ControllerKeyMap.get(event.getKeyCode()); - - if (controllerKey != 0 && (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) - || ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) - || ((eventSource & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD))) - { - int action = event.getAction(); - if (action == KeyEvent.ACTION_DOWN) { - handled = true; - GameControllerAdapter.onButtonEvent(StandardControllerName,event.getDeviceId(), controllerKey,true, 1.0f, false); - }else if (action == KeyEvent.ACTION_UP) { - handled = true; - GameControllerAdapter.onButtonEvent(StandardControllerName,event.getDeviceId(), controllerKey,false, 0.0f, false); - } - } - - return handled; - } -} diff --git a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerCompat.java b/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerCompat.java deleted file mode 100644 index 65b919bdae..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerCompat.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cocos2dx.lib.inputmanagercompat; - -import android.content.Context; -import android.os.Build; -import android.os.Handler; -import android.view.InputDevice; -import android.view.MotionEvent; - -public interface InputManagerCompat { - /** - * Gets information about the input device with the specified id. - * - * @param id The device id - * @return The input device or null if not found - */ - public InputDevice getInputDevice(int id); - - /** - * Gets the ids of all input devices in the system. - * - * @return The input device ids. - */ - public int[] getInputDeviceIds(); - - /** - * Registers an input device listener to receive notifications about when - * input devices are added, removed or changed. - * - * @param listener The listener to register. - * @param handler The handler on which the listener should be invoked, or - * null if the listener should be invoked on the calling thread's - * looper. - */ - public void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener, - Handler handler); - - /** - * Unregisters an input device listener. - * - * @param listener The listener to unregister. - */ - public void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener); - - /* - * The following three calls are to simulate V16 behavior on pre-Jellybean - * devices. If you don't call them, your callback will never be called - * pre-API 16. - */ - - /** - * Pass the motion events to the InputManagerCompat. This is used to - * optimize for polling for controllers. If you do not pass these events in, - * polling will cause regular object creation. - * - * @param event the motion event from the app - */ - public void onGenericMotionEvent(MotionEvent event); - - /** - * Tell the V9 input manager that it should stop polling for disconnected - * devices. You can call this during onPause in your activity, although you - * might want to call it whenever your game is not active (or whenever you - * don't care about being notified of new input devices) - */ - public void onPause(); - - /** - * Tell the V9 input manager that it should start polling for disconnected - * devices. You can call this during onResume in your activity, although you - * might want to call it less often (only when the gameplay is actually - * active) - */ - public void onResume(); - - public interface InputDeviceListener { - /** - * Called whenever the input manager detects that a device has been - * added. This will only be called in the V9 version when a motion event - * is detected. - * - * @param deviceId The id of the input device that was added. - */ - void onInputDeviceAdded(int deviceId); - - /** - * Called whenever the properties of an input device have changed since - * they were last queried. This will not be called for the V9 version of - * the API. - * - * @param deviceId The id of the input device that changed. - */ - void onInputDeviceChanged(int deviceId); - - /** - * Called whenever the input manager detects that a device has been - * removed. For the V9 version, this can take some time depending on the - * poll rate. - * - * @param deviceId The id of the input device that was removed. - */ - void onInputDeviceRemoved(int deviceId); - } - - /** - * Use this to construct a compatible InputManager. - */ - public static class Factory { - - /** - * Constructs and returns a compatible InputManger - * - * @param context the Context that will be used to get the system - * service from - * @return a compatible implementation of InputManager - */ - public static InputManagerCompat getInputManager(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return new InputManagerV16(context); - } else { - return new InputManagerV9(); - } - } - } -} diff --git a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV16.java b/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV16.java deleted file mode 100644 index f0d265adb0..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV16.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cocos2dx.lib.inputmanagercompat; - -import android.annotation.TargetApi; -import android.content.Context; -import android.hardware.input.InputManager; -import android.os.Build; -import android.os.Handler; -import android.view.InputDevice; -import android.view.MotionEvent; - -import java.util.HashMap; -import java.util.Map; - -@TargetApi(Build.VERSION_CODES.JELLY_BEAN) -public class InputManagerV16 implements InputManagerCompat { - - private final InputManager mInputManager; - private final Map mListeners; - - public InputManagerV16(Context context) { - mInputManager = (InputManager) context.getSystemService(Context.INPUT_SERVICE); - mListeners = new HashMap(); - } - - @Override - public InputDevice getInputDevice(int id) { - return mInputManager.getInputDevice(id); - } - - @Override - public int[] getInputDeviceIds() { - return mInputManager.getInputDeviceIds(); - } - - static class V16InputDeviceListener implements InputManager.InputDeviceListener { - final InputManagerCompat.InputDeviceListener mIDL; - - public V16InputDeviceListener(InputDeviceListener idl) { - mIDL = idl; - } - - @Override - public void onInputDeviceAdded(int deviceId) { - mIDL.onInputDeviceAdded(deviceId); - } - - @Override - public void onInputDeviceChanged(int deviceId) { - mIDL.onInputDeviceChanged(deviceId); - } - - @Override - public void onInputDeviceRemoved(int deviceId) { - mIDL.onInputDeviceRemoved(deviceId); - } - - } - - @Override - public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) { - V16InputDeviceListener v16Listener = new V16InputDeviceListener(listener); - mInputManager.registerInputDeviceListener(v16Listener, handler); - mListeners.put(listener, v16Listener); - } - - @Override - public void unregisterInputDeviceListener(InputDeviceListener listener) { - V16InputDeviceListener curListener = mListeners.remove(listener); - if (null != curListener) - { - mInputManager.unregisterInputDeviceListener(curListener); - } - - } - - @Override - public void onGenericMotionEvent(MotionEvent event) { - // unused in V16 - } - - @Override - public void onPause() { - // unused in V16 - } - - @Override - public void onResume() { - // unused in V16 - } - -} diff --git a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV9.java b/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV9.java deleted file mode 100644 index abb47a8719..0000000000 --- a/cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV9.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cocos2dx.lib.inputmanagercompat; - -import android.os.Handler; -import android.os.Message; -import android.os.SystemClock; -import android.util.Log; -import android.util.SparseArray; -import android.view.InputDevice; -import android.view.MotionEvent; - -import java.lang.ref.WeakReference; -import java.util.ArrayDeque; -import java.util.HashMap; -import java.util.Map; -import java.util.Queue; - -public class InputManagerV9 implements InputManagerCompat { - private static final String LOG_TAG = "InputManagerV9"; - private static final int MESSAGE_TEST_FOR_DISCONNECT = 101; - private static final long CHECK_ELAPSED_TIME = 3000L; - - private static final int ON_DEVICE_ADDED = 0; - private static final int ON_DEVICE_CHANGED = 1; - private static final int ON_DEVICE_REMOVED = 2; - - private final SparseArray mDevices; - private final Map mListeners; - private final Handler mDefaultHandler; - - private static class PollingMessageHandler extends Handler { - private final WeakReference mInputManager; - - PollingMessageHandler(InputManagerV9 im) { - mInputManager = new WeakReference(im); - } - - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - switch (msg.what) { - case MESSAGE_TEST_FOR_DISCONNECT: - InputManagerV9 imv = mInputManager.get(); - if (null != imv) { - long time = SystemClock.elapsedRealtime(); - int size = imv.mDevices.size(); - for (int i = 0; i < size; i++) { - long[] lastContact = imv.mDevices.valueAt(i); - if (null != lastContact) { - if (time - lastContact[0] > CHECK_ELAPSED_TIME) { - // check to see if the device has been - // disconnected - int id = imv.mDevices.keyAt(i); - if (null == InputDevice.getDevice(id)) { - // disconnected! - imv.notifyListeners(ON_DEVICE_REMOVED, id); - imv.mDevices.remove(id); - } else { - lastContact[0] = time; - } - } - } - } - sendEmptyMessageDelayed(MESSAGE_TEST_FOR_DISCONNECT, - CHECK_ELAPSED_TIME); - } - break; - } - } - - } - - public InputManagerV9() { - mDevices = new SparseArray(); - mListeners = new HashMap(); - mDefaultHandler = new PollingMessageHandler(this); - // as a side-effect, populates our collection of watched - // input devices - getInputDeviceIds(); - } - - @Override - public InputDevice getInputDevice(int id) { - return InputDevice.getDevice(id); - } - - @Override - public int[] getInputDeviceIds() { - // add any hitherto unknown devices to our - // collection of watched input devices - int[] activeDevices = InputDevice.getDeviceIds(); - long time = SystemClock.elapsedRealtime(); - for ( int id : activeDevices ) { - long[] lastContact = mDevices.get(id); - if ( null == lastContact ) { - // we have a new device - mDevices.put(id, new long[] { time }); - } - } - return activeDevices; - } - - @Override - public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) { - mListeners.remove(listener); - if (handler == null) { - handler = mDefaultHandler; - } - mListeners.put(listener, handler); - } - - @Override - public void unregisterInputDeviceListener(InputDeviceListener listener) { - mListeners.remove(listener); - } - - private void notifyListeners(int why, int deviceId) { - // the state of some device has changed - if (!mListeners.isEmpty()) { - // yes... this will cause an object to get created... hopefully - // it won't happen very often - for (InputDeviceListener listener : mListeners.keySet()) { - Handler handler = mListeners.get(listener); - DeviceEvent odc = DeviceEvent.getDeviceEvent(why, deviceId, listener); - handler.post(odc); - } - } - } - - private static class DeviceEvent implements Runnable { - private int mMessageType; - private int mId; - private InputDeviceListener mListener; - private static Queue sEventQueue = new ArrayDeque(); - - private DeviceEvent() { - } - - static DeviceEvent getDeviceEvent(int messageType, int id, - InputDeviceListener listener) { - DeviceEvent curChanged = sEventQueue.poll(); - if (null == curChanged) { - curChanged = new DeviceEvent(); - } - curChanged.mMessageType = messageType; - curChanged.mId = id; - curChanged.mListener = listener; - return curChanged; - } - - @Override - public void run() { - switch (mMessageType) { - case ON_DEVICE_ADDED: - mListener.onInputDeviceAdded(mId); - break; - case ON_DEVICE_CHANGED: - mListener.onInputDeviceChanged(mId); - break; - case ON_DEVICE_REMOVED: - mListener.onInputDeviceRemoved(mId); - break; - default: - Log.e(LOG_TAG, "Unknown Message Type"); - break; - } - // dump this runnable back in the queue - sEventQueue.offer(this); - } - } - - @Override - public void onGenericMotionEvent(MotionEvent event) { - // detect new devices - int id = event.getDeviceId(); - long[] timeArray = mDevices.get(id); - if (null == timeArray) { - notifyListeners(ON_DEVICE_ADDED, id); - timeArray = new long[1]; - mDevices.put(id, timeArray); - } - long time = SystemClock.elapsedRealtime(); - timeArray[0] = time; - } - - @Override - public void onPause() { - mDefaultHandler.removeMessages(MESSAGE_TEST_FOR_DISCONNECT); - } - - @Override - public void onResume() { - mDefaultHandler.sendEmptyMessage(MESSAGE_TEST_FOR_DISCONNECT); - } - -} 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 3aa43b7a1c..afa4c1df66 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 @@ -945,6 +945,7 @@ ); "OTHER_LDFLAGS[arch=arm64]" = "-llua"; "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; + "OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../platform/ios"; @@ -970,6 +971,7 @@ ); "OTHER_LDFLAGS[arch=arm64]" = "-llua"; "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; + "OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../platform/ios"; diff --git a/cocos/ui/Android.mk b/cocos/ui/Android.mk index 4c6e33334e..fed4a17385 100644 --- a/cocos/ui/Android.mk +++ b/cocos/ui/Android.mk @@ -41,8 +41,6 @@ $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../.. \ $(LOCAL_PATH)/../editor-support -LOCAL_CFLAGS += -Wno-psabi -LOCAL_EXPORT_CFLAGS += -Wno-psabi LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index 1cbbd901c0..90b65063ca 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -623,7 +623,6 @@ bool TextField::isPasswordEnabled()const void TextField::setPasswordStyleText(const char *styleText) { _textFieldRenderer->setPasswordStyleText(styleText); - _passwordStyleText = styleText; setText(getStringValue()); diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index f130130767..8133421da1 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -747,20 +747,6 @@ "cocos/platform/android/CCGLView.h", "cocos/platform/android/CCPlatformDefine.h", "cocos/platform/android/CCStdC.h", - "cocos/platform/android/ControllerAutoAdapter/.classpath", - "cocos/platform/android/ControllerAutoAdapter/.project", - "cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs", - "cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml", - "cocos/platform/android/ControllerAutoAdapter/ant.properties", - "cocos/platform/android/ControllerAutoAdapter/build.xml", - "cocos/platform/android/ControllerAutoAdapter/lint.xml", - "cocos/platform/android/ControllerAutoAdapter/proguard-project.txt", - "cocos/platform/android/ControllerAutoAdapter/project.properties", - "cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerActivity.java", - "cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerHelper.java", - "cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerCompat.java", - "cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV16.java", - "cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV9.java", "cocos/platform/android/ControllerManualAdapter/.classpath", "cocos/platform/android/ControllerManualAdapter/.project", "cocos/platform/android/ControllerManualAdapter/.settings/org.eclipse.jdt.core.prefs", diff --git a/templates/cpp-template-default/proj.android/jni/Application.mk b/templates/cpp-template-default/proj.android/jni/Application.mk index edd61073c3..93c859c1b0 100644 --- a/templates/cpp-template-default/proj.android/jni/Application.mk +++ b/templates/cpp-template-default/proj.android/jni/Application.mk @@ -1,5 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Application.mk b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Application.mk index edd61073c3..93c859c1b0 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Application.mk @@ -1,5 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk index edd61073c3..93c859c1b0 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk @@ -1,5 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic + APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/tests/cpp-empty-test/proj.android/jni/Application.mk b/tests/cpp-empty-test/proj.android/jni/Application.mk index 2ccd787827..93c859c1b0 100644 --- a/tests/cpp-empty-test/proj.android/jni/Application.mk +++ b/tests/cpp-empty-test/proj.android/jni/Application.mk @@ -1,8 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic -# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] -# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp b/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp index 5d8544dcd7..ee1dd9f4e3 100644 --- a/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp +++ b/tests/cpp-tests/Classes/CurlTest/CurlTest.cpp @@ -33,13 +33,13 @@ void CurlTest::onTouchesEnded(const std::vector& touches, Event *event) curl = curl_easy_init(); if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, "baidu.com"); + curl_easy_setopt(curl, CURLOPT_URL, "http://webtest.cocos2d-x.org/curltest"); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); if (res == 0) { - _label->setString("0 response"); + _label->setString("Connect successfully!"); } else { diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp index d637c7c9c6..f9c9f39337 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp @@ -69,15 +69,15 @@ void PlayMusic::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -169,15 +169,15 @@ void TMoveTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -291,15 +291,15 @@ void TMoveBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -404,15 +404,15 @@ void TRotateTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -517,15 +517,15 @@ void TRotateBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -627,15 +627,15 @@ void TScaleTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -751,15 +751,15 @@ void TScaleBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -869,15 +869,15 @@ void TSkewTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -992,15 +992,15 @@ void TSkewBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -1106,15 +1106,15 @@ void TriggerState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::st { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "ID") { if (str != NULL) @@ -1195,15 +1195,15 @@ void ArmaturePlayAction::serialize(cocostudio::CocoLoader *pCocoLoader, cocostud { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp index 18beb3cae4..a33b2bd455 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp @@ -51,15 +51,15 @@ void TimeElapsed::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "TotalTime") { if (str != NULL) @@ -151,15 +151,15 @@ void ArmatureActionState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostu { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -279,15 +279,15 @@ void NodeInRect::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stEx { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) @@ -381,15 +381,15 @@ void NodeVisible::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE { int length = pCocoNode->GetChildNum(); int count = 0; - stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(); + stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader); std::string key; const char *str = NULL; for (int i = 0; i < length; ++i) { count = pDataItemsArray[i].GetChildNum(); - stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(); - key = pDataItemArray[0].GetValue(); - str = pDataItemArray[1].GetValue(); + stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader); + key = pDataItemArray[0].GetValue(pCocoLoader); + str = pDataItemArray[1].GetValue(pCocoLoader); if (key == "Tag") { if (str != NULL) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 6424599248..1ad294deec 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "NodeTest.h" +#include #include "../testResource.h" enum @@ -1274,28 +1275,28 @@ void NodeNameTest::test(float dt) // enumerateChildren() // name = regular expression int i = 0; -// parent = Node::create(); -// for (int i = 0; i < 100; ++i) -// { -// auto node = Node::create(); -// sprintf(name, "node%d", i); -// node->setName(name); -// parent->addChild(node); -// } -// -// i = 0; -// parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 100, ""); -// -// i = 0; -// parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return true; -// }); -// CCAssert(i == 1, ""); + parent = Node::create(); + for (int i = 0; i < 100; ++i) + { + auto node = Node::create(); + sprintf(name, "node%d", i); + node->setName(name); + parent->addChild(node); + } + + i = 0; + parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool { + ++i; + return false; + }); + CCAssert(i == 100, ""); + + i = 0; + parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool { + ++i; + return true; + }); + CCAssert(i == 1, ""); // enumerateChildren @@ -1332,118 +1333,105 @@ void NodeNameTest::test(float dt) CCAssert(i == 1, ""); // search from root - parent = getScene(); + parent = Node::create(); for (int i = 0; i < 100; ++i) { auto node = Node::create(); - node->setName("node"); + sprintf(name, "node%d", i); + node->setName(name); parent->addChild(node); for (int j = 0; j < 100; ++j) { auto child = Node::create(); - child->setName("child"); + child->setName("node"); node->addChild(child); } } i = 0; - parent->enumerateChildren("/node", [&i](Node* node) -> bool { + parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool { + ++i; + return false; + }); + CCAssert(i == 10000, ""); + + i = 0; + parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool { + ++i; + return true; + }); + CCAssert(i == 1, ""); + + // search from parent + // name is xxx/.. + i = 0; + parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + ++i; + return true; + }); + CCAssert(i == 1, ""); + + i = 0; + parent->enumerateChildren("node/..", [&i](Node* node) -> bool { + ++i; + return false; + }); + CCAssert(i == 10000, ""); + + // name = /xxx : search from root + parent = getScene(); + for (int j = 0; j < 100; j++) + { + auto node = Node::create(); + sprintf(name, "node%d", j); + node->setName(name); + parent->addChild(node); + + for (int k = 0; k < 100; ++k) + { + auto child = Node::create(); + sprintf(name, "node%d", k); + child->setName(name); + node->addChild(child); + } + } + + i = 0; + enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool { ++i; return false; }); CCAssert(i == 100, ""); i = 0; - parent->enumerateChildren("//child", [&i](Node* node) -> bool { + enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool { + ++i; + return true; + }); + CCAssert(i == 1, ""); + + i = 0; + enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool { + ++i; + return false; + }); + CCAssert(i == 10100, ""); // 10000(children) + 100(parent) + + i = 0; + enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool { + ++i; + return true; + }); + CCAssert(i == 1, ""); + + i = 0; + enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { ++i; return false; }); CCAssert(i == 10000, ""); -// i = 0; -// parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 10000, ""); -// -// i = 0; -// parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool { -// ++i; -// return true; -// }); -// CCAssert(i == 1, ""); - - // search from parent - // name is xxx/.. -// i = 0; -// parent->enumerateChildren("node/..", [&i](Node* node) -> bool { -// ++i; -// return true; -// }); -// CCAssert(i == 1, ""); -// -// i = 0; -// parent->enumerateChildren("node/..", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 10000, ""); - - // name = /xxx : search from root -// parent = getScene(); -// for (int j = 0; j < 100; j++) -// { -// auto node = Node::create(); -// sprintf(name, "node%d", j); -// node->setName(name); -// parent->addChild(node); -// -// for (int k = 0; k < 100; ++k) -// { -// auto child = Node::create(); -// sprintf(name, "node%d", k); -// child->setName(name); -// node->addChild(child); -// } -// } -// -// i = 0; -// enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 100, ""); - -// i = 0; -// enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return true; -// }); -// CCAssert(i == 1, ""); -// -// i = 0; -// enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 10100, ""); // 10000(children) + 100(parent) -// -// i = 0; -// enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool { -// ++i; -// return true; -// }); -// CCAssert(i == 1, ""); -// -// i = 0; -// enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool { -// ++i; -// return false; -// }); -// CCAssert(i == 10000, ""); - // utils::findChildren() parent = Node::create(); diff --git a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp index 9df7f7cad5..9b895e65bf 100644 --- a/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp +++ b/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp @@ -43,7 +43,7 @@ namespace CLN(TMXIsoTest1New), CLN(TMXIsoTest2New), CLN(TMXUncompressedTestNew), - //CLN(TMXHexTestNew), + CLN(TMXHexTestNew), CLN(TMXReadWriteTestNew), CLN(TMXTilesetTestNew), CLN(TMXOrthoObjectsTestNew), @@ -55,8 +55,8 @@ namespace CLN(TMXOrthoFlipRunTimeTestNew), CLN(TMXOrthoFromXMLTestNew), CLN(TMXOrthoXMLFormatTestNew), -// CLN(TileMapTestNew), -// CLN(TileMapEditTestNew), + CLN(TileMapTestNew), + CLN(TileMapEditTestNew), CLN(TMXBug987New), CLN(TMXBug787New), CLN(TMXGIDObjectsTestNew), diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp index f882651fdf..ad4ed1b84e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp @@ -6,6 +6,7 @@ // UILoadingBarTest_Editor UILoadingBarTest_Editor::UILoadingBarTest_Editor() +:_count(0) { } diff --git a/tests/cpp-tests/Resources/ccs-res b/tests/cpp-tests/Resources/ccs-res index 2173b0b479..6b28e94848 160000 --- a/tests/cpp-tests/Resources/ccs-res +++ b/tests/cpp-tests/Resources/ccs-res @@ -1 +1 @@ -Subproject commit 2173b0b479e0e7be62df9ded754b20e75e74b0f2 +Subproject commit 6b28e948482ca7ed44c31daf3fef2e42ad6b59fb diff --git a/tests/cpp-tests/proj.android/jni/Application.mk b/tests/cpp-tests/proj.android/jni/Application.mk index cdd0d48ce0..362124d303 100644 --- a/tests/cpp-tests/proj.android/jni/Application.mk +++ b/tests/cpp-tests/proj.android/jni/Application.mk @@ -1,8 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic -# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] -# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -Wno-literal-suffix -fsigned-char APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) diff --git a/tests/game-controller-test/Classes/GameControllerTest.cpp b/tests/game-controller-test/Classes/GameControllerTest.cpp index 0f9f860a4d..9e535b6d64 100644 --- a/tests/game-controller-test/Classes/GameControllerTest.cpp +++ b/tests/game-controller-test/Classes/GameControllerTest.cpp @@ -283,32 +283,6 @@ void GameControllerTest::onAxisEvent(cocos2d::Controller* controller, int keyCod } } -void GameControllerTest::update(float dt) -{ - /*if (_player1 && _player1->isConnected()) - { - auto gamePad = _player1->getGamepad(); - - Vec2 newPos = _leftActor->getPosition(); - newPos.x += gamePad->getLeftThumbstick()->getAxisX()->getValue(); - newPos.y -= gamePad->getLeftThumbstick()->getAxisY()->getValue(); - adjustActorPos(newPos); - _leftActor->setPosition(newPos); - - newPos = _rightActor->getPosition(); - newPos.x += gamePad->getRightThumbstick()->getAxisX()->getValue(); - newPos.y -= gamePad->getRightThumbstick()->getAxisY()->getValue(); - adjustActorPos(newPos); - _rightActor->setPosition(newPos); - - char triggerStatus[50]; - sprintf(triggerStatus,"left trigger:%f",gamePad->getLeftTrigger()->getValue()); - _leftTriggerLabel->setString(triggerStatus); - sprintf(triggerStatus,"right trigger:%f",gamePad->getRightTrigger()->getValue()); - _rightTriggerLabel->setString(triggerStatus); - }*/ -} - bool GameControllerTest::init() { if ( !Layer::init() ) @@ -341,7 +315,7 @@ bool GameControllerTest::init() auto menu = Menu::create(closeItem,nullptr); menu->setPosition(Vec2::ZERO); this->addChild(menu); - + registerControllerListener(); return true; @@ -376,7 +350,7 @@ void GameControllerTest::createControllerSprite(ControllerHolder& holder) holder._holderNode->addChild(holder._deviceIdLabel); //----------------------------------------------------------------- //371,294 64 - auto dPadTexture = Director::sharedDirector()->getTextureCache()->addImage("dPad.png"); + auto dPadTexture = Director::getInstance()->getTextureCache()->addImage("dPad.png"); auto dPadCenter = Sprite::createWithTexture(dPadTexture,Rect(60,60,68,68)); dPadCenter->setPosition(Vec2(371,294)); diff --git a/tests/game-controller-test/Classes/GameControllerTest.h b/tests/game-controller-test/Classes/GameControllerTest.h index f2a2e6fd3e..26b843e534 100644 --- a/tests/game-controller-test/Classes/GameControllerTest.h +++ b/tests/game-controller-test/Classes/GameControllerTest.h @@ -18,9 +18,9 @@ public: void onKeyDown(cocos2d::Controller* controller, int keyCode, cocos2d::Event* event); void onKeyUp(cocos2d::Controller* controller, int keyCode, cocos2d::Event* event); void onAxisEvent(cocos2d::Controller* controller, int keyCode, cocos2d::Event* event); - - void update(float dt); + void menuCloseCallback(Ref* sender); + private: float _visibleCentreX; float _visibleCentreY; diff --git a/tests/game-controller-test/proj.android/jni/Application.mk b/tests/game-controller-test/proj.android/jni/Application.mk index f0582bf96e..93c859c1b0 100644 --- a/tests/game-controller-test/proj.android/jni/Application.mk +++ b/tests/game-controller-test/proj.android/jni/Application.mk @@ -1,8 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic -# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] -# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) diff --git a/tests/lua-empty-test/project/proj.android/jni/Application.mk b/tests/lua-empty-test/project/proj.android/jni/Application.mk index 2ccd787827..93c859c1b0 100644 --- a/tests/lua-empty-test/project/proj.android/jni/Application.mk +++ b/tests/lua-empty-test/project/proj.android/jni/Application.mk @@ -1,8 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic -# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] -# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/tests/lua-tests/project/proj.android/jni/Application.mk b/tests/lua-tests/project/proj.android/jni/Application.mk index 2ccd787827..93c859c1b0 100644 --- a/tests/lua-tests/project/proj.android/jni/Application.mk +++ b/tests/lua-tests/project/proj.android/jni/Application.mk @@ -1,8 +1,9 @@ -APP_STL := gnustl_static +APP_STL := c++_static +NDK_TOOLCHAIN_VERSION=clang + +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_LDFLAGS := -latomic -# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] -# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9 -APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char APP_DEBUG := $(strip $(NDK_DEBUG)) ifeq ($(APP_DEBUG),1) @@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1) else APP_CPPFLAGS += -DNDEBUG APP_OPTIM := release -endif +endif \ No newline at end of file diff --git a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua index c1952acf71..19298ad2e2 100644 --- a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua +++ b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua @@ -1,4 +1,5 @@ local size = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() ---------------------------------------- ----Sprite3DBasicTest @@ -72,12 +73,13 @@ function Sprite3DWithSkinTest.onTouchesEnd(touches, event) end function Sprite3DWithSkinTest.addNewSpriteWithCoords(parent,x,y) - local sprite = cc.Sprite3D:create("Sprite3DTest/girl.c3t") - sprite:setRotation3D({x = -90.0, y = 0.0, z = 0.0}) + local sprite = cc.Sprite3D:create("Sprite3DTest/orc.c3b") + sprite:setScale(3) + sprite:setRotation3D({x = 0, y = 180, z = 0}) sprite:setPosition(cc.p(x, y)) parent:addChild(sprite) - local animation = cc.Animation3D:getOrCreate("Sprite3DTest/girl.c3t") + local animation = cc.Animation3D:getOrCreate("Sprite3DTest/orc.c3b") if nil ~= animation then local animate = cc.Animate3D:create(animation) if math.random() < (1/3) then @@ -112,6 +114,171 @@ function Sprite3DWithSkinTest.create() end +---------------------------------------- +----Animate3DTest +---------------------------------------- +local State = +{ + SWIMMING = 0, + SWIMMING_TO_HURT = 1, + HURT = 2, + HURT_TO_SWIMMING = 3, +} + +local Animate3DTest = {} +Animate3DTest.__index = Animate3DTest + +function Animate3DTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, Animate3DTest) + return target +end + + + +function Animate3DTest:onEnter() + + self._hurt = nil + self._swim = nil + self._sprite = nil + self._moveAction = nil + self._transTime = 0.1 + self._elapseTransTime = 0.0 + + local function renewCallBack() + self._sprite:stopActionByTag(101) + self._state = State.HURT_TO_SWIMMING + end + local function onTouchesEnd(touches, event ) + for i = 1,table.getn(touches) do + local location = touches[i]:getLocation() + if self._sprite ~= nil then + local len = cc.pGetLength(cc.pSub(cc.p(self._sprite:getPosition()), location)) + if len < 40 then + if self._state == State.SWIMMING then + self._sprite:runAction(self._hurt) + local delay = cc.DelayTime:create(self._hurt:getDuration() - 0.1) + local seq = cc.Sequence:create(delay, cc.CallFunc:create(renewCallBack)) + seq:setTag(101) + self._sprite:runAction(seq) + self._state = State.SWIMMING_TO_HURT + end + return + end + end + end + end + + self:addSprite3D() + + local listener = cc.EventListenerTouchAllAtOnce:create() + listener:registerScriptHandler(onTouchesEnd,cc.Handler.EVENT_TOUCHES_ENDED ) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) + + local function update(dt) + if self._state == State.HURT_TO_SWIMMING then + self._elapseTransTime = self._elapseTransTime + dt + local t = self._elapseTransTime / self._transTime + + if t >= 1.0 then + t = 1.0 + self._sprite:stopAction(self._hurt) + self._state = State.SWIMMING + end + self._swim:setWeight(t) + self._hurt:setWeight(1.0 - t) + elseif self._state == State.SWIMMING_TO_HURT then + self._elapseTransTime = self._elapseTransTime + dt + local t = self._elapseTransTime / self._transTime + if t >= 1.0 then + t = 1.0 + self._state = State.HURT + end + self._swim:setWeight(1.0 - t) + self._hurt:setWeight(t) + end + end + + self:scheduleUpdateWithPriorityLua(update,0) +end + +function Animate3DTest:onExit() + self._moveAction:release() + self._hurt:release() + self._swim:release() + self:unscheduleUpdate() +end + +function Animate3DTest:addSprite3D() + -- body + local fileName = "Sprite3DTest/tortoise.c3b" + local sprite = cc.Sprite3D:create(fileName) + sprite:setScale(0.1) + local winSize = cc.Director:getInstance():getWinSize() + sprite:setPosition(cc.p(winSize.width * 4.0 / 5.0, winSize.height / 2.0)) + self:addChild(sprite) + + self._sprite = sprite + + local animation = cc.Animation3D:getOrCreate(fileName) + if nil ~= animation then + local animate = cc.Animate3D:create(animation, 0.0, 1.933) + sprite:runAction(cc.RepeatForever:create(animate)) + self._swim = animate + self._swim:retain() + self._hurt = cc.Animate3D:create(animation, 1.933, 2.8) + self._hurt:retain() + self._state = State.SWIMMING + end + + self._moveAction = cc.MoveTo:create(4.0, cc.p(winSize.width / 5.0, winSize.height / 2.0)) + self._moveAction:retain() + + local function reachEndCallBack() + self._sprite:stopActionByTag(100) + local inverse = self._moveAction:reverse() + inverse:retain() + self._moveAction:release() + self._moveAction = inverse + local rot = cc.RotateBy:create(1.0, { x = 0.0, y = 180.0, z = 0.0}) + local seq = cc.Sequence:create(rot, self._moveAction, cc.CallFunc:create(reachEndCallBack)) + seq:setTag(100) + self._sprite:runAction(seq) + end + + local seq = cc.Sequence:create(self._moveAction, cc.CallFunc:create(reachEndCallBack)) + seq:setTag(100) + sprite:runAction(seq) +end + +function Animate3DTest.create() + local layer = Animate3DTest.extend(cc.Layer:create()) + + if nil ~= layer then + Helper.initWithLayer(layer) + Helper.titleLabel:setString("Testing Animate3D") + Helper.subtitleLabel:setString("Touch to beat the tortoise") + + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + elseif "exit" == event then + layer:onExit() + end + end + layer:registerScriptHandler(onNodeEvent) + end + + return layer +end + + function Sprite3DTest() local scene = cc.Scene:create() @@ -119,6 +286,7 @@ function Sprite3DTest() { Sprite3DBasicTest.create, Sprite3DWithSkinTest.create, + Animate3DTest.create, } scene:addChild(Sprite3DBasicTest.create()) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 20ef1d54cc..81750a9172 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -7,7 +7,7 @@ prefix = cocos2dx # all classes will be embedded in that namespace target_namespace = cc -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 2f18460525..5e5e1c39f6 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -7,7 +7,7 @@ prefix = cocos2dx_extension # all classes will be embedded in that namespace target_namespace = cc -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/tolua/cocos2dx_physics.ini b/tools/tolua/cocos2dx_physics.ini index d2c3549161..6911e254cb 100644 --- a/tools/tolua/cocos2dx_physics.ini +++ b/tools/tolua/cocos2dx_physics.ini @@ -7,7 +7,7 @@ prefix = cocos2dx_physics # all classes will be embedded in that namespace target_namespace = cc -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/tolua/cocos2dx_spine.ini b/tools/tolua/cocos2dx_spine.ini index 783e2a052e..5d1e6743c0 100644 --- a/tools/tolua/cocos2dx_spine.ini +++ b/tools/tolua/cocos2dx_spine.ini @@ -7,7 +7,7 @@ prefix = cocos2dx_spine # all classes will be embedded in that namespace target_namespace = sp -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 6cedc7c62d..ca654b59ad 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -10,7 +10,7 @@ target_namespace = ccs # the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". cpp_namespace = cocostudio -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/tolua/cocos2dx_ui.ini b/tools/tolua/cocos2dx_ui.ini index 1bbc7331f4..79d54ac995 100644 --- a/tools/tolua/cocos2dx_ui.ini +++ b/tools/tolua/cocos2dx_ui.ini @@ -10,7 +10,7 @@ target_namespace = ccui # the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". cpp_namespace = cocos2d::ui -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include diff --git a/tools/travis-scripts/before-install.sh b/tools/travis-scripts/before-install.sh index 0a33175825..220e33d06a 100755 --- a/tools/travis-scripts/before-install.sh +++ b/tools/travis-scripts/before-install.sh @@ -22,12 +22,12 @@ install_android_ndk() else HOST_NAME="linux" fi - echo "Download android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 ..." - curl -O http://dl.google.com/android/ndk/android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 - echo "Decompress android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 ..." - tar xjf android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 + echo "Download android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..." + curl -O http://dl.google.com/android/ndk/android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 + echo "Decompress android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..." + tar xjf android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 # Rename ndk - mv android-ndk-r9b android-ndk + mv android-ndk-r9d android-ndk } install_nacl_sdk()