diff --git a/CHANGELOG b/CHANGELOG index 78a3a19328..58c9390ddf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,8 +3,10 @@ cocos2d-x-3.3?? ?? [NEW] Node: added stopAllActionsByTag() [NEW] UI: added `WebView` on iOS and Android + [FIX] EditBox: moved to ui:EditBox [FIX] Node: create unneeded temple `Vec2` object in `setPosition(int, int)`, `setPositionX()` and `setPositionY()` [FIX] Node: skew effect is wrong + [FIX] Node: setNormalizedPosition can not take effect if parent position is not changed [FIX] TextureAtlas: may crash if only drawing part of it cocos2d-x-3.3alpha0 Aug.28 2014 diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index c49581a417..dcf250b68c 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -969,8 +969,6 @@ 15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; }; 15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; }; 15AE1BDF19AAE01E00C27E9E /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; }; - 15AE1BE019AAE01E00C27E9E /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */; }; - 15AE1BE119AAE01E00C27E9E /* CCScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */; }; 15AE1BE219AAE01E00C27E9E /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; }; 15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; }; 15AE1BE419AAE01E00C27E9E /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; }; @@ -1000,24 +998,12 @@ 15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168491807AF4E005B8026 /* CCControlUtils.h */; }; 15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */; }; 15AE1BFE19AAE01E00C27E9E /* CCInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684B1807AF4E005B8026 /* CCInvocation.h */; }; - 15AE1BFF19AAE01E00C27E9E /* CCScale9Sprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */; }; - 15AE1C0019AAE01E00C27E9E /* CCScale9Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */; }; 15AE1C0119AAE01E00C27E9E /* CCScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */; }; 15AE1C0219AAE01E00C27E9E /* CCScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A1685F1807AF4E005B8026 /* CCScrollView.h */; }; 15AE1C0319AAE01E00C27E9E /* CCTableView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168621807AF4E005B8026 /* CCTableView.cpp */; }; 15AE1C0419AAE01E00C27E9E /* CCTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168631807AF4E005B8026 /* CCTableView.h */; }; 15AE1C0519AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A168641807AF4E005B8026 /* CCTableViewCell.cpp */; }; 15AE1C0619AAE01E00C27E9E /* CCTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168651807AF4E005B8026 /* CCTableViewCell.h */; }; - 15AE1C0719AAE02500C27E9E /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */; }; - 15AE1C0819AAE02500C27E9E /* CCEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168501807AF4E005B8026 /* CCEditBox.h */; }; - 15AE1C0919AAE02500C27E9E /* CCEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */; }; - 15AE1C0A19AAE02500C27E9E /* CCEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168501807AF4E005B8026 /* CCEditBox.h */; }; - 15AE1C0B19AAE02D00C27E9E /* CCEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */; }; - 15AE1C0C19AAE02D00C27E9E /* CCEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */; }; - 15AE1C0D19AAE03400C27E9E /* CCEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */; }; - 15AE1C0E19AAE03400C27E9E /* CCEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */; }; - 15AE1C0F19AAE03E00C27E9E /* CCEditBoxImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */; }; - 15AE1C1019AAE03E00C27E9E /* CCEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */; }; 15AE1C1119AAE2C600C27E9E /* CCPhysicsDebugNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEC180E27CF00808F54 /* CCPhysicsDebugNode.cpp */; }; 15AE1C1219AAE2C600C27E9E /* CCPhysicsDebugNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD71EED180E27CF00808F54 /* CCPhysicsDebugNode.h */; }; 15AE1C1319AAE2C600C27E9E /* CCPhysicsSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD71EEE180E27CF00808F54 /* CCPhysicsSprite.cpp */; }; @@ -1350,6 +1336,30 @@ 1ABA68B11888D700007D1BB4 /* CCFontCharMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABA68AD1888D700007D1BB4 /* CCFontCharMap.h */; }; 1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; }; 1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; }; + 292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; }; + 292DB13E19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; }; + 292DB13F19B4574100A80320 /* UIEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13019B4574100A80320 /* UIEditBox.h */; }; + 292DB14019B4574100A80320 /* UIEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13019B4574100A80320 /* UIEditBox.h */; }; + 292DB14119B4574100A80320 /* UIEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13119B4574100A80320 /* UIEditBoxImpl.h */; }; + 292DB14219B4574100A80320 /* UIEditBoxImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13119B4574100A80320 /* UIEditBoxImpl.h */; }; + 292DB14319B4574100A80320 /* UIEditBoxImplAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13219B4574100A80320 /* UIEditBoxImplAndroid.cpp */; }; + 292DB14419B4574100A80320 /* UIEditBoxImplAndroid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13219B4574100A80320 /* UIEditBoxImplAndroid.cpp */; }; + 292DB14519B4574100A80320 /* UIEditBoxImplAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13319B4574100A80320 /* UIEditBoxImplAndroid.h */; }; + 292DB14619B4574100A80320 /* UIEditBoxImplAndroid.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13319B4574100A80320 /* UIEditBoxImplAndroid.h */; }; + 292DB14719B4574100A80320 /* UIEditBoxImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13419B4574100A80320 /* UIEditBoxImplIOS.h */; }; + 292DB14819B4574100A80320 /* UIEditBoxImplIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13419B4574100A80320 /* UIEditBoxImplIOS.h */; }; + 292DB14919B4574100A80320 /* UIEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13519B4574100A80320 /* UIEditBoxImplIOS.mm */; }; + 292DB14A19B4574100A80320 /* UIEditBoxImplIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13519B4574100A80320 /* UIEditBoxImplIOS.mm */; }; + 292DB14B19B4574100A80320 /* UIEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13619B4574100A80320 /* UIEditBoxImplMac.h */; }; + 292DB14C19B4574100A80320 /* UIEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13619B4574100A80320 /* UIEditBoxImplMac.h */; }; + 292DB14D19B4574100A80320 /* UIEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13719B4574100A80320 /* UIEditBoxImplMac.mm */; }; + 292DB14E19B4574100A80320 /* UIEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13719B4574100A80320 /* UIEditBoxImplMac.mm */; }; + 292DB14F19B4574100A80320 /* UIEditBoxImplNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13819B4574100A80320 /* UIEditBoxImplNone.cpp */; }; + 292DB15019B4574100A80320 /* UIEditBoxImplNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB13819B4574100A80320 /* UIEditBoxImplNone.cpp */; }; + 292DB15F19B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB15D19B461CA00A80320 /* ExtensionDeprecated.cpp */; }; + 292DB16019B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB15D19B461CA00A80320 /* ExtensionDeprecated.cpp */; }; + 292DB16119B461CA00A80320 /* ExtensionDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB15E19B461CA00A80320 /* ExtensionDeprecated.h */; }; + 292DB16219B461CA00A80320 /* ExtensionDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB15E19B461CA00A80320 /* ExtensionDeprecated.h */; }; 29394CF019B01DBA00D2DE1A /* UIWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = 29394CEC19B01DBA00D2DE1A /* UIWebView.h */; }; 29394CF119B01DBA00D2DE1A /* UIWebView.h in Headers */ = {isa = PBXBuildFile; fileRef = 29394CEC19B01DBA00D2DE1A /* UIWebView.h */; }; 29394CF219B01DBA00D2DE1A /* UIWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29394CED19B01DBA00D2DE1A /* UIWebView.mm */; }; @@ -2304,6 +2314,18 @@ 2905FA1318CF08D100240AA3 /* UIWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidget.cpp; sourceTree = ""; }; 2905FA1418CF08D100240AA3 /* UIWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidget.h; sourceTree = ""; }; 29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = ""; }; + 292DB12F19B4574100A80320 /* UIEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEditBox.cpp; sourceTree = ""; }; + 292DB13019B4574100A80320 /* UIEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBox.h; sourceTree = ""; }; + 292DB13119B4574100A80320 /* UIEditBoxImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxImpl.h; sourceTree = ""; }; + 292DB13219B4574100A80320 /* UIEditBoxImplAndroid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEditBoxImplAndroid.cpp; sourceTree = ""; }; + 292DB13319B4574100A80320 /* UIEditBoxImplAndroid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxImplAndroid.h; sourceTree = ""; }; + 292DB13419B4574100A80320 /* UIEditBoxImplIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxImplIOS.h; sourceTree = ""; }; + 292DB13519B4574100A80320 /* UIEditBoxImplIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIEditBoxImplIOS.mm; sourceTree = ""; }; + 292DB13619B4574100A80320 /* UIEditBoxImplMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxImplMac.h; sourceTree = ""; }; + 292DB13719B4574100A80320 /* UIEditBoxImplMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIEditBoxImplMac.mm; sourceTree = ""; }; + 292DB13819B4574100A80320 /* UIEditBoxImplNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEditBoxImplNone.cpp; sourceTree = ""; }; + 292DB15D19B461CA00A80320 /* ExtensionDeprecated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionDeprecated.cpp; sourceTree = ""; }; + 292DB15E19B461CA00A80320 /* ExtensionDeprecated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionDeprecated.h; sourceTree = ""; }; 29394CEC19B01DBA00D2DE1A /* UIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWebView.h; sourceTree = ""; }; 29394CED19B01DBA00D2DE1A /* UIWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIWebView.mm; sourceTree = ""; }; 29394CEE19B01DBA00D2DE1A /* UIWebViewImpl_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWebViewImpl_iOS.h; sourceTree = ""; }; @@ -2405,18 +2427,6 @@ 46A168491807AF4E005B8026 /* CCControlUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCControlUtils.h; sourceTree = ""; }; 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCInvocation.cpp; sourceTree = ""; }; 46A1684B1807AF4E005B8026 /* CCInvocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCInvocation.h; sourceTree = ""; }; - 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCScale9Sprite.cpp; sourceTree = ""; }; - 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCScale9Sprite.h; sourceTree = ""; }; - 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBox.cpp; sourceTree = ""; }; - 46A168501807AF4E005B8026 /* CCEditBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBox.h; sourceTree = ""; }; - 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImpl.h; sourceTree = ""; }; - 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplAndroid.cpp; sourceTree = ""; }; - 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplAndroid.h; sourceTree = ""; }; - 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplIOS.h; sourceTree = ""; }; - 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplIOS.mm; sourceTree = ""; }; - 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplNone.cpp; sourceTree = ""; }; - 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCEditBoxImplWin.cpp; sourceTree = ""; }; - 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplWin.h; sourceTree = ""; }; 46A1685E1807AF4E005B8026 /* CCScrollView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCScrollView.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 46A1685F1807AF4E005B8026 /* CCScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCScrollView.h; sourceTree = ""; }; 46A168621807AF4E005B8026 /* CCTableView.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTableView.cpp; sourceTree = ""; }; @@ -2867,8 +2877,6 @@ B276EF5C1988D1D500CD400F /* CCVertexIndexData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexIndexData.cpp; sourceTree = ""; }; B276EF5D1988D1D500CD400F /* CCVertexIndexBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexIndexBuffer.h; sourceTree = ""; }; B276EF5E1988D1D500CD400F /* CCVertexIndexBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexIndexBuffer.cpp; sourceTree = ""; }; - B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplMac.mm; sourceTree = ""; }; - B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplMac.h; sourceTree = ""; }; B29594AF1926D5D9003EEF37 /* ccShader_3D_Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Color.frag; sourceTree = ""; }; B29594B01926D5D9003EEF37 /* ccShader_3D_ColorTex.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_ColorTex.frag; sourceTree = ""; }; B29594B11926D5D9003EEF37 /* ccShader_3D_PositionTex.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_PositionTex.vert; sourceTree = ""; }; @@ -3979,6 +3987,23 @@ path = ../cocos/ui; sourceTree = ""; }; + 292DB12E19B4574100A80320 /* UIEditBox */ = { + isa = PBXGroup; + children = ( + 292DB12F19B4574100A80320 /* UIEditBox.cpp */, + 292DB13019B4574100A80320 /* UIEditBox.h */, + 292DB13119B4574100A80320 /* UIEditBoxImpl.h */, + 292DB13219B4574100A80320 /* UIEditBoxImplAndroid.cpp */, + 292DB13319B4574100A80320 /* UIEditBoxImplAndroid.h */, + 292DB13419B4574100A80320 /* UIEditBoxImplIOS.h */, + 292DB13519B4574100A80320 /* UIEditBoxImplIOS.mm */, + 292DB13619B4574100A80320 /* UIEditBoxImplMac.h */, + 292DB13719B4574100A80320 /* UIEditBoxImplMac.mm */, + 292DB13819B4574100A80320 /* UIEditBoxImplNone.cpp */, + ); + path = UIEditBox; + sourceTree = ""; + }; 29CB8F501929D63600C841D6 /* layout */ = { isa = PBXGroup; children = ( @@ -4030,6 +4055,7 @@ 29CB8F531929D67D00C841D6 /* widgets */ = { isa = PBXGroup; children = ( + 292DB12E19B4574100A80320 /* UIEditBox */, 2905F9FE18CF08D000240AA3 /* UIListView.cpp */, 2905F9FF18CF08D000240AA3 /* UIListView.h */, 2905FA0018CF08D000240AA3 /* UILoadingBar.cpp */, @@ -4129,6 +4155,8 @@ 46A167981807AF4D005B8026 /* extensions */ = { isa = PBXGroup; children = ( + 292DB15D19B461CA00A80320 /* ExtensionDeprecated.cpp */, + 292DB15E19B461CA00A80320 /* ExtensionDeprecated.h */, 46A167D21807AF4D005B8026 /* cocos-ext.h */, 46A168321807AF4E005B8026 /* ExtensionMacros.h */, 1AAF5350180E305F000584C8 /* assets-manager */, @@ -4143,7 +4171,6 @@ isa = PBXGroup; children = ( 46A168341807AF4E005B8026 /* CCControlExtension */, - 46A1684E1807AF4E005B8026 /* CCEditBox */, 46A1685D1807AF4E005B8026 /* CCScrollView */, ); path = GUI; @@ -4175,31 +4202,10 @@ 46A168491807AF4E005B8026 /* CCControlUtils.h */, 46A1684A1807AF4E005B8026 /* CCInvocation.cpp */, 46A1684B1807AF4E005B8026 /* CCInvocation.h */, - 46A1684C1807AF4E005B8026 /* CCScale9Sprite.cpp */, - 46A1684D1807AF4E005B8026 /* CCScale9Sprite.h */, ); path = CCControlExtension; sourceTree = ""; }; - 46A1684E1807AF4E005B8026 /* CCEditBox */ = { - isa = PBXGroup; - children = ( - B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */, - B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */, - 46A1684F1807AF4E005B8026 /* CCEditBox.cpp */, - 46A168501807AF4E005B8026 /* CCEditBox.h */, - 46A168511807AF4E005B8026 /* CCEditBoxImpl.h */, - 46A168521807AF4E005B8026 /* CCEditBoxImplAndroid.cpp */, - 46A168531807AF4E005B8026 /* CCEditBoxImplAndroid.h */, - 46A168541807AF4E005B8026 /* CCEditBoxImplIOS.h */, - 46A168551807AF4E005B8026 /* CCEditBoxImplIOS.mm */, - 46A168581807AF4E005B8026 /* CCEditBoxImplNone.cpp */, - 46A1685B1807AF4E005B8026 /* CCEditBoxImplWin.cpp */, - 46A1685C1807AF4E005B8026 /* CCEditBoxImplWin.h */, - ); - path = CCEditBox; - sourceTree = ""; - }; 46A1685D1807AF4E005B8026 /* CCScrollView */ = { isa = PBXGroup; children = ( @@ -4943,9 +4949,11 @@ 50ABBE851925AB6F00A911A9 /* ccFPSImages.h in Headers */, 15AE1A5319AAD40300C27E9E /* b2Draw.h in Headers */, 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, + 292DB14B19B4574100A80320 /* UIEditBoxImplMac.h in Headers */, 50ABBE891925AB6F00A911A9 /* CCMap.h in Headers */, 50ABBE8D1925AB6F00A911A9 /* CCNS.h in Headers */, 50ABBEA51925AB6F00A911A9 /* CCScriptSupport.h in Headers */, + 292DB14519B4574100A80320 /* UIEditBoxImplAndroid.h in Headers */, 15AE1B9A19AADFDF00C27E9E /* UIHBox.h in Headers */, 15AE18EB19AAD35000C27E9E /* CCActionNode.h in Headers */, 15AE1A3819AAD3D500C27E9E /* b2Shape.h in Headers */, @@ -5020,7 +5028,6 @@ 15AE199919AAD39600C27E9E /* LoadingBarReader.h in Headers */, 15AE1A8F19AAD40300C27E9E /* b2RopeJoint.h in Headers */, 15AE18ED19AAD35000C27E9E /* CCActionObject.h in Headers */, - 15AE1C0C19AAE02D00C27E9E /* CCEditBoxImpl.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, 15AE18A719AAD33D00C27E9E /* CCScrollViewLoader.h in Headers */, 15AE184819AAD2F700C27E9E /* cocos3d.h in Headers */, @@ -5030,7 +5037,6 @@ 50ABBEA11925AB6F00A911A9 /* CCScheduler.h in Headers */, 15AE1B6219AADA9900C27E9E /* UIButton.h in Headers */, 50ABBDB71925AB4100A911A9 /* CCTexture2D.h in Headers */, - 15AE1BE119AAE01E00C27E9E /* CCScale9Sprite.h in Headers */, 50ABBE811925AB6F00A911A9 /* CCEventType.h in Headers */, 1A57008F180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */, 15AE19A319AAD39600C27E9E /* TextBMFontReader.h in Headers */, @@ -5175,6 +5181,7 @@ 15AE188519AAD33D00C27E9E /* CCBSequence.h in Headers */, 15AE1AE219AAD42500C27E9E /* cpDampedRotarySpring.h in Headers */, 5034CA49191D591100CE6051 /* ccShader_Label_df.frag in Headers */, + 292DB14119B4574100A80320 /* UIEditBoxImpl.h in Headers */, 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */, 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */, @@ -5183,6 +5190,7 @@ 15AE18FB19AAD35000C27E9E /* CCColliderDetector.h in Headers */, 15AE19E119AAD3A700C27E9E /* Skeleton.h in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, + 292DB14719B4574100A80320 /* UIEditBoxImplIOS.h in Headers */, 15AE1A9119AAD40300C27E9E /* b2WeldJoint.h in Headers */, 15AE1A5419AAD40300C27E9E /* b2GrowableStack.h in Headers */, 15AE1B4E19AADA9900C27E9E /* UIListView.h in Headers */, @@ -5286,7 +5294,6 @@ 15AE1BCA19AAE01E00C27E9E /* CCControl.h in Headers */, 50ABBDBF1925AB4100A911A9 /* CCTextureCache.h in Headers */, 15AE186719AAD31D00C27E9E /* CDXMacOSXSupport.h in Headers */, - 15AE1C0A19AAE02500C27E9E /* CCEditBox.h in Headers */, B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */, 15AE1ADF19AAD42500C27E9E /* chipmunk_types.h in Headers */, 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, @@ -5336,6 +5343,7 @@ 15AE18A919AAD33D00C27E9E /* CCSpriteLoader.h in Headers */, 15AE198419AAD36400C27E9E /* WidgetReaderProtocol.h in Headers */, 50ABBEC91925AB6F00A911A9 /* firePngData.h in Headers */, + 292DB16119B461CA00A80320 /* ExtensionDeprecated.h in Headers */, 503DD8F51926B0DB00CD74DD /* CCIMEDelegate.h in Headers */, 50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */, 15AE1BDB19AAE01E00C27E9E /* CCControlSwitch.h in Headers */, @@ -5365,6 +5373,7 @@ 15AE1AEC19AAD42500C27E9E /* util.h in Headers */, 15AE19DD19AAD3A700C27E9E /* Json.h in Headers */, 15AE191A19AAD35000C27E9E /* CCSSceneReader.h in Headers */, + 292DB13F19B4574100A80320 /* UIEditBox.h in Headers */, 50ABBE671925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */, 15AE18E219AAD35000C27E9E /* TriggerMng.h in Headers */, 15AE1B2B19AAD43700C27E9E /* prime.h in Headers */, @@ -5417,7 +5426,6 @@ 50ABBE771925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */, 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, 50ABC0171926664800A911A9 /* CCImage.h in Headers */, - 15AE1C0E19AAE03400C27E9E /* CCEditBoxImplMac.h in Headers */, 15AE1AED19AAD42500C27E9E /* cpArbiter.h in Headers */, 50ABBDA91925AB4100A911A9 /* CCRenderCommand.h in Headers */, 50ABBD951925AB4100A911A9 /* CCGLProgramState.h in Headers */, @@ -5448,6 +5456,7 @@ 15AE183319AAD2F700C27E9E /* CCOBB.h in Headers */, 15AE18B119AAD33D00C27E9E /* CCBMemberVariableAssigner.h in Headers */, 15AE1AFA19AAD42500C27E9E /* cpConstraint.h in Headers */, + 292DB14019B4574100A80320 /* UIEditBox.h in Headers */, 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */, 15AE1A0A19AAD3A700C27E9E /* CCSkeleton.h in Headers */, 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */, @@ -5456,6 +5465,7 @@ 46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */, 46A170FD1807CECB005B8026 /* CCPhysicsBody.h in Headers */, 50ABBE9C1925AB6F00A911A9 /* CCRef.h in Headers */, + 292DB16219B461CA00A80320 /* ExtensionDeprecated.h in Headers */, 50ABBD961925AB4100A911A9 /* CCGLProgramState.h in Headers */, 46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */, 50ABBDB41925AB4100A911A9 /* ccShaders.h in Headers */, @@ -5543,6 +5553,7 @@ 15AE19F819AAD3A700C27E9E /* Animation.h in Headers */, 1A5700A1180BC5D20088DEC7 /* CCNode.h in Headers */, 15AE181919AAD2F700C27E9E /* CCAttachNode.h in Headers */, + 292DB14C19B4574100A80320 /* UIEditBoxImplMac.h in Headers */, 15AE1BF019AAE01E00C27E9E /* CCControlHuePicker.h in Headers */, 15AE18B819AAD33D00C27E9E /* CCBSequenceProperty.h in Headers */, 503DD8E41926736A00CD74DD /* CCDirectorCaller.h in Headers */, @@ -5572,6 +5583,7 @@ 50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */, 50ABBD411925AB0000A911A9 /* CCMath.h in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, + 292DB14819B4574100A80320 /* UIEditBoxImplIOS.h in Headers */, 15AE1A0819AAD3A700C27E9E /* BoneData.h in Headers */, 50ABBD9A1925AB4100A911A9 /* CCGLProgramStateCache.h in Headers */, 15AE181D19AAD2F700C27E9E /* CCBundle3D.h in Headers */, @@ -5603,6 +5615,7 @@ 15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */, 15AE1AA619AAD40300C27E9E /* b2Fixture.h in Headers */, 15AE1BBA19AADFF000C27E9E /* HttpClient.h in Headers */, + 292DB14619B4574100A80320 /* UIEditBoxImplAndroid.h in Headers */, 15AE1AF819AAD42500C27E9E /* chipmunk_types.h in Headers */, 15AE1B9419AADA9A00C27E9E /* GUIDefine.h in Headers */, 15AE183B19AAD2F700C27E9E /* CCRay.h in Headers */, @@ -5745,6 +5758,7 @@ 15AE1B8D19AADA9A00C27E9E /* UIScale9Sprite.h in Headers */, 15AE18AC19AAD33D00C27E9E /* CCBAnimationManager.h in Headers */, 15AE1A1A19AAD3A700C27E9E /* Skin.h in Headers */, + 292DB14219B4574100A80320 /* UIEditBoxImpl.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */, 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */, @@ -5766,7 +5780,6 @@ 15AE1BFE19AAE01E00C27E9E /* CCInvocation.h in Headers */, 15AE1A9E19AAD40300C27E9E /* b2StackAllocator.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, - 15AE1C0F19AAE03E00C27E9E /* CCEditBoxImplIOS.h in Headers */, 15AE1A1619AAD3A700C27E9E /* SkeletonData.h in Headers */, 50ABBD4B1925AB0000A911A9 /* Mat4.h in Headers */, 15AE1BBE19AADFF000C27E9E /* SocketIO.h in Headers */, @@ -5827,7 +5840,6 @@ 15AE198019AAD35700C27E9E /* CCTimeLine.h in Headers */, 50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */, 1A01C69718F57BE800EFE3A6 /* CCInteger.h in Headers */, - 15AE1C0019AAE01E00C27E9E /* CCScale9Sprite.h in Headers */, 15AE1C0619AAE01E00C27E9E /* CCTableViewCell.h in Headers */, 15AE19AB19AAD39700C27E9E /* ListViewReader.h in Headers */, 50ABBEBE1925AB6F00A911A9 /* ccUtils.h in Headers */, @@ -5883,13 +5895,11 @@ B276EF641988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */, 15AE1A0619AAD3A700C27E9E /* Bone.h in Headers */, ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */, - 15AE1C0819AAE02500C27E9E /* CCEditBox.h in Headers */, 50ABC0201926664800A911A9 /* CCThread.h in Headers */, 15AE1B8519AADA9A00C27E9E /* UITextField.h in Headers */, 1A01C69318F57BE800EFE3A6 /* CCDouble.h in Headers */, 15AE184B19AAD30500C27E9E /* Export.h in Headers */, 15AE196019AAD35100C27E9E /* CCSpriteFrameCacheHelper.h in Headers */, - 15AE1C0B19AAE02D00C27E9E /* CCEditBoxImpl.h in Headers */, 50ABBE221925AB6F00A911A9 /* atitc.h in Headers */, 15AE1AB719AAD40300C27E9E /* b2ContactSolver.h in Headers */, 15AE193319AAD35100C27E9E /* CCActionNode.h in Headers */, @@ -6002,6 +6012,7 @@ 15AE1B1E19AAD43700C27E9E /* cpBody.c in Sources */, 15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */, 3EA3EDBC1991CDFA00645534 /* CCCamera.cpp in Sources */, + 292DB14F19B4574100A80320 /* UIEditBoxImplNone.cpp in Sources */, 15AE199419AAD39600C27E9E /* LayoutReader.cpp in Sources */, 1A01C68A18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, 1A1645B0191B726C008C7C7F /* ConvertUTF.c in Sources */, @@ -6033,7 +6044,6 @@ 15AE186319AAD31D00C27E9E /* CDAudioManager.m in Sources */, 15AE1B2219AAD43700C27E9E /* cpShape.c in Sources */, ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */, - 15AE1C0D19AAE03400C27E9E /* CCEditBoxImplMac.mm in Sources */, 15AE1A2C19AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */, 15AE184019AAD2F700C27E9E /* CCSprite3D.cpp in Sources */, 46A170E61807CECA005B8026 /* CCPhysicsBody.cpp in Sources */, @@ -6045,7 +6055,6 @@ 50ABBEBB1925AB6F00A911A9 /* ccUtils.cpp in Sources */, 15AE186A19AAD31D00C27E9E /* CocosDenshion.m in Sources */, 15AE198C19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, - 15AE1C0919AAE02500C27E9E /* CCEditBox.cpp in Sources */, 15AE1B6319AADA9900C27E9E /* UICheckBox.cpp in Sources */, 15EFA211198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */, 50ABBEB71925AB6F00A911A9 /* ccUTF8.cpp in Sources */, @@ -6122,6 +6131,7 @@ 50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */, 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 50ABBED71925AB6F00A911A9 /* ZipUtils.cpp in Sources */, + 292DB14919B4574100A80320 /* UIEditBoxImplIOS.mm in Sources */, 15AE181019AAD2F700C27E9E /* CCAnimation3D.cpp in Sources */, 1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */, 1A570112180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, @@ -6152,6 +6162,7 @@ 15AE1B5319AADA9900C27E9E /* UIRichText.cpp in Sources */, 15AE19DC19AAD3A700C27E9E /* Json.cpp in Sources */, 15AE1B2419AAD43700C27E9E /* cpSpaceComponent.c in Sources */, + 292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */, 50ABBE551925AB6F00A911A9 /* CCEventFocus.cpp in Sources */, 15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */, @@ -6200,6 +6211,8 @@ 1A570202180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */, 1A570208180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */, 1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */, + 292DB15F19B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */, + 292DB14D19B4574100A80320 /* UIEditBoxImplMac.mm in Sources */, 50ABBDB51925AB4100A911A9 /* CCTexture2D.cpp in Sources */, 1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 15AE1BD019AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */, @@ -6218,7 +6231,6 @@ 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, B24AA989195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, 15AE199619AAD39600C27E9E /* ListViewReader.cpp in Sources */, - 15AE1BE019AAE01E00C27E9E /* CCScale9Sprite.cpp in Sources */, 50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */, 15AE1B1419AAD43700C27E9E /* cpPinJoint.c in Sources */, 15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, @@ -6338,6 +6350,7 @@ 50ABC0631926664800A911A9 /* CCDevice.mm in Sources */, 15AE1A2819AAD3D500C27E9E /* b2Collision.cpp in Sources */, 15AE1B6719AADA9900C27E9E /* UIScale9Sprite.cpp in Sources */, + 292DB14319B4574100A80320 /* UIEditBoxImplAndroid.cpp in Sources */, 15AE1A5219AAD40300C27E9E /* b2Draw.cpp in Sources */, 50ABBE1F1925AB6F00A911A9 /* atitc.cpp in Sources */, 1A01C69818F57BE800EFE3A6 /* CCSet.cpp in Sources */, @@ -6451,6 +6464,7 @@ 46A171031807CECB005B8026 /* CCPhysicsShape.cpp in Sources */, 50ABC0161926664800A911A9 /* CCImage.cpp in Sources */, 1A01C6A518F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, + 292DB14E19B4574100A80320 /* UIEditBoxImplMac.mm in Sources */, 15AE1BFB19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */, 15AE1B9019AADA9A00C27E9E /* UIWidget.cpp in Sources */, ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */, @@ -6502,6 +6516,7 @@ 15AE198E19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, 50ABBE621925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */, 15AE1AB619AAD40300C27E9E /* b2ContactSolver.cpp in Sources */, + 292DB13E19B4574100A80320 /* UIEditBox.cpp in Sources */, 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */, 15AE19EF19AAD3A700C27E9E /* SkeletonBounds.cpp in Sources */, 15AE18B219AAD33D00C27E9E /* CCBReader.cpp in Sources */, @@ -6547,6 +6562,7 @@ 15AE1B4319AAD43700C27E9E /* cpSpaceHash.c in Sources */, 15AE1A1D19AAD3A700C27E9E /* SlotData.cpp in Sources */, 50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */, + 292DB14419B4574100A80320 /* UIEditBoxImplAndroid.cpp in Sources */, 15AE193619AAD35100C27E9E /* CCArmature.cpp in Sources */, 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, 15AE1AC419AAD40300C27E9E /* b2FrictionJoint.cpp in Sources */, @@ -6566,7 +6582,6 @@ 1A570086180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */, 15AE1AB819AAD40300C27E9E /* b2EdgeAndCircleContact.cpp in Sources */, 15AE19FF19AAD3A700C27E9E /* AtlasAttachmentLoader.cpp in Sources */, - 15AE1C0719AAE02500C27E9E /* CCEditBox.cpp in Sources */, 1A57008A180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */, 15AE18AF19AAD33D00C27E9E /* CCBKeyframe.cpp in Sources */, 15AE19FB19AAD3A700C27E9E /* AnimationStateData.cpp in Sources */, @@ -6596,6 +6611,7 @@ 15AE195F19AAD35100C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, 15AE193019AAD35100C27E9E /* CCActionManagerEx.cpp in Sources */, 503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */, + 292DB14A19B4574100A80320 /* UIEditBoxImplIOS.mm in Sources */, 15AE1A9419AAD40300C27E9E /* b2BlockAllocator.cpp in Sources */, 15AE1B4419AAD43700C27E9E /* cpSpaceQuery.c in Sources */, 15AE1A4D19AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, @@ -6612,6 +6628,7 @@ 15AE1AB019AAD40300C27E9E /* b2ChainAndPolygonContact.cpp in Sources */, 1A5701B2180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, 1A5701B6180BCB590088DEC7 /* CCFontFreeType.cpp in Sources */, + 292DB16019B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */, 50ABBEAC1925AB6F00A911A9 /* ccTypes.cpp in Sources */, 15AE196A19AAD35100C27E9E /* DictionaryHelper.cpp in Sources */, 15AE1A3F19AAD3D500C27E9E /* b2Collision.cpp in Sources */, @@ -6672,6 +6689,7 @@ 15AE194019AAD35100C27E9E /* CCBone.cpp in Sources */, 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, + 292DB15019B4574100A80320 /* UIEditBoxImplNone.cpp in Sources */, 15AE19F119AAD3A700C27E9E /* Event.cpp in Sources */, 15AE185F19AAD31200C27E9E /* SimpleAudioEngine.mm in Sources */, 15AE1BE819AAE01E00C27E9E /* CCControl.cpp in Sources */, @@ -6681,7 +6699,6 @@ 15AE182919AAD2F700C27E9E /* CCMeshSkin.cpp in Sources */, 15AE1BBD19AADFF000C27E9E /* SocketIO.cpp in Sources */, 15AE1A4319AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */, - 15AE1BFF19AAE01E00C27E9E /* CCScale9Sprite.cpp in Sources */, 15AE1A3A19AAD3D500C27E9E /* b2BroadPhase.cpp in Sources */, 15AE19B619AAD39700C27E9E /* TextBMFontReader.cpp in Sources */, 15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */, @@ -6715,7 +6732,6 @@ 15AE19AE19AAD39700C27E9E /* PageViewReader.cpp in Sources */, 3EA3EDBD1991CDFA00645534 /* CCCamera.cpp in Sources */, 1A570297180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */, - 15AE1C1019AAE03E00C27E9E /* CCEditBoxImplIOS.mm in Sources */, 50ABBE321925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, 15AE1A9F19AAD40300C27E9E /* b2Timer.cpp in Sources */, 15AE1AD419AAD40300C27E9E /* b2WeldJoint.cpp in Sources */, diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 2029a5d0ff..dec67dde2c 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -472,8 +472,6 @@ 1AC35BEE18CECF0C00F37B72 /* CCControlStepperTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7318CECF0B00F37B72 /* CCControlStepperTest.cpp */; }; 1AC35BEF18CECF0C00F37B72 /* CCControlSwitchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7618CECF0B00F37B72 /* CCControlSwitchTest.cpp */; }; 1AC35BF018CECF0C00F37B72 /* CCControlSwitchTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7618CECF0B00F37B72 /* CCControlSwitchTest.cpp */; }; - 1AC35BF118CECF0C00F37B72 /* EditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7918CECF0B00F37B72 /* EditBoxTest.cpp */; }; - 1AC35BF218CECF0C00F37B72 /* EditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7918CECF0B00F37B72 /* EditBoxTest.cpp */; }; 1AC35BF318CECF0C00F37B72 /* ExtensionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7B18CECF0B00F37B72 /* ExtensionsTest.cpp */; }; 1AC35BF418CECF0C00F37B72 /* ExtensionsTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7B18CECF0B00F37B72 /* ExtensionsTest.cpp */; }; 1AC35BF518CECF0C00F37B72 /* HttpClientTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A7E18CECF0B00F37B72 /* HttpClientTest.cpp */; }; @@ -484,8 +482,6 @@ 1AC35BFA18CECF0C00F37B72 /* WebSocketTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8218CECF0B00F37B72 /* WebSocketTest.cpp */; }; 1AC35BFB18CECF0C00F37B72 /* NotificationCenterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8518CECF0B00F37B72 /* NotificationCenterTest.cpp */; }; 1AC35BFC18CECF0C00F37B72 /* NotificationCenterTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8518CECF0B00F37B72 /* NotificationCenterTest.cpp */; }; - 1AC35BFD18CECF0C00F37B72 /* Scale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8818CECF0B00F37B72 /* Scale9SpriteTest.cpp */; }; - 1AC35BFE18CECF0C00F37B72 /* Scale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8818CECF0B00F37B72 /* Scale9SpriteTest.cpp */; }; 1AC35BFF18CECF0C00F37B72 /* CustomTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8B18CECF0B00F37B72 /* CustomTableViewCell.cpp */; }; 1AC35C0018CECF0C00F37B72 /* CustomTableViewCell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8B18CECF0B00F37B72 /* CustomTableViewCell.cpp */; }; 1AC35C0118CECF0C00F37B72 /* TableViewTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC35A8D18CECF0B00F37B72 /* TableViewTestScene.cpp */; }; @@ -863,6 +859,8 @@ 29080DE6191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */; }; 290E94B5196FC16900694919 /* CocostudioParserTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 290E94B3196FC16900694919 /* CocostudioParserTest.cpp */; }; 290E94B6196FC16900694919 /* CocostudioParserTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 290E94B3196FC16900694919 /* CocostudioParserTest.cpp */; }; + 292CF01419A1965E00E8E6A0 /* UIEditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */; }; + 292CF01519A1965E00E8E6A0 /* UIEditBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */; }; 295824591987415900F9746D /* UIScale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 295824571987415900F9746D /* UIScale9SpriteTest.cpp */; }; 2958245A1987415900F9746D /* UIScale9SpriteTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 295824571987415900F9746D /* UIScale9SpriteTest.cpp */; }; 298D7F6F19AC31F300FF096D /* UIWebViewTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 298D7F6D19AC31F300FF096D /* UIWebViewTest.cpp */; }; @@ -2555,8 +2553,6 @@ 1AC35A7418CECF0B00F37B72 /* CCControlStepperTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlStepperTest.h; sourceTree = ""; }; 1AC35A7618CECF0B00F37B72 /* CCControlSwitchTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControlSwitchTest.cpp; sourceTree = ""; }; 1AC35A7718CECF0B00F37B72 /* CCControlSwitchTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControlSwitchTest.h; sourceTree = ""; }; - 1AC35A7918CECF0B00F37B72 /* EditBoxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditBoxTest.cpp; sourceTree = ""; }; - 1AC35A7A18CECF0B00F37B72 /* EditBoxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditBoxTest.h; sourceTree = ""; }; 1AC35A7B18CECF0B00F37B72 /* ExtensionsTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionsTest.cpp; sourceTree = ""; }; 1AC35A7C18CECF0B00F37B72 /* ExtensionsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionsTest.h; sourceTree = ""; }; 1AC35A7E18CECF0B00F37B72 /* HttpClientTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpClientTest.cpp; sourceTree = ""; }; @@ -2567,8 +2563,6 @@ 1AC35A8318CECF0B00F37B72 /* WebSocketTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketTest.h; sourceTree = ""; }; 1AC35A8518CECF0B00F37B72 /* NotificationCenterTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationCenterTest.cpp; sourceTree = ""; }; 1AC35A8618CECF0B00F37B72 /* NotificationCenterTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationCenterTest.h; sourceTree = ""; }; - 1AC35A8818CECF0B00F37B72 /* Scale9SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scale9SpriteTest.cpp; sourceTree = ""; }; - 1AC35A8918CECF0B00F37B72 /* Scale9SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scale9SpriteTest.h; sourceTree = ""; }; 1AC35A8B18CECF0B00F37B72 /* CustomTableViewCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomTableViewCell.cpp; sourceTree = ""; }; 1AC35A8C18CECF0B00F37B72 /* CustomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTableViewCell.h; sourceTree = ""; }; 1AC35A8D18CECF0B00F37B72 /* TableViewTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TableViewTestScene.cpp; sourceTree = ""; }; @@ -2886,6 +2880,8 @@ 29080D8C191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest_Editor.h; sourceTree = ""; }; 290E94B3196FC16900694919 /* CocostudioParserTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CocostudioParserTest.cpp; path = ../CocostudioParserTest.cpp; sourceTree = ""; }; 290E94B4196FC16900694919 /* CocostudioParserTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CocostudioParserTest.h; path = ../CocostudioParserTest.h; sourceTree = ""; }; + 292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEditBoxTest.cpp; sourceTree = ""; }; + 292CF01319A1965E00E8E6A0 /* UIEditBoxTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxTest.h; sourceTree = ""; }; 295824571987415900F9746D /* UIScale9SpriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScale9SpriteTest.cpp; sourceTree = ""; }; 295824581987415900F9746D /* UIScale9SpriteTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScale9SpriteTest.h; sourceTree = ""; }; 298D7F6D19AC31F300FF096D /* UIWebViewTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIWebViewTest.cpp; path = UIWebViewTest/UIWebViewTest.cpp; sourceTree = ""; }; @@ -5773,12 +5769,10 @@ 1AC359DF18CECF0B00F37B72 /* CocoStudioComponentsTest */, 1AC35A5818CECF0B00F37B72 /* CocoStudioSceneTest */, 1AC35A6118CECF0B00F37B72 /* ControlExtensionTest */, - 1AC35A7818CECF0B00F37B72 /* EditBoxTest */, 1AC35A7B18CECF0B00F37B72 /* ExtensionsTest.cpp */, 1AC35A7C18CECF0B00F37B72 /* ExtensionsTest.h */, 1AC35A7D18CECF0B00F37B72 /* NetworkTest */, 1AC35A8418CECF0B00F37B72 /* NotificationCenterTest */, - 1AC35A8718CECF0B00F37B72 /* Scale9SpriteTest */, 1AC35A8A18CECF0B00F37B72 /* TableViewTest */, ); path = ExtensionsTest; @@ -6020,15 +6014,6 @@ path = CCControlSwitchTest; sourceTree = ""; }; - 1AC35A7818CECF0B00F37B72 /* EditBoxTest */ = { - isa = PBXGroup; - children = ( - 1AC35A7918CECF0B00F37B72 /* EditBoxTest.cpp */, - 1AC35A7A18CECF0B00F37B72 /* EditBoxTest.h */, - ); - path = EditBoxTest; - sourceTree = ""; - }; 1AC35A7D18CECF0B00F37B72 /* NetworkTest */ = { isa = PBXGroup; children = ( @@ -6051,15 +6036,6 @@ path = NotificationCenterTest; sourceTree = ""; }; - 1AC35A8718CECF0B00F37B72 /* Scale9SpriteTest */ = { - isa = PBXGroup; - children = ( - 1AC35A8818CECF0B00F37B72 /* Scale9SpriteTest.cpp */, - 1AC35A8918CECF0B00F37B72 /* Scale9SpriteTest.h */, - ); - path = Scale9SpriteTest; - sourceTree = ""; - }; 1AC35A8A18CECF0B00F37B72 /* TableViewTest */ = { isa = PBXGroup; children = ( @@ -7006,6 +6982,8 @@ 298D7F6C19AC31C000FF096D /* UIWebViewTest */, 295824571987415900F9746D /* UIScale9SpriteTest.cpp */, 295824581987415900F9746D /* UIScale9SpriteTest.h */, + 292CF01219A1965E00E8E6A0 /* UIEditBoxTest.cpp */, + 292CF01319A1965E00E8E6A0 /* UIEditBoxTest.h */, 29080D1F191B595E0066F8DF /* CocosGUIScene.cpp */, 29080D20191B595E0066F8DF /* CocosGUIScene.h */, 29080D37191B595E0066F8DF /* GUIEditorTest.cpp */, @@ -7970,7 +7948,6 @@ 1AC35B6718CECF0C00F37B72 /* AnimationsTestLayer.cpp in Sources */, 29080DB7191B595E0066F8DF /* UIListViewTest_Editor.cpp in Sources */, 1AC35BF918CECF0C00F37B72 /* WebSocketTest.cpp in Sources */, - 1AC35BF118CECF0C00F37B72 /* EditBoxTest.cpp in Sources */, 1AC35B3918CECF0C00F37B72 /* Bug-1174.cpp in Sources */, 1AC35BE318CECF0C00F37B72 /* CCControlColourPickerTest.cpp in Sources */, 29080DB1191B595E0066F8DF /* UILayoutTest.cpp in Sources */, @@ -8021,7 +7998,6 @@ 29080DD1191B595E0066F8DF /* UISliderTest_Editor.cpp in Sources */, 1AC35B2718CECF0C00F37B72 /* ActionsTest.cpp in Sources */, 1AC35C4918CECF0C00F37B72 /* ShaderTest.cpp in Sources */, - 1AC35BFD18CECF0C00F37B72 /* Scale9SpriteTest.cpp in Sources */, 1AC35B4318CECF0C00F37B72 /* Bug-624.cpp in Sources */, 1AC35BF718CECF0C00F37B72 /* SocketIOTest.cpp in Sources */, 1AC35C4F18CECF0C00F37B72 /* SpriteTest.cpp in Sources */, @@ -8040,6 +8016,7 @@ 1AC35B7D18CECF0C00F37B72 /* PlayerController.cpp in Sources */, 29080D9F191B595E0066F8DF /* CustomReader.cpp in Sources */, 1AC35BE718CECF0C00F37B72 /* CCControlScene.cpp in Sources */, + 292CF01419A1965E00E8E6A0 /* UIEditBoxTest.cpp in Sources */, 29080DBF191B595E0066F8DF /* UIPageViewTest_Editor.cpp in Sources */, 1AC35B5F18CECF0C00F37B72 /* DataVisitorTest.cpp in Sources */, 1AC35B5D18CECF0C00F37B72 /* CurrentLanguageTest.cpp in Sources */, @@ -8166,7 +8143,6 @@ 1AC35B6818CECF0C00F37B72 /* AnimationsTestLayer.cpp in Sources */, 29080D8E191B595E0066F8DF /* CocosGUIScene.cpp in Sources */, 1AC35BFA18CECF0C00F37B72 /* WebSocketTest.cpp in Sources */, - 1AC35BF218CECF0C00F37B72 /* EditBoxTest.cpp in Sources */, 38FA2E74194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */, 2958245A1987415900F9746D /* UIScale9SpriteTest.cpp in Sources */, 1AC35B3A18CECF0C00F37B72 /* Bug-1174.cpp in Sources */, @@ -8221,9 +8197,9 @@ 1AC35C0618CECF0C00F37B72 /* FontTest.cpp in Sources */, 1AC35C3818CECF0C00F37B72 /* PerformanceTest.cpp in Sources */, 1F33635018E37E840074764D /* RefPtrTest.cpp in Sources */, + 292CF01519A1965E00E8E6A0 /* UIEditBoxTest.cpp in Sources */, 1AC35B2818CECF0C00F37B72 /* ActionsTest.cpp in Sources */, 1AC35C4A18CECF0C00F37B72 /* ShaderTest.cpp in Sources */, - 1AC35BFE18CECF0C00F37B72 /* Scale9SpriteTest.cpp in Sources */, C04F935B1941B05400E9FEAB /* TileMapTest2.cpp in Sources */, 1AC35B4418CECF0C00F37B72 /* Bug-624.cpp in Sources */, 1AC35BF818CECF0C00F37B72 /* SocketIOTest.cpp in Sources */, diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index cbd4b97f31..d13cd07bc6 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -126,6 +126,7 @@ Node::Node(void) , _cascadeColorEnabled(false) , _cascadeOpacityEnabled(false) , _usingNormalizedPosition(false) +, _normalizedPositionDirty(false) , _name("") , _hashOfName(0) , _cameraMask(1) @@ -613,6 +614,7 @@ void Node::setNormalizedPosition(const Vec2& position) _normalizedPosition = position; _usingNormalizedPosition = true; + _normalizedPositionDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true; } @@ -1210,17 +1212,21 @@ void Node::visit() uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags) { + if(_usingNormalizedPosition) { + CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); + if ((parentFlags & FLAGS_CONTENT_SIZE_DIRTY) || _normalizedPositionDirty) { + auto s = _parent->getContentSize(); + _position.x = _normalizedPosition.x * s.width; + _position.y = _normalizedPosition.y * s.height; + _transformUpdated = _transformDirty = _inverseDirty = true; + _normalizedPositionDirty = false; + } + } + uint32_t flags = parentFlags; flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0); flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0); - - if(_usingNormalizedPosition && (flags & FLAGS_CONTENT_SIZE_DIRTY)) { - CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes"); - auto s = _parent->getContentSize(); - _position.x = _normalizedPosition.x * s.width; - _position.y = _normalizedPosition.y * s.height; - _transformUpdated = _transformDirty = _inverseDirty = true; - } + if(flags & FLAGS_DIRTY_MASK) _modelViewTransform = this->transform(parentTransform); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 8f24f2d09d..96ab1118ee 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1555,6 +1555,7 @@ protected: float _positionZ; ///< OpenGL real Z position Vec2 _normalizedPosition; bool _usingNormalizedPosition; + bool _normalizedPositionDirty; float _skewX; ///< skew angle on x-axis float _skewY; ///< skew angle on y-axis diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 108b9bc422..7c61bf42bb 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -192,15 +192,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l - - - - @@ -409,9 +405,12 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l + + + @@ -516,16 +515,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l - - - - - @@ -786,9 +780,13 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\spine\prebuilt\release-l + + + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 1a5d9f9b25..d918da6cc1 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -76,15 +76,9 @@ {b27aba95-51a2-413c-8570-0aff9adf2b6b} - - {220cf2ee-61b0-40cf-a88a-8627e4e609f1} - {a1f539bc-d5be-4224-a4d2-01c0b6f17d6e} - - {dc45cd54-4576-4401-87b7-a276f91a45bd} - {1de7fce7-0dee-4571-8fcd-43eb617aaf8b} @@ -211,6 +205,12 @@ {8579ed15-b266-4f80-818d-a3a9251c4248} + + {89eb6312-dc7f-4fda-b9b2-ab67c31ddd55} + + + {118d80ca-ccf2-480c-b87d-25220af23440} + @@ -787,42 +787,6 @@ extension\AssetsManager - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - extension\GUI\CCScrollView @@ -832,15 +796,6 @@ extension\GUI\CCScrollView - - extension\GUI\CCEditBox - - - extension\GUI\CCEditBox - - - extension\GUI\CCEditBox - extension\physics_nodes @@ -1165,6 +1120,48 @@ cocosbuilder\Source Files + + ui\UIWidgets\EditBox + + + ui\UIWidgets\EditBox + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + ui\UIWidgets\EditBox + @@ -1825,45 +1822,6 @@ extension\AssetsManager - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - - - extension\GUI\CCControlExtension - extension\GUI\CCScrollView @@ -1873,18 +1831,6 @@ extension\GUI\CCScrollView - - extension\GUI\CCEditBox - - - extension\GUI\CCEditBox - - - extension\GUI\CCEditBox - - - extension\GUI\CCEditBox - extension\physics_nodes @@ -2290,6 +2236,54 @@ cocosbuilder\Header Files + + ui\UIWidgets\EditBox + + + ui\UIWidgets\EditBox + + + ui\UIWidgets\EditBox + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + extension\GUI\CCControlExtensions + + + ui\UIWidgets\EditBox + diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index c28351046b..6a2a74efd2 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -760,7 +760,17 @@ bool Bundle3D::loadNodes(NodeDatas& nodedatas) if (_version == "0.1" || _version == "1.2" || _version == "0.2") { SkinData skinData; - loadSkinData("", &skinData); + if (!loadSkinData("", &skinData)) + { + auto node= new (std::nothrow) NodeData(); + auto modelnode = new (std::nothrow) ModelData(); + modelnode->matrialId = ""; + modelnode->subMeshId = ""; + node->modelNodeDatas.push_back(modelnode); + nodedatas.nodes.push_back(node); + return true; + } + auto nodeDatas = new (std::nothrow) NodeData*[skinData.skinBoneNames.size() + skinData.nodeBoneNames.size()]; int index = 0; size_t i; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 8d289035ab..ed9a3baf89 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -231,6 +231,7 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c auto sprite = new (std::nothrow) Sprite3D(); if (sprite) { + sprite->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId)); if (modeldata->matrialId == "" && matrialdatas.materials.size()) { @@ -399,6 +400,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m node= Node::create(); if(node) { + node->setName(nodedata->id); node->setAdditionalTransform(&nodedata->transform); if(root) { diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index c454b4f63a..ac588ab6a9 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -90,9 +90,6 @@ list(REMOVE_ITEM cocos2d_source_files "${CMAKE_CURRENT_SOURCE_DIR}/storage/local-storage/LocalStorageAndroid.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/base/CCEventController.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/base/CCEventListenerController.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/../extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/../extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/../extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/editor-support/cocostudio/proj.wp8/pch.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/../extensions/proj.wp8/pch.cpp") diff --git a/cocos/base/ObjectFactory.cpp b/cocos/base/ObjectFactory.cpp index 1a14b14ce7..4d9c11145b 100644 --- a/cocos/base/ObjectFactory.cpp +++ b/cocos/base/ObjectFactory.cpp @@ -22,6 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#include #include "base/ObjectFactory.h" @@ -30,12 +31,22 @@ NS_CC_BEGIN ObjectFactory::TInfo::TInfo(void) :_class("") ,_fun(nullptr) +,_func(nullptr) { } ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins) :_class(type) ,_fun(ins) +,_func(nullptr) +{ + ObjectFactory::getInstance()->registerType(*this); +} + +ObjectFactory::TInfo::TInfo(const std::string& type, InstanceFunc ins) + :_class(type) + ,_fun(nullptr) + ,_func(ins) { ObjectFactory::getInstance()->registerType(*this); } @@ -44,18 +55,21 @@ ObjectFactory::TInfo::TInfo(const TInfo &t) { _class = t._class; _fun = t._fun; + _func = t._func; } ObjectFactory::TInfo::~TInfo(void) { _class = ""; _fun = nullptr; + _func = nullptr; } ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t) { _class = t._class; _fun = t._fun; + _func = t._func; return *this; } @@ -88,13 +102,18 @@ void ObjectFactory::destroyInstance() Ref* ObjectFactory::createObject(const std::string &name) { - Ref *o = nullptr; - do - { - const TInfo t = _typeMap[name]; - CC_BREAK_IF(t._fun == nullptr); - o = t._fun(); - } while (0); + Ref *o = nullptr; + do + { + const TInfo t = _typeMap[name]; + if (t._fun != nullptr) + { + o = t._fun(); + }else if (t._func != nullptr) + { + o = t._func(); + } + } while (0); return o; } diff --git a/cocos/base/ObjectFactory.h b/cocos/base/ObjectFactory.h index 658fc65352..c9342f2c9d 100644 --- a/cocos/base/ObjectFactory.h +++ b/cocos/base/ObjectFactory.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include +#include #include "base/CCRef.h" #include "base/CCPlatformMacros.h" @@ -36,15 +37,18 @@ class CC_DLL ObjectFactory { public: typedef cocos2d::Ref* (*Instance)(void); + typedef std::function InstanceFunc; struct CC_DLL TInfo { TInfo(void); - TInfo(const std::string& type, Instance ins = NULL); + TInfo(const std::string& type, Instance ins = nullptr); + TInfo(const std::string& type, InstanceFunc ins = nullptr); TInfo(const TInfo &t); ~TInfo(void); TInfo& operator= (const TInfo &t); std::string _class; Instance _fun; + InstanceFunc _func; }; typedef std::unordered_map FactoryMap; diff --git a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.cpp b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.cpp index 2089898058..186708fc34 100644 --- a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.cpp @@ -19,7 +19,7 @@ namespace cocosbuilder { void Scale9SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) { - ((Scale9Sprite *)pNode)->setSpriteFrame(pSpriteFrame); + ((cocos2d::ui::Scale9Sprite *)pNode)->setSpriteFrame(pSpriteFrame); } else { NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); } @@ -27,7 +27,7 @@ void Scale9SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParen void Scale9SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { - ((Scale9Sprite *)pNode)->setColor(pColor3B); + ((cocos2d::ui::Scale9Sprite *)pNode)->setColor(pColor3B); } else { NodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pColor3B, ccbReader); } @@ -35,7 +35,7 @@ void Scale9SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, co void Scale9SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { - ((Scale9Sprite *)pNode)->setOpacity(pByte); + ((cocos2d::ui::Scale9Sprite *)pNode)->setOpacity(pByte); } else { NodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, ccbReader); } @@ -54,7 +54,7 @@ void Scale9SpriteLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, cons if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { //((Scale9Sprite *)pNode)->setContentSize(pSize); } else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { - ((Scale9Sprite *)pNode)->setPreferredSize(pSize); + ((cocos2d::ui::Scale9Sprite *)pNode)->setPreferredSize(pSize); } else { NodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, ccbReader); } @@ -62,13 +62,13 @@ void Scale9SpriteLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, cons void Scale9SpriteLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) { - ((Scale9Sprite *)pNode)->setInsetLeft(pFloat); + ((cocos2d::ui::Scale9Sprite *)pNode)->setInsetLeft(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) { - ((Scale9Sprite *)pNode)->setInsetTop(pFloat); + ((cocos2d::ui::Scale9Sprite *)pNode)->setInsetTop(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) { - ((Scale9Sprite *)pNode)->setInsetRight(pFloat); + ((cocos2d::ui::Scale9Sprite *)pNode)->setInsetRight(pFloat); } else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) { - ((Scale9Sprite *)pNode)->setInsetBottom(pFloat); + ((cocos2d::ui::Scale9Sprite *)pNode)->setInsetBottom(pFloat); } else { NodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, ccbReader); } diff --git a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h index 70f7e1816b..35bf229776 100644 --- a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h +++ b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h @@ -3,7 +3,7 @@ #include "CCNodeLoader.h" #include "CCScale9SpriteLoader.h" -#include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "ui/UIScale9Sprite.h" namespace cocosbuilder { @@ -28,8 +28,8 @@ protected: * @js NA * @lua NA */ - virtual cocos2d::extension::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { - cocos2d::extension::Scale9Sprite* pNode = cocos2d::extension::Scale9Sprite::create(); + virtual cocos2d::ui::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { + cocos2d::ui::Scale9Sprite* pNode = cocos2d::ui::Scale9Sprite::create(); pNode->setAnchorPoint(cocos2d::Vec2::ZERO); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 0369186f4f..e1e1cf9af3 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -176,6 +176,27 @@ void GUIReader::registerTypeAndCallBack(const std::string& classType, } } +void GUIReader::registerTypeAndCallBack(const std::string& classType, + ObjectFactory::InstanceFunc ins, + Ref *object, + SEL_ParseEvent callBack) +{ + ObjectFactory* factoryCreate = ObjectFactory::getInstance(); + + ObjectFactory::TInfo t(classType, ins); + factoryCreate->registerType(t); + + if (object) + { + _mapObject.insert(ParseObjectMap::value_type(classType, object)); + } + + if (callBack) + { + _mapParseSelector.insert(ParseCallBackMap::value_type(classType, callBack)); + } +} + Widget* GUIReader::widgetFromJsonFile(const char *fileName) { @@ -1511,11 +1532,11 @@ void WidgetPropertiesReader0300::setPropsForAllCustomWidgetFromJsonDictionary(co { GUIReader* guiReader = GUIReader::getInstance(); - std::map object_map = GUIReader::getInstance()->getParseObjectMap(); - Ref* object = object_map[classType]; + std::map *object_map = guiReader->getParseObjectMap(); + Ref* object = (*object_map)[classType]; - std::map selector_map = guiReader->getParseCallBackMap(); - SEL_ParseEvent selector = selector_map[classType]; + std::map *selector_map = guiReader->getParseCallBackMap(); + SEL_ParseEvent selector = (*selector_map)[classType]; if (object && selector) { diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 89f27a6a1b..12239ead66 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -72,6 +72,11 @@ public: cocos2d::ObjectFactory::Instance ins, Ref* object, SEL_ParseEvent callBack); + + void registerTypeAndCallBack(const std::string& classType, + cocos2d::ObjectFactory::InstanceFunc ins, + Ref* object, + SEL_ParseEvent callBack); protected: GUIReader(); ~GUIReader(); @@ -85,8 +90,8 @@ protected: ParseObjectMap _mapObject; public: - ParseCallBackMap getParseCallBackMap() { return _mapParseSelector; }; - ParseObjectMap getParseObjectMap() { return _mapObject; }; + ParseCallBackMap* getParseCallBackMap() { return &_mapParseSelector; }; + ParseObjectMap* getParseObjectMap() { return &_mapObject; }; }; diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java deleted file mode 100644 index fd4cd81954..0000000000 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ****************************************************************************/ -package org.cocos2dx.lib; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import android.content.Context; -import android.content.res.AssetManager; -import android.opengl.ETC1Util; -import android.util.Log; - -public class Cocos2dxETCLoader { - private static final String ASSETS_PATH = "assets/"; - private static Context context; - - public static boolean loadTexture(String filePath) { - if (! ETC1Util.isETC1Supported()) { - return false; - } - - if (filePath.length() == 0) { - return false; - } - - // Create ETC1Texture - InputStream inputStream = null; - ETC1Util.ETC1Texture texture = null; - AssetManager assetManager = null; - try { - if (filePath.charAt(0) == '/') { - // absolute path - inputStream = new FileInputStream(filePath); - } else { - // remove prefix: "assets/" - if (filePath.startsWith(ASSETS_PATH)) { - filePath = filePath.substring(ASSETS_PATH.length()); - } - assetManager = context.getAssets(); - inputStream = assetManager.open(filePath); - } - - texture = ETC1Util.createTexture(inputStream); - inputStream.close(); - } catch (Exception e) { - Log.d("Cocos2dx", "Unable to create texture for " + filePath); - - texture = null; - } - - if (texture != null) { - boolean ret = true; - - try { - final int width = texture.getWidth(); - final int height = texture.getHeight(); - final int length = texture.getData().remaining(); - - final byte[] data = new byte[length]; - final ByteBuffer buf = ByteBuffer.wrap(data); - buf.order(ByteOrder.nativeOrder()); - buf.put(texture.getData()); - - nativeSetTextureInfo(width, - height, - data, - length); - } catch (Exception e) - { - Log.d("invoke native function error", e.toString()); - ret = false; - } - - return ret; - } else { - return false; - } - } - - public static void setContext(Context context) { - Cocos2dxETCLoader.context = context; - } - - private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data, - final int dataLength); -} diff --git a/cocos/platform/ios/CCEAGLView.mm b/cocos/platform/ios/CCEAGLView.mm index 3c5c1c7b37..87a02a566c 100644 --- a/cocos/platform/ios/CCEAGLView.mm +++ b/cocos/platform/ios/CCEAGLView.mm @@ -374,7 +374,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. for(UIView* view in subviews) { - if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")]) + if([view isKindOfClass:NSClassFromString(@"CCCustomUITextField")] || + [view isKindOfClass:NSClassFromString(@"UICustomUITextField")]) { if ([view isFirstResponder]) { diff --git a/cocos/platform/win32/CCFileUtilsWin32.cpp b/cocos/platform/win32/CCFileUtilsWin32.cpp index c43339c8a7..1e174ef13e 100644 --- a/cocos/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/platform/win32/CCFileUtilsWin32.cpp @@ -147,7 +147,7 @@ static Data getData(const std::string& filename, bool forString) WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); - HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, nullptr); + HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, nullptr); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); size = ::GetFileSize(fileHandle, nullptr); @@ -222,7 +222,7 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); - HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, nullptr); + HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, nullptr); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); *size = ::GetFileSize(fileHandle, nullptr); diff --git a/cocos/scripting/lua-bindings/auto/api/ControlButton.lua b/cocos/scripting/lua-bindings/auto/api/ControlButton.lua index 1d965170ff..5d757d9b16 100644 --- a/cocos/scripting/lua-bindings/auto/api/ControlButton.lua +++ b/cocos/scripting/lua-bindings/auto/api/ControlButton.lua @@ -122,7 +122,7 @@ -- @function [parent=#ControlButton] getBackgroundSpriteForState -- @param self -- @param #int state --- @return Scale9Sprite#Scale9Sprite ret (return value: cc.Scale9Sprite) +-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite) -------------------------------- -- @@ -159,7 +159,7 @@ -- -- @function [parent=#ControlButton] getBackgroundSprite -- @param self --- @return Scale9Sprite#Scale9Sprite ret (return value: cc.Scale9Sprite) +-- @return Scale9Sprite#Scale9Sprite ret (return value: ccui.Scale9Sprite) -------------------------------- -- Returns the title color used for a state.
@@ -205,7 +205,7 @@ -- in "CCControlState". -- @function [parent=#ControlButton] setBackgroundSpriteForState -- @param self --- @param #cc.Scale9Sprite sprite +-- @param #ccui.Scale9Sprite sprite -- @param #int state -------------------------------- @@ -218,7 +218,7 @@ -- -- @function [parent=#ControlButton] setBackgroundSprite -- @param self --- @param #cc.Scale9Sprite var +-- @param #ccui.Scale9Sprite var -------------------------------- -- @@ -288,9 +288,9 @@ -- @return string#string ret (return value: string) -------------------------------- --- @overload self, cc.Scale9Sprite +-- @overload self, ccui.Scale9Sprite -- @overload self --- @overload self, cc.Node, cc.Scale9Sprite +-- @overload self, cc.Node, ccui.Scale9Sprite -- @overload self, string, string, float -- @function [parent=#ControlButton] create -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/EditBox.lua b/cocos/scripting/lua-bindings/auto/api/EditBox.lua deleted file mode 100644 index 7aae0b17ee..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/EditBox.lua +++ /dev/null @@ -1,182 +0,0 @@ - --------------------------------- --- @module EditBox --- @extend ControlButton,IMEDelegate --- @parent_module cc - --------------------------------- --- Get the text entered in the edit box.
--- return The text entered in the edit box. --- @function [parent=#EditBox] getText --- @param self --- @return char#char ret (return value: char) - --------------------------------- --- Set the placeholder's font name.
--- param pFontName The font name. --- @function [parent=#EditBox] setPlaceholderFontName --- @param self --- @param #char pFontName - --------------------------------- --- Get a text in the edit box that acts as a placeholder when an
--- edit box is empty. --- @function [parent=#EditBox] getPlaceHolder --- @param self --- @return char#char ret (return value: char) - --------------------------------- --- Set the font name.
--- param pFontName The font name. --- @function [parent=#EditBox] setFontName --- @param self --- @param #char pFontName - --------------------------------- --- Set the placeholder's font size.
--- param fontSize The font size. --- @function [parent=#EditBox] setPlaceholderFontSize --- @param self --- @param #int fontSize - --------------------------------- --- Set the input mode of the edit box.
--- param inputMode One of the EditBox::InputMode constants. --- @function [parent=#EditBox] setInputMode --- @param self --- @param #int inputMode - --------------------------------- --- Set the font color of the placeholder text when the edit box is empty.
--- Not supported on IOS. --- @function [parent=#EditBox] setPlaceholderFontColor --- @param self --- @param #color3b_table color - --------------------------------- --- Set the font color of the widget's text. --- @function [parent=#EditBox] setFontColor --- @param self --- @param #color3b_table color - --------------------------------- --- Set the placeholder's font.
--- param pFontName The font name.
--- param fontSize The font size. --- @function [parent=#EditBox] setPlaceholderFont --- @param self --- @param #char pFontName --- @param #int fontSize - --------------------------------- --- Set the font size.
--- param fontSize The font size. --- @function [parent=#EditBox] setFontSize --- @param self --- @param #int fontSize - --------------------------------- --- Init edit box with specified size. This method should be invoked right after constructor.
--- param size The size of edit box. --- @function [parent=#EditBox] initWithSizeAndBackgroundSprite --- @param self --- @param #size_table size --- @param #cc.Scale9Sprite pNormal9SpriteBg --- @return bool#bool ret (return value: bool) - --------------------------------- --- Set a text in the edit box that acts as a placeholder when an
--- edit box is empty.
--- param pText The given text. --- @function [parent=#EditBox] setPlaceHolder --- @param self --- @param #char pText - --------------------------------- --- Set the return type that are to be applied to the edit box.
--- param returnType One of the EditBox::KeyboardReturnType constants. --- @function [parent=#EditBox] setReturnType --- @param self --- @param #int returnType - --------------------------------- --- Set the input flags that are to be applied to the edit box.
--- param inputFlag One of the EditBox::InputFlag constants. --- @function [parent=#EditBox] setInputFlag --- @param self --- @param #int inputFlag - --------------------------------- --- Gets the maximum input length of the edit box.
--- return Maximum input length. --- @function [parent=#EditBox] getMaxLength --- @param self --- @return int#int ret (return value: int) - --------------------------------- --- Set the text entered in the edit box.
--- param pText The given text. --- @function [parent=#EditBox] setText --- @param self --- @param #char pText - --------------------------------- --- Sets the maximum input length of the edit box.
--- Setting this value enables multiline input mode by default.
--- Available on Android, iOS and Windows Phone.
--- param maxLength The maximum length. --- @function [parent=#EditBox] setMaxLength --- @param self --- @param #int maxLength - --------------------------------- --- Set the font.
--- param pFontName The font name.
--- param fontSize The font size. --- @function [parent=#EditBox] setFont --- @param self --- @param #char pFontName --- @param #int fontSize - --------------------------------- --- create a edit box with size.
--- return An autorelease pointer of EditBox, you don't need to release it only if you retain it again. --- @function [parent=#EditBox] create --- @param self --- @param #size_table size --- @param #cc.Scale9Sprite pNormal9SpriteBg --- @param #cc.Scale9Sprite pPressed9SpriteBg --- @param #cc.Scale9Sprite pDisabled9SpriteBg --- @return EditBox#EditBox ret (return value: cc.EditBox) - --------------------------------- --- --- @function [parent=#EditBox] setAnchorPoint --- @param self --- @param #vec2_table anchorPoint - --------------------------------- --- --- @function [parent=#EditBox] setPosition --- @param self --- @param #vec2_table pos - --------------------------------- --- --- @function [parent=#EditBox] setVisible --- @param self --- @param #bool visible - --------------------------------- --- --- @function [parent=#EditBox] setContentSize --- @param self --- @param #size_table size - --------------------------------- --- Constructor.
--- js ctor --- @function [parent=#EditBox] EditBox --- @param self - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua index 6798a0b06d..99a0edbd12 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua @@ -1,11 +1,6 @@ -------------------------------- -- @module cc --------------------------------------------------------- --- the cc Scale9Sprite --- @field [parent=#cc] Scale9Sprite#Scale9Sprite Scale9Sprite preloaded module - - -------------------------------------------------------- -- the cc Control -- @field [parent=#cc] Control#Control Control preloaded module @@ -66,11 +61,6 @@ -- @field [parent=#cc] TableView#TableView TableView preloaded module --------------------------------------------------------- --- the cc EditBox --- @field [parent=#cc] EditBox#EditBox EditBox preloaded module - - -------------------------------------------------------- -- the cc AssetsManager -- @field [parent=#cc] AssetsManager#AssetsManager AssetsManager preloaded module diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index 81f1c26626..6958a28aa3 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -5,1347 +5,6 @@ -int lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Rect arg0; - - ok &= luaval_to_rect(tolua_S, 2, &arg0, "cc.Scale9Sprite:resizableSpriteWithCapInsets"); - if(!ok) - return 0; - cocos2d::extension::Scale9Sprite* ret = cobj->resizableSpriteWithCapInsets(arg0); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:resizableSpriteWithCapInsets",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setInsetBottom(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetBottom'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Scale9Sprite:setInsetBottom"); - if(!ok) - return 0; - cobj->setInsetBottom(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setInsetBottom",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetBottom'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 1) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:initWithSpriteFrameName"); - - if (!ok) { break; } - bool ret = cobj->initWithSpriteFrameName(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:initWithSpriteFrameName"); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithSpriteFrameName"); - - if (!ok) { break; } - bool ret = cobj->initWithSpriteFrameName(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:initWithSpriteFrameName",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setInsetTop(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetTop'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Scale9Sprite:setInsetTop"); - if(!ok) - return 0; - cobj->setInsetTop(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setInsetTop",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetTop'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_init(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_init'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - bool ret = cobj->init(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:init",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_init'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setPreferredSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setPreferredSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Size arg0; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.Scale9Sprite:setPreferredSize"); - if(!ok) - return 0; - cobj->setPreferredSize(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setPreferredSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setPreferredSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::SpriteFrame* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0); - if(!ok) - return 0; - cobj->setSpriteFrame(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setSpriteFrame",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 3) { - cocos2d::SpriteBatchNode* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteBatchNode",&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithBatchNode"); - - if (!ok) { break; } - cocos2d::Rect arg2; - ok &= luaval_to_rect(tolua_S, 4, &arg2, "cc.Scale9Sprite:initWithBatchNode"); - - if (!ok) { break; } - bool ret = cobj->initWithBatchNode(arg0, arg1, arg2); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 4) { - cocos2d::SpriteBatchNode* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteBatchNode",&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithBatchNode"); - - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.Scale9Sprite:initWithBatchNode"); - - if (!ok) { break; } - cocos2d::Rect arg3; - ok &= luaval_to_rect(tolua_S, 5, &arg3, "cc.Scale9Sprite:initWithBatchNode"); - - if (!ok) { break; } - bool ret = cobj->initWithBatchNode(arg0, arg1, arg2, arg3); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:initWithBatchNode",argc, 4); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getInsetBottom(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetBottom'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - double ret = cobj->getInsetBottom(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getInsetBottom",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetBottom'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getCapInsets(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getCapInsets'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::Rect ret = cobj->getCapInsets(); - rect_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getCapInsets",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getCapInsets'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 4) - { - cocos2d::SpriteBatchNode* arg0; - cocos2d::Rect arg1; - bool arg2; - cocos2d::Rect arg3; - - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteBatchNode",&arg0); - - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:updateWithBatchNode"); - - ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.Scale9Sprite:updateWithBatchNode"); - - ok &= luaval_to_rect(tolua_S, 5, &arg3, "cc.Scale9Sprite:updateWithBatchNode"); - if(!ok) - return 0; - bool ret = cobj->updateWithBatchNode(arg0, arg1, arg2, arg3); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:updateWithBatchNode",argc, 4); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getInsetRight(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetRight'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - double ret = cobj->getInsetRight(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getInsetRight",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetRight'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getOriginalSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getOriginalSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::Size ret = cobj->getOriginalSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getOriginalSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getOriginalSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_initWithFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithFile'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 2) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - bool ret = cobj->initWithFile(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 3) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - cocos2d::Rect arg2; - ok &= luaval_to_rect(tolua_S, 4, &arg2, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - bool ret = cobj->initWithFile(arg0, arg1, arg2); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - cocos2d::Rect arg0; - ok &= luaval_to_rect(tolua_S, 2, &arg0, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - bool ret = cobj->initWithFile(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 1) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:initWithFile"); - - if (!ok) { break; } - bool ret = cobj->initWithFile(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:initWithFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithFile'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getInsetTop(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetTop'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - double ret = cobj->getInsetTop(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getInsetTop",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetTop'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setInsetLeft(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetLeft'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Scale9Sprite:setInsetLeft"); - if(!ok) - return 0; - cobj->setInsetLeft(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setInsetLeft",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetLeft'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 1) { - cocos2d::SpriteFrame* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0); - - if (!ok) { break; } - bool ret = cobj->initWithSpriteFrame(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 2) { - cocos2d::SpriteFrame* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0); - - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:initWithSpriteFrame"); - - if (!ok) { break; } - bool ret = cobj->initWithSpriteFrame(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - }while(0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:initWithSpriteFrame",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getPreferredSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getPreferredSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cocos2d::Size ret = cobj->getPreferredSize(); - size_to_luaval(tolua_S, ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getPreferredSize",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getPreferredSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setCapInsets(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setCapInsets'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Rect arg0; - - ok &= luaval_to_rect(tolua_S, 2, &arg0, "cc.Scale9Sprite:setCapInsets"); - if(!ok) - return 0; - cobj->setCapInsets(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setCapInsets",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setCapInsets'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_getInsetLeft(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetLeft'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - double ret = cobj->getInsetLeft(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:getInsetLeft",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_getInsetLeft'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_setInsetRight(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::Scale9Sprite*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetRight'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - double arg0; - - ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.Scale9Sprite:setInsetRight"); - if(!ok) - return 0; - cobj->setInsetRight(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:setInsetRight",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_setInsetRight'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::Rect arg2; - ok &= luaval_to_rect(tolua_S, 4, &arg2, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 0) - { - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - cocos2d::Rect arg0; - ok &= luaval_to_rect(tolua_S, 2, &arg0, "cc.Scale9Sprite:create"); - if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0, arg1); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:create"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::create(arg0); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d", "cc.Scale9Sprite:create",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 2) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:createWithSpriteFrameName"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:createWithSpriteFrameName"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0, arg1); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Scale9Sprite:createWithSpriteFrameName"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrameName(arg0); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d", "cc.Scale9Sprite:createWithSpriteFrameName",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Scale9Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 2) - { - cocos2d::SpriteFrame* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Scale9Sprite:createWithSpriteFrame"); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0, arg1); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 1) - { - cocos2d::SpriteFrame* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0); - if (!ok) { break; } - cocos2d::extension::Scale9Sprite* ret = cocos2d::extension::Scale9Sprite::createWithSpriteFrame(arg0); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); - return 1; - } - } while (0); - ok = true; - CCLOG("%s has wrong number of arguments: %d, was expecting %d", "cc.Scale9Sprite:createWithSpriteFrame",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_extension_Scale9Sprite_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::Scale9Sprite* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj = new cocos2d::extension::Scale9Sprite(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Scale9Sprite"); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scale9Sprite:Scale9Sprite",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_Scale9Sprite_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_extension_Scale9Sprite_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (Scale9Sprite)"); - return 0; -} - -int lua_register_cocos2dx_extension_Scale9Sprite(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.Scale9Sprite"); - tolua_cclass(tolua_S,"Scale9Sprite","cc.Scale9Sprite","cc.Node",nullptr); - - tolua_beginmodule(tolua_S,"Scale9Sprite"); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_Scale9Sprite_constructor); - tolua_function(tolua_S,"resizableSpriteWithCapInsets",lua_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets); - tolua_function(tolua_S,"setInsetBottom",lua_cocos2dx_extension_Scale9Sprite_setInsetBottom); - tolua_function(tolua_S,"initWithSpriteFrameName",lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName); - tolua_function(tolua_S,"setInsetTop",lua_cocos2dx_extension_Scale9Sprite_setInsetTop); - tolua_function(tolua_S,"init",lua_cocos2dx_extension_Scale9Sprite_init); - tolua_function(tolua_S,"setPreferredSize",lua_cocos2dx_extension_Scale9Sprite_setPreferredSize); - tolua_function(tolua_S,"setSpriteFrame",lua_cocos2dx_extension_Scale9Sprite_setSpriteFrame); - tolua_function(tolua_S,"initWithBatchNode",lua_cocos2dx_extension_Scale9Sprite_initWithBatchNode); - tolua_function(tolua_S,"getInsetBottom",lua_cocos2dx_extension_Scale9Sprite_getInsetBottom); - tolua_function(tolua_S,"getCapInsets",lua_cocos2dx_extension_Scale9Sprite_getCapInsets); - tolua_function(tolua_S,"updateWithBatchNode",lua_cocos2dx_extension_Scale9Sprite_updateWithBatchNode); - tolua_function(tolua_S,"getInsetRight",lua_cocos2dx_extension_Scale9Sprite_getInsetRight); - tolua_function(tolua_S,"getOriginalSize",lua_cocos2dx_extension_Scale9Sprite_getOriginalSize); - tolua_function(tolua_S,"initWithFile",lua_cocos2dx_extension_Scale9Sprite_initWithFile); - tolua_function(tolua_S,"getInsetTop",lua_cocos2dx_extension_Scale9Sprite_getInsetTop); - tolua_function(tolua_S,"setInsetLeft",lua_cocos2dx_extension_Scale9Sprite_setInsetLeft); - tolua_function(tolua_S,"initWithSpriteFrame",lua_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame); - tolua_function(tolua_S,"getPreferredSize",lua_cocos2dx_extension_Scale9Sprite_getPreferredSize); - tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_extension_Scale9Sprite_setCapInsets); - tolua_function(tolua_S,"getInsetLeft",lua_cocos2dx_extension_Scale9Sprite_getInsetLeft); - tolua_function(tolua_S,"setInsetRight",lua_cocos2dx_extension_Scale9Sprite_setInsetRight); - tolua_function(tolua_S,"create", lua_cocos2dx_extension_Scale9Sprite_create); - tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName); - tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::extension::Scale9Sprite).name(); - g_luaType[typeName] = "cc.Scale9Sprite"; - g_typeCast["Scale9Sprite"] = "cc.Scale9Sprite"; - return 1; -} - int lua_cocos2dx_extension_Control_setEnabled(lua_State* tolua_S) { int argc = 0; @@ -2927,8 +1586,8 @@ int lua_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(lua_State* ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.ControlButton:getBackgroundSpriteForState"); if(!ok) return 0; - cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSpriteForState(arg0); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); + cocos2d::ui::Scale9Sprite* ret = cobj->getBackgroundSpriteForState(arg0); + object_to_luaval(tolua_S, "ccui.Scale9Sprite",(cocos2d::ui::Scale9Sprite*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.ControlButton:getBackgroundSpriteForState",argc, 1); @@ -3196,8 +1855,8 @@ int lua_cocos2dx_extension_ControlButton_getBackgroundSprite(lua_State* tolua_S) { if(!ok) return 0; - cocos2d::extension::Scale9Sprite* ret = cobj->getBackgroundSprite(); - object_to_luaval(tolua_S, "cc.Scale9Sprite",(cocos2d::extension::Scale9Sprite*)ret); + cocos2d::ui::Scale9Sprite* ret = cobj->getBackgroundSprite(); + object_to_luaval(tolua_S, "ccui.Scale9Sprite",(cocos2d::ui::Scale9Sprite*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.ControlButton:getBackgroundSprite",argc, 0); @@ -3427,10 +2086,10 @@ int lua_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(lua_State* argc = lua_gettop(tolua_S)-1; if (argc == 2) { - cocos2d::extension::Scale9Sprite* arg0; + cocos2d::ui::Scale9Sprite* arg0; cocos2d::extension::Control::State arg1; - ok &= luaval_to_object(tolua_S, 2, "cc.Scale9Sprite",&arg0); + ok &= luaval_to_object(tolua_S, 2, "ccui.Scale9Sprite",&arg0); ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.ControlButton:setBackgroundSpriteForState"); if(!ok) @@ -3522,9 +2181,9 @@ int lua_cocos2dx_extension_ControlButton_setBackgroundSprite(lua_State* tolua_S) argc = lua_gettop(tolua_S)-1; if (argc == 1) { - cocos2d::extension::Scale9Sprite* arg0; + cocos2d::ui::Scale9Sprite* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Scale9Sprite",&arg0); + ok &= luaval_to_object(tolua_S, 2, "ccui.Scale9Sprite",&arg0); if(!ok) return 0; cobj->setBackgroundSprite(arg0); @@ -3973,8 +2632,8 @@ int lua_cocos2dx_extension_ControlButton_create(lua_State* tolua_S) { if (argc == 1) { - cocos2d::extension::Scale9Sprite* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Scale9Sprite",&arg0); + cocos2d::ui::Scale9Sprite* arg0; + ok &= luaval_to_object(tolua_S, 2, "ccui.Scale9Sprite",&arg0); if (!ok) { break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0); object_to_luaval(tolua_S, "cc.ControlButton",(cocos2d::extension::ControlButton*)ret); @@ -3999,8 +2658,8 @@ int lua_cocos2dx_extension_ControlButton_create(lua_State* tolua_S) cocos2d::Node* arg0; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0); if (!ok) { break; } - cocos2d::extension::Scale9Sprite* arg1; - ok &= luaval_to_object(tolua_S, 3, "cc.Scale9Sprite",&arg1); + cocos2d::ui::Scale9Sprite* arg1; + ok &= luaval_to_object(tolua_S, 3, "ccui.Scale9Sprite",&arg1); if (!ok) { break; } cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1); object_to_luaval(tolua_S, "cc.ControlButton",(cocos2d::extension::ControlButton*)ret); @@ -12160,976 +10819,6 @@ int lua_register_cocos2dx_extension_TableView(lua_State* tolua_S) return 1; } -int lua_cocos2dx_extension_EditBox_getText(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getText'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - const char* ret = cobj->getText(); - tolua_pushstring(tolua_S,(const char*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:getText",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getText'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setPlaceholderFontName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setPlaceholderFontName"); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - cobj->setPlaceholderFontName(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setPlaceholderFontName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_getPlaceHolder(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getPlaceHolder'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - const char* ret = cobj->getPlaceHolder(); - tolua_pushstring(tolua_S,(const char*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:getPlaceHolder",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getPlaceHolder'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setFontName(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontName'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setFontName"); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - cobj->setFontName(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setFontName",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontName'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setPlaceholderFontSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setPlaceholderFontSize"); - if(!ok) - return 0; - cobj->setPlaceholderFontSize(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setPlaceholderFontSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setInputMode(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setInputMode'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::extension::EditBox::InputMode arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setInputMode"); - if(!ok) - return 0; - cobj->setInputMode(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setInputMode",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setInputMode'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setPlaceholderFontColor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontColor'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Color3B arg0; - - ok &= luaval_to_color3b(tolua_S, 2, &arg0, "cc.EditBox:setPlaceholderFontColor"); - if(!ok) - return 0; - cobj->setPlaceholderFontColor(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setPlaceholderFontColor",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFontColor'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setFontColor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontColor'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Color3B arg0; - - ok &= luaval_to_color3b(tolua_S, 2, &arg0, "cc.EditBox:setFontColor"); - if(!ok) - return 0; - cobj->setFontColor(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setFontColor",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontColor'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setPlaceholderFont(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFont'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const char* arg0; - int arg1; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setPlaceholderFont"); arg0 = arg0_tmp.c_str(); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.EditBox:setPlaceholderFont"); - if(!ok) - return 0; - cobj->setPlaceholderFont(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setPlaceholderFont",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceholderFont'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setFontSize(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFontSize'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setFontSize"); - if(!ok) - return 0; - cobj->setFontSize(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setFontSize",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFontSize'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - cocos2d::Size arg0; - cocos2d::extension::Scale9Sprite* arg1; - - ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.EditBox:initWithSizeAndBackgroundSprite"); - - ok &= luaval_to_object(tolua_S, 3, "cc.Scale9Sprite",&arg1); - if(!ok) - return 0; - bool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:initWithSizeAndBackgroundSprite",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setPlaceHolder(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setPlaceHolder'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setPlaceHolder"); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - cobj->setPlaceHolder(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setPlaceHolder",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setPlaceHolder'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setReturnType(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setReturnType'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::extension::EditBox::KeyboardReturnType arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setReturnType"); - if(!ok) - return 0; - cobj->setReturnType(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setReturnType",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setReturnType'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setInputFlag(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setInputFlag'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::extension::EditBox::InputFlag arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setInputFlag"); - if(!ok) - return 0; - cobj->setInputFlag(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setInputFlag",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setInputFlag'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_getMaxLength(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_getMaxLength'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - int ret = cobj->getMaxLength(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:getMaxLength",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_getMaxLength'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setText(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setText'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - const char* arg0; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setText"); arg0 = arg0_tmp.c_str(); - if(!ok) - return 0; - cobj->setText(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setText",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setText'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setMaxLength(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setMaxLength'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - int arg0; - - ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EditBox:setMaxLength"); - if(!ok) - return 0; - cobj->setMaxLength(arg0); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setMaxLength",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setMaxLength'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_setFont(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::extension::EditBox*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_EditBox_setFont'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - const char* arg0; - int arg1; - - std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "cc.EditBox:setFont"); arg0 = arg0_tmp.c_str(); - - ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "cc.EditBox:setFont"); - if(!ok) - return 0; - cobj->setFont(arg0, arg1); - return 0; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:setFont",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_setFont'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_extension_EditBox_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 2) - { - cocos2d::Size arg0; - cocos2d::extension::Scale9Sprite* arg1; - ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.EditBox:create"); - ok &= luaval_to_object(tolua_S, 3, "cc.Scale9Sprite",&arg1); - if(!ok) - return 0; - cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1); - object_to_luaval(tolua_S, "cc.EditBox",(cocos2d::extension::EditBox*)ret); - return 1; - } - if (argc == 3) - { - cocos2d::Size arg0; - cocos2d::extension::Scale9Sprite* arg1; - cocos2d::extension::Scale9Sprite* arg2; - ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.EditBox:create"); - ok &= luaval_to_object(tolua_S, 3, "cc.Scale9Sprite",&arg1); - ok &= luaval_to_object(tolua_S, 4, "cc.Scale9Sprite",&arg2); - if(!ok) - return 0; - cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "cc.EditBox",(cocos2d::extension::EditBox*)ret); - return 1; - } - if (argc == 4) - { - cocos2d::Size arg0; - cocos2d::extension::Scale9Sprite* arg1; - cocos2d::extension::Scale9Sprite* arg2; - cocos2d::extension::Scale9Sprite* arg3; - ok &= luaval_to_size(tolua_S, 2, &arg0, "cc.EditBox:create"); - ok &= luaval_to_object(tolua_S, 3, "cc.Scale9Sprite",&arg1); - ok &= luaval_to_object(tolua_S, 4, "cc.Scale9Sprite",&arg2); - ok &= luaval_to_object(tolua_S, 5, "cc.Scale9Sprite",&arg3); - if(!ok) - return 0; - cocos2d::extension::EditBox* ret = cocos2d::extension::EditBox::create(arg0, arg1, arg2, arg3); - object_to_luaval(tolua_S, "cc.EditBox",(cocos2d::extension::EditBox*)ret); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.EditBox:create",argc, 2); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_extension_EditBox_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::extension::EditBox* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - return 0; - cobj = new cocos2d::extension::EditBox(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EditBox"); - return 1; - } - CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.EditBox:EditBox",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_EditBox_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_extension_EditBox_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (EditBox)"); - return 0; -} - -int lua_register_cocos2dx_extension_EditBox(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.EditBox"); - tolua_cclass(tolua_S,"EditBox","cc.EditBox","cc.ControlButton",nullptr); - - tolua_beginmodule(tolua_S,"EditBox"); - tolua_function(tolua_S,"new",lua_cocos2dx_extension_EditBox_constructor); - tolua_function(tolua_S,"getText",lua_cocos2dx_extension_EditBox_getText); - tolua_function(tolua_S,"setPlaceholderFontName",lua_cocos2dx_extension_EditBox_setPlaceholderFontName); - tolua_function(tolua_S,"getPlaceHolder",lua_cocos2dx_extension_EditBox_getPlaceHolder); - tolua_function(tolua_S,"setFontName",lua_cocos2dx_extension_EditBox_setFontName); - tolua_function(tolua_S,"setPlaceholderFontSize",lua_cocos2dx_extension_EditBox_setPlaceholderFontSize); - tolua_function(tolua_S,"setInputMode",lua_cocos2dx_extension_EditBox_setInputMode); - tolua_function(tolua_S,"setPlaceholderFontColor",lua_cocos2dx_extension_EditBox_setPlaceholderFontColor); - tolua_function(tolua_S,"setFontColor",lua_cocos2dx_extension_EditBox_setFontColor); - tolua_function(tolua_S,"setPlaceholderFont",lua_cocos2dx_extension_EditBox_setPlaceholderFont); - tolua_function(tolua_S,"setFontSize",lua_cocos2dx_extension_EditBox_setFontSize); - tolua_function(tolua_S,"initWithSizeAndBackgroundSprite",lua_cocos2dx_extension_EditBox_initWithSizeAndBackgroundSprite); - tolua_function(tolua_S,"setPlaceHolder",lua_cocos2dx_extension_EditBox_setPlaceHolder); - tolua_function(tolua_S,"setReturnType",lua_cocos2dx_extension_EditBox_setReturnType); - tolua_function(tolua_S,"setInputFlag",lua_cocos2dx_extension_EditBox_setInputFlag); - tolua_function(tolua_S,"getMaxLength",lua_cocos2dx_extension_EditBox_getMaxLength); - tolua_function(tolua_S,"setText",lua_cocos2dx_extension_EditBox_setText); - tolua_function(tolua_S,"setMaxLength",lua_cocos2dx_extension_EditBox_setMaxLength); - tolua_function(tolua_S,"setFont",lua_cocos2dx_extension_EditBox_setFont); - tolua_function(tolua_S,"create", lua_cocos2dx_extension_EditBox_create); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::extension::EditBox).name(); - g_luaType[typeName] = "cc.EditBox"; - g_typeCast["EditBox"] = "cc.EditBox"; - return 1; -} - int lua_cocos2dx_extension_AssetsManager_setStoragePath(lua_State* tolua_S) { int argc = 0; @@ -13845,19 +11534,17 @@ TOLUA_API int register_all_cocos2dx_extension(lua_State* tolua_S) lua_register_cocos2dx_extension_Control(tolua_S); lua_register_cocos2dx_extension_TableViewCell(tolua_S); - lua_register_cocos2dx_extension_Scale9Sprite(tolua_S); + lua_register_cocos2dx_extension_ControlStepper(tolua_S); lua_register_cocos2dx_extension_ControlSwitch(tolua_S); lua_register_cocos2dx_extension_ScrollView(tolua_S); lua_register_cocos2dx_extension_TableView(tolua_S); - lua_register_cocos2dx_extension_AssetsManager(tolua_S); - lua_register_cocos2dx_extension_ControlButton(tolua_S); - lua_register_cocos2dx_extension_EditBox(tolua_S); lua_register_cocos2dx_extension_ControlSlider(tolua_S); - lua_register_cocos2dx_extension_ControlStepper(tolua_S); lua_register_cocos2dx_extension_ControlSaturationBrightnessPicker(tolua_S); lua_register_cocos2dx_extension_ControlColourPicker(tolua_S); lua_register_cocos2dx_extension_ControlPotentiometer(tolua_S); + lua_register_cocos2dx_extension_ControlButton(tolua_S); lua_register_cocos2dx_extension_ControlHuePicker(tolua_S); + lua_register_cocos2dx_extension_AssetsManager(tolua_S); tolua_endmodule(tolua_S); return 1; diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp index ce1bfeebc3..cbd41e6a6b 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp @@ -243,53 +243,6 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp index da15b71819..e8da5290ee 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -1995,23 +1995,23 @@ void vec3_to_luaval(lua_State* L,const cocos2d::Vec3& vec3) lua_rawset(L, -3); } -void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec3) +void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec4) { if (NULL == L) return; lua_newtable(L); /* L: table */ lua_pushstring(L, "x"); /* L: table key */ - lua_pushnumber(L, (lua_Number) vec3.x); /* L: table key value*/ + lua_pushnumber(L, (lua_Number) vec4.x); /* L: table key value*/ lua_rawset(L, -3); /* table[key] = value, L: table */ lua_pushstring(L, "y"); /* L: table key */ - lua_pushnumber(L, (lua_Number) vec3.y); /* L: table key value*/ + lua_pushnumber(L, (lua_Number) vec4.y); /* L: table key value*/ lua_rawset(L, -3); lua_pushstring(L, "z"); /* L: table key */ - lua_pushnumber(L, (lua_Number) vec3.z); /* L: table key value*/ + lua_pushnumber(L, (lua_Number) vec4.z); /* L: table key value*/ lua_rawset(L, -3); lua_pushstring(L, "w"); /* L: table key */ - lua_pushnumber(L, (lua_Number) vec3.z); /* L: table key value*/ + lua_pushnumber(L, (lua_Number) vec4.w); /* L: table key value*/ lua_rawset(L, -3); } diff --git a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h index 2d07f4a2f2..6626ecad1c 100644 --- a/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/cocos/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -240,7 +240,7 @@ extern bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vectorinit(className, createFunc, setPropsFunc); + return reader; + } + + Ref* CustomGUIReader::createInstance() + { + Ref* result = nullptr; + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + stack->executeFunction(_createFunc, 0, 1, [&result](lua_State* L,int numReturn){ + result = static_cast(tolua_tousertype(L, -1, nullptr)); + lua_pop(L, 1); + }); + return result; + } + + CustomGUIReader::CustomGUIReader() + :_className() + ,_createFunc(0) + ,_setPropsFunc(0) + { + + } + + CustomGUIReader::~CustomGUIReader() + { + if (_createFunc) + { + LuaEngine::getInstance()->removeScriptHandler(_createFunc); + _createFunc = 0; + } + if (_setPropsFunc) + { + LuaEngine::getInstance()->removeScriptHandler(_setPropsFunc); + _setPropsFunc = 0; + } + } + + void CustomGUIReader::init(std::string &className, int createFunc, int setPropsFunc) + { + _className = className; + _createFunc = createFunc; + _setPropsFunc = setPropsFunc; + + ObjectFactory* factoryCreate = ObjectFactory::getInstance(); + ObjectFactory::TInfo t; + t._class = className; + t._func = CC_CALLBACK_0(CustomGUIReader::createInstance, this); + factoryCreate->registerType(t); + + auto guiReader = GUIReader::getInstance(); + auto objMap = guiReader->getParseObjectMap(); + (*objMap)[className] = this; + auto callbackMap = guiReader->getParseCallBackMap(); + (*callbackMap)[className] = parseselector(CustomGUIReader::setCustomProps); + } + + void CustomGUIReader::setCustomProps(const std::string &classType, cocos2d::Ref *widget, const rapidjson::Value &customOptions) + { + if (_setPropsFunc != 0) + { + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + customOptions.Accept(writer); + + auto stack = LuaEngine::getInstance()->getLuaStack(); + stack->pushString(classType.c_str(), classType.size()); + stack->pushObject(widget, "cc.Ref"); + stack->pushString(buffer.GetString(), buffer.Size()); + stack->executeFunctionByHandler(_setPropsFunc, 3); + } + } +} diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h new file mode 100644 index 0000000000..b82ddd65aa --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h @@ -0,0 +1,34 @@ +#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CUSTOM_GUI_READER_H +#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CUSTOM_GUI_READER_H + +#include "cocostudio/WidgetReader/WidgetReader.h" + +USING_NS_CC; + +namespace cocostudio +{ + class CustomGUIReader : public Ref + { + public: + + CustomGUIReader(); + virtual ~CustomGUIReader(); + + static CustomGUIReader* create(std::string &className, int createFunc, int setPropsFunc); + + void init(std::string &className, int createFunc, int setPropsFunc); + + Ref* createInstance(); + + void setCustomProps(const std::string &classType, cocos2d::Ref *widget, const rapidjson::Value &customOptions); + + private: + std::string _className; + int _createFunc; + int _setPropsFunc; + }; +} + + + +#endif diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp index a8bca1e5dc..eabfb21ac0 100644 --- a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp @@ -30,6 +30,7 @@ #include "CCLuaValue.h" #include "CocoStudio.h" #include "CCLuaEngine.h" +#include "CustomGUIReader.h" using namespace cocostudio; @@ -554,6 +555,53 @@ static void extendActionTimeline(lua_State* L) lua_pop(L, 1); } +int lua_cocos2dx_CustomGUIReader_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"ccs.CustomGUIReader",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 3) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccs.CustomGUIReader:create"); + if (!ok) { break; } +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION arg1 = toluafix_ref_function(tolua_S,3,0); +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION arg2 = toluafix_ref_function(tolua_S,4,0); + + cocostudio::CustomGUIReader* ret = cocostudio::CustomGUIReader::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "ccs.CustomGUIReader",(cocostudio::CustomGUIReader*)ret); + return 1; + } + } while (0); + CCLOG("%s has wrong number of arguments: %d, was expecting %d", "ccs.CustomGUIReader:create",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CustomGUIReader_create'.",&tolua_err); +#endif + return 0; +} int register_all_cocos2dx_coco_studio_manual(lua_State* L) { @@ -569,6 +617,26 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L) return 0; } +int lua_register_cocos2dx_coco_studio_CustomGUIReader(lua_State* tolua_S) +{ + tolua_module(tolua_S,"ccs",0); + tolua_beginmodule(tolua_S,"ccs"); + + + tolua_usertype(tolua_S,"ccs.CustomGUIReader"); + tolua_cclass(tolua_S,"CustomGUIReader","ccs.CustomGUIReader","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"CustomGUIReader"); + tolua_function(tolua_S,"create",lua_cocos2dx_CustomGUIReader_create); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocostudio::CustomGUIReader).name(); + g_luaType[typeName] = "ccs.CustomGUIReader"; + g_typeCast["CustomGUIReader"] = "ccs.CustomGUIReader"; + + tolua_endmodule(tolua_S); + return 1; +} + int register_cocostudio_module(lua_State* L) { lua_getglobal(L, "_G"); @@ -576,6 +644,7 @@ int register_cocostudio_module(lua_State* L) { register_all_cocos2dx_studio(L); register_all_cocos2dx_coco_studio_manual(L); + lua_register_cocos2dx_coco_studio_CustomGUIReader(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp index b2f2e1c8a8..80498ab073 100644 --- a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp @@ -1045,7 +1045,7 @@ static void extendTableView(lua_State* L) int register_all_cocos2dx_extension_manual(lua_State* tolua_S) { extendControl(tolua_S); - extendEditBox(tolua_S); + /* extendEditBox(tolua_S); */ extendAssetsManager(tolua_S); extendScrollView(tolua_S); extendTableView(tolua_S); diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index c61e2b6ae3..cee7f1fd53 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -66,6 +66,7 @@ LOCAL_SRC_FILES += ../manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.cpp \ #cocostudio LOCAL_SRC_FILES += ../manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp \ + ../manual/cocostudio/CustomGUIReader.cpp \ ../auto/lua_cocos2dx_studio_auto.cpp #spine 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 36cecee16a..260b98b268 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 @@ -236,6 +236,10 @@ 15EFA64E198B3342000C57D3 /* lua.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E718CD8F470087CE3A /* lua.h */; }; 15EFA64F198B3342000C57D3 /* luaconf.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E818CD8F470087CE3A /* luaconf.h */; }; 15EFA650198B3342000C57D3 /* lualib.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ABCA1E918CD8F470087CE3A /* lualib.h */; }; + 566F015F19B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */; }; + 566F016019B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */; }; + 566F016119B5EB0F00FCA620 /* CustomGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */; }; + 566F016219B5EB0F00FCA620 /* CustomGUIReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -364,6 +368,8 @@ 1ABCA1FF18CD8F6E0087CE3A /* tolua++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "tolua++.h"; path = "../../../../external/lua/tolua/tolua++.h"; sourceTree = ""; }; 2905FACE18CF12E600240AA3 /* lua_cocos2dx_ui_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_ui_auto.cpp; sourceTree = ""; }; 2905FACF18CF12E600240AA3 /* lua_cocos2dx_ui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_ui_auto.hpp; sourceTree = ""; }; + 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomGUIReader.cpp; sourceTree = ""; }; + 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGUIReader.h; sourceTree = ""; }; C0D9BAFA1974D30000EC35BB /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../external/lua/lua/prebuilt/ios/liblua.a; sourceTree = ""; }; /* End PBXFileReference section */ @@ -507,6 +513,8 @@ 15EFA400198B2AB2000C57D3 /* cocostudio */ = { isa = PBXGroup; children = ( + 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */, + 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */, 15EFA401198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.cpp */, 15EFA402198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.hpp */, ); @@ -738,6 +746,7 @@ 15C1C2EE19874CBE00A46ACC /* tolua_fix.h in Headers */, 155C7E2019A71CCC00F08B25 /* LuaSkeletonAnimation.h in Headers */, 15415AB719A71A53004F1E71 /* io.h in Headers */, + 566F016119B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15C1C2DC19874B4400A46ACC /* xxtea.h in Headers */, 15415AD319A71A53004F1E71 /* timeout.h in Headers */, 15C1C2D5198749BC00A46ACC /* LuaOpengl.h in Headers */, @@ -798,6 +807,7 @@ 15EFA642198B32BB000C57D3 /* tolua_fix.h in Headers */, 155C7E2119A71CCE00F08B25 /* LuaSkeletonAnimation.h in Headers */, 15415AB819A71A53004F1E71 /* io.h in Headers */, + 566F016219B5EB0F00FCA620 /* CustomGUIReader.h in Headers */, 15EFA62B198B3220000C57D3 /* LuaOpengl.h in Headers */, 15415AD419A71A53004F1E71 /* timeout.h in Headers */, 15EFA62C198B3220000C57D3 /* lua_cocos2dx_deprecated.h in Headers */, @@ -928,6 +938,7 @@ 155C7E1E19A71CC700F08B25 /* LuaSkeletonAnimation.cpp in Sources */, 15415AB519A71A53004F1E71 /* io.c in Sources */, 15C1C2CE1987498B00A46ACC /* LuaOpengl.cpp in Sources */, + 566F015F19B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */, 15415AC119A71A53004F1E71 /* options.c in Sources */, 155C7E0A19A71C8B00F08B25 /* lua_cocos2dx_network_manual.cpp in Sources */, 15415AD119A71A53004F1E71 /* timeout.c in Sources */, @@ -995,6 +1006,7 @@ 155C7E1F19A71CC800F08B25 /* LuaSkeletonAnimation.cpp in Sources */, 15415ACA19A71A53004F1E71 /* serial.c in Sources */, 155C7DEA19A71BDA00F08B25 /* lua_cocos2dx_3d_auto.cpp in Sources */, + 566F016019B5EB0F00FCA620 /* CustomGUIReader.cpp in Sources */, 155C7DF119A71C2300F08B25 /* lua_cocos2dx_studio_auto.cpp in Sources */, 155C7E0B19A71C8D00F08B25 /* lua_cocos2dx_network_manual.cpp in Sources */, 15415AAE19A71A53004F1E71 /* except.c in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index e84501f6f1..5dcc558ab4 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -56,6 +56,7 @@ + @@ -117,6 +118,7 @@ + diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index 11d3df728e..1f8c61573d 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -243,6 +243,9 @@ luasocket + + manual\cocostudio +
@@ -422,6 +425,9 @@ luasocket + + manual\cocostudio + diff --git a/cocos/ui/Android.mk b/cocos/ui/Android.mk index 221315e578..a76af6d91a 100644 --- a/cocos/ui/Android.mk +++ b/cocos/ui/Android.mk @@ -33,6 +33,9 @@ UIDeprecated.cpp \ UIScale9Sprite.cpp \ UIWebView.cpp \ UIWebViewImpl_android.cpp \ +UIEditBox/UIEditBox.cpp \ +UIEditBox/UIEditBoxImplAndroid.cpp \ + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../editor-support diff --git a/cocos/ui/CocosGUI.h b/cocos/ui/CocosGUI.h index 04ce980bd5..5d12b2186e 100644 --- a/cocos/ui/CocosGUI.h +++ b/cocos/ui/CocosGUI.h @@ -52,7 +52,7 @@ THE SOFTWARE. #include "ui/UIDeprecated.h" #include "ui/GUIExport.h" #include "ui/UIScale9Sprite.h" - +#include "ui/UIEditBox/UIEditBox.h" NS_CC_BEGIN namespace ui { diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp similarity index 75% rename from extensions/GUI/CCEditBox/CCEditBox.cpp rename to cocos/ui/UIEditBox/UIEditBox.cpp index bbb42be42d..6ef69b9e74 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -23,10 +23,12 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCEditBox.h" -#include "CCEditBoxImpl.h" +#include "UIEditBox.h" +#include "UIEditBoxImpl.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { static const float CHECK_EDITBOX_POSITION_INTERVAL = 0.1f; @@ -42,6 +44,7 @@ EditBox::EditBox(void) , _colPlaceHolder(Color3B::GRAY) , _maxLength(0) , _adjustHeight(0.0f) +, _backgroundSprite(nullptr) #if CC_ENABLE_SCRIPT_BINDING , _scriptEditBoxHandler(0) #endif @@ -57,26 +60,21 @@ EditBox::~EditBox(void) } -void EditBox::touchDownAction(Ref *sender, Control::EventType controlEvent) +void EditBox::touchDownAction(Ref *sender, TouchEventType controlEvent) { - _editBoxImpl->openKeyboard(); + if (controlEvent == Widget::TouchEventType::ENDED) { + _editBoxImpl->openKeyboard(); + } } -EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale9Sprite* pPressed9SpriteBg/* = nullptr*/, Scale9Sprite* pDisabled9SpriteBg/* = nullptr*/) +EditBox* EditBox::create(const Size& size, + const std::string& normalSprite, + TextureResType texType /*= TextureResType::LOCAL*/) { - EditBox* pRet = new (std::nothrow) EditBox(); + EditBox* pRet = new EditBox(); - if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, pNormal9SpriteBg)) + if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, normalSprite, texType)) { - if (pPressed9SpriteBg != nullptr) - { - pRet->setBackgroundSpriteForState(pPressed9SpriteBg, Control::State::HIGH_LIGHTED); - } - - if (pDisabled9SpriteBg != nullptr) - { - pRet->setBackgroundSpriteForState(pDisabled9SpriteBg, Control::State::DISABLED); - } pRet->autorelease(); } else @@ -86,19 +84,79 @@ EditBox* EditBox::create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale return pRet; } - -bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pPressed9SpriteBg) + + +EditBox* EditBox::create(const cocos2d::Size &size, cocos2d::ui::Scale9Sprite *normalSprite, ui::Scale9Sprite *pressedSprite, Scale9Sprite* disabledSprite) { - if (ControlButton::initWithBackgroundSprite(pPressed9SpriteBg)) + EditBox* pRet = new (std::nothrow) EditBox(); + + if (pRet != nullptr && pRet->initWithSizeAndBackgroundSprite(size, normalSprite)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + + return pRet; +} + +bool EditBox::initWithSizeAndBackgroundSprite(const cocos2d::Size &size, cocos2d::ui::Scale9Sprite *pNormal9SpriteBg) +{ + if (Widget::init()) { _editBoxImpl = __createSystemEditBox(this); _editBoxImpl->initWithSize(size); _editBoxImpl->setInputMode(EditBox::InputMode::ANY); - this->setZoomOnTouchDown(false); - this->setPreferredSize(size); + _backgroundSprite = pNormal9SpriteBg; + + this->setContentSize(size); this->setPosition(Vec2(0, 0)); - this->addTargetWithActionForControlEvent(this, cccontrol_selector(EditBox::touchDownAction), Control::EventType::TOUCH_UP_INSIDE); + + _backgroundSprite->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2)); + _backgroundSprite->setContentSize(size); + this->addProtectedChild(_backgroundSprite); + + this->setTouchEnabled(true); + + this->addTouchEventListener(CC_CALLBACK_2(EditBox::touchDownAction, this)); + + return true; + } + return false; +} + + +bool EditBox::initWithSizeAndBackgroundSprite(const Size& size, + const std::string& pNormal9SpriteBg, + TextureResType texType) +{ + if (Widget::init()) + { + _editBoxImpl = __createSystemEditBox(this); + _editBoxImpl->initWithSize(size); + _editBoxImpl->setInputMode(EditBox::InputMode::ANY); + + if (texType == Widget::TextureResType::LOCAL) + { + _backgroundSprite = Scale9Sprite::create(pNormal9SpriteBg); + } + else + { + _backgroundSprite = Scale9Sprite::createWithSpriteFrameName(pNormal9SpriteBg); + } + this->setContentSize(size); + this->setPosition(Vec2(0, 0)); + + _backgroundSprite->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2)); + _backgroundSprite->setContentSize(size); + this->addProtectedChild(_backgroundSprite); + + this->setTouchEnabled(true); + + this->addTouchEventListener(CC_CALLBACK_2(EditBox::touchDownAction, this)); return true; } @@ -210,7 +268,7 @@ void EditBox::setPlaceholderFontSize(int fontSize) _placeholderFontSize = fontSize; if (_editBoxImpl != nullptr && _placeholderFontName.length() > 0) { - _editBoxImpl->setPlaceholderFont(_placeholderFontName.c_str(), _fontSize); + _editBoxImpl->setPlaceholderFont(_placeholderFontName.c_str(), fontSize); } } @@ -284,7 +342,7 @@ void EditBox::setReturnType(EditBox::KeyboardReturnType returnType) /* override function */ void EditBox::setPosition(const Vec2& pos) { - ControlButton::setPosition(pos); + Widget::setPosition(pos); if (_editBoxImpl != nullptr) { _editBoxImpl->setPosition(pos); @@ -293,7 +351,7 @@ void EditBox::setPosition(const Vec2& pos) void EditBox::setVisible(bool visible) { - ControlButton::setVisible(visible); + Widget::setVisible(visible); if (_editBoxImpl != nullptr) { _editBoxImpl->setVisible(visible); @@ -302,16 +360,25 @@ void EditBox::setVisible(bool visible) void EditBox::setContentSize(const Size& size) { - ControlButton::setContentSize(size); + Widget::setContentSize(size); if (_editBoxImpl != nullptr) { _editBoxImpl->setContentSize(size); } } + +void EditBox::adaptRenderers() +{ + if (_contentSizeDirty) + { + _backgroundSprite->setContentSize(_contentSize); + _backgroundSprite->setPosition(Vec2(_contentSize.width/2, _contentSize.height/2)); + } +} void EditBox::setAnchorPoint(const Vec2& anchorPoint) { - ControlButton::setAnchorPoint(anchorPoint); + Widget::setAnchorPoint(anchorPoint); if (_editBoxImpl != nullptr) { _editBoxImpl->setAnchorPoint(anchorPoint); @@ -320,7 +387,7 @@ void EditBox::setAnchorPoint(const Vec2& anchorPoint) void EditBox::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { - ControlButton::visit(renderer, parentTransform, parentFlags); + Widget::visit(renderer, parentTransform, parentFlags); if (_editBoxImpl != nullptr) { _editBoxImpl->visit(); @@ -337,7 +404,7 @@ void EditBox::onEnter(void) } #endif - ControlButton::onEnter(); + Widget::onEnter(); if (_editBoxImpl != nullptr) { _editBoxImpl->onEnter(); @@ -357,7 +424,7 @@ void EditBox::updatePosition(float dt) void EditBox::onExit(void) { - ControlButton::onExit(); + Widget::onExit(); if (_editBoxImpl != nullptr) { // remove system edit control @@ -432,4 +499,6 @@ void EditBox::unregisterScriptEditBoxHandler(void) } #endif -NS_CC_EXT_END +} + +NS_CC_END diff --git a/cocos/ui/UIEditBox/UIEditBox.h b/cocos/ui/UIEditBox/UIEditBox.h new file mode 100644 index 0000000000..72af4a2627 --- /dev/null +++ b/cocos/ui/UIEditBox/UIEditBox.h @@ -0,0 +1,474 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __UIEDITTEXT_H__ +#define __UIEDITTEXT_H__ + +#include "base/CCIMEDelegate.h" +#include "ui/GUIDefine.h" +#include "ui/UIButton.h" +#include "ui/UIScale9Sprite.h" + +NS_CC_BEGIN + +namespace ui { + + class EditBox; + class EditBoxImpl; + + + class CC_GUI_DLL EditBoxDelegate + { + public: + /** + * @js NA + * @lua NA + */ + virtual ~EditBoxDelegate() {}; + + /** + * This method is called when an edit box gains focus after keyboard is shown. + * @param editBox The edit box object that generated the event. + * @js NA + * @lua NA + */ + virtual void editBoxEditingDidBegin(EditBox* editBox) {}; + + + /** + * This method is called when an edit box loses focus after keyboard is hidden. + * @param editBox The edit box object that generated the event. + * @js NA + * @lua NA + */ + virtual void editBoxEditingDidEnd(EditBox* editBox) {}; + + /** + * This method is called when the edit box text was changed. + * @param editBox The edit box object that generated the event. + * @param text The new text. + * @js NA + * @lua NA + */ + virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) {}; + + /** + * This method is called when the return button was pressed or the outside area of keyboard was touched. + * @param editBox The edit box object that generated the event. + * @js NA + * @lua NA + */ + virtual void editBoxReturn(EditBox* editBox) = 0; + + }; + + /** + * \brief Class for edit box. + * + * You can use this widget to gather small amounts of text from the user. + * + */ + + class CC_GUI_DLL EditBox + : public Widget + , public IMEDelegate + { + public: + enum class KeyboardReturnType + { + DEFAULT, + DONE, + SEND, + SEARCH, + GO + }; + + /** + * \brief The EditBox::InputMode defines the type of text that the user is allowed + * to enter. + */ + enum class InputMode + { + /** + * The user is allowed to enter any text, including line breaks. + */ + ANY, + + /** + * The user is allowed to enter an e-mail address. + */ + EMAIL_ADDRESS, + + /** + * The user is allowed to enter an integer value. + */ + NUMERIC, + + /** + * The user is allowed to enter a phone number. + */ + PHONE_NUMBER, + + /** + * The user is allowed to enter a URL. + */ + URL, + + /** + * The user is allowed to enter a real number value. + * This extends kEditBoxInputModeNumeric by allowing a decimal point. + */ + DECIMAL, + + /** + * The user is allowed to enter any text, except for line breaks. + */ + SINGLE_LINE, + }; + + /** + * \brief The EditBox::InputFlag defines how the input text is displayed/formatted. + */ + enum class InputFlag + { + /** + * Indicates that the text entered is confidential data that should be + * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. + */ + PASSWORD, + + /** + * Indicates that the text entered is sensitive data that the + * implementation must never store into a dictionary or table for use + * in predictive, auto-completing, or other accelerated input schemes. + * A credit card number is an example of sensitive data. + */ + SENSITIVE, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each word should be capitalized. + */ + INITIAL_CAPS_WORD, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each sentence should be capitalized. + */ + INITIAL_CAPS_SENTENCE, + + /** + * Capitalize all characters automatically. + */ + INTIAL_CAPS_ALL_CHARACTERS, + }; + + /** + * create a edit box with size. + * @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again. + */ + static EditBox* create(const Size& size, + Scale9Sprite* normalSprite, + Scale9Sprite* pressedSprite = nullptr, + Scale9Sprite* disabledSprite = nullptr); + + + /** + * create a edit box with size. + * @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again. + */ + static EditBox* create(const Size& size, + const std::string& pNormal9SpriteBg, + TextureResType texType = TextureResType::LOCAL); + + /** + * Constructor. + * @js ctor + */ + EditBox(void); + + /** + * Destructor. + * @js NA + * @lua NA + */ + virtual ~EditBox(void); + + /** + * Init edit box with specified size. This method should be invoked right after constructor. + * @param size The size of edit box. + */ + bool initWithSizeAndBackgroundSprite(const Size& size, + const std::string& pNormal9SpriteBg, + TextureResType texType = TextureResType::LOCAL); + + bool initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pNormal9SpriteBg); + + /** + * Gets/Sets the delegate for edit box. + * @lua NA + */ + void setDelegate(EditBoxDelegate* pDelegate); + /** + * @js NA + * @lua NA + */ + EditBoxDelegate* getDelegate(); + +#if CC_ENABLE_SCRIPT_BINDING + /** + * Registers a script function that will be called for EditBox events. + * + * This handler will be removed automatically after onExit() called. + * @code + * -- lua sample + * local function editboxEventHandler(eventType) + * if eventType == "began" then + * -- triggered when an edit box gains focus after keyboard is shown + * elseif eventType == "ended" then + * -- triggered when an edit box loses focus after keyboard is hidden. + * elseif eventType == "changed" then + * -- triggered when the edit box text was changed. + * elseif eventType == "return" then + * -- triggered when the return button was pressed or the outside area of keyboard was touched. + * end + * end + * + * local editbox = EditBox:create(Size(...), Scale9Sprite:create(...)) + * editbox = registerScriptEditBoxHandler(editboxEventHandler) + * @endcode + * + * @param handler A number that indicates a lua function. + * @js NA + * @lua NA + */ + void registerScriptEditBoxHandler(int handler); + + /** + * Unregisters a script function that will be called for EditBox events. + * @js NA + * @lua NA + */ + void unregisterScriptEditBoxHandler(void); + /** + * get a script Handler + * @js NA + * @lua NA + */ + int getScriptEditBoxHandler(void){ return _scriptEditBoxHandler ;} + +#endif // #if CC_ENABLE_SCRIPT_BINDING + + /** + * Set the text entered in the edit box. + * @param pText The given text. + */ + void setText(const char* pText); + + /** + * Get the text entered in the edit box. + * @return The text entered in the edit box. + */ + const char* getText(void); + + /** + * Set the font. + * @param pFontName The font name. + * @param fontSize The font size. + */ + void setFont(const char* pFontName, int fontSize); + + /** + * Set the font name. + * @param pFontName The font name. + */ + void setFontName(const char* pFontName); + + /** + * Set the font size. + * @param fontSize The font size. + */ + void setFontSize(int fontSize); + + /** + * Set the font color of the widget's text. + */ + void setFontColor(const Color3B& color); + + /** + * Set the placeholder's font. + * @param pFontName The font name. + * @param fontSize The font size. + */ + void setPlaceholderFont(const char* pFontName, int fontSize); + + /** + * Set the placeholder's font name. + * @param pFontName The font name. + */ + void setPlaceholderFontName(const char* pFontName); + + /** + * Set the placeholder's font size. + * @param fontSize The font size. + */ + void setPlaceholderFontSize(int fontSize); + + /** + * Set the font color of the placeholder text when the edit box is empty. + * Not supported on IOS. + */ + void setPlaceholderFontColor(const Color3B& color); + + /** + * Set a text in the edit box that acts as a placeholder when an + * edit box is empty. + * @param pText The given text. + */ + void setPlaceHolder(const char* pText); + + /** + * Get a text in the edit box that acts as a placeholder when an + * edit box is empty. + */ + const char* getPlaceHolder(void); + + /** + * Set the input mode of the edit box. + * @param inputMode One of the EditBox::InputMode constants. + */ + void setInputMode(InputMode inputMode); + + /** + * Sets the maximum input length of the edit box. + * Setting this value enables multiline input mode by default. + * Available on Android, iOS and Windows Phone. + * + * @param maxLength The maximum length. + */ + void setMaxLength(int maxLength); + + /** + * Gets the maximum input length of the edit box. + * + * @return Maximum input length. + */ + int getMaxLength(); + + /** + * Set the input flags that are to be applied to the edit box. + * @param inputFlag One of the EditBox::InputFlag constants. + */ + void setInputFlag(InputFlag inputFlag); + + /** + * Set the return type that are to be applied to the edit box. + * @param returnType One of the EditBox::KeyboardReturnType constants. + */ + void setReturnType(EditBox::KeyboardReturnType returnType); + + /* override functions */ + virtual void setPosition(const Vec2& pos) override; + virtual void setVisible(bool visible) override; + virtual void setContentSize(const Size& size) override; + virtual void setAnchorPoint(const Vec2& anchorPoint) override; + /** + * @js NA + * @lua NA + */ + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + /** + * @js NA + * @lua NA + */ + virtual void onEnter(void) override; + /** + * @js NA + * @lua NA + */ + virtual void onExit(void) override; + /** + * @js NA + * @lua NA + */ + virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) override; + /** + * @js NA + * @lua NA + */ + virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) override; + /** + * @js NA + * @lua NA + */ + virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) override; + /** + * @js NA + * @lua NA + */ + virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override; + + /* callback funtions + * @js NA + * @lua NA + */ + void touchDownAction(Ref *sender, TouchEventType controlEvent); + + protected: + virtual void adaptRenderers(); + + void updatePosition(float dt); + EditBoxImpl* _editBoxImpl; + EditBoxDelegate* _delegate; + + InputMode _editBoxInputMode; + InputFlag _editBoxInputFlag; + EditBox::KeyboardReturnType _keyboardReturnType; + + Scale9Sprite *_backgroundSprite; + std::string _text; + std::string _placeHolder; + + std::string _fontName; + std::string _placeholderFontName; + + int _fontSize; + int _placeholderFontSize; + + Color3B _colText; + Color3B _colPlaceHolder; + + int _maxLength; + float _adjustHeight; +#if CC_ENABLE_SCRIPT_BINDING + int _scriptEditBoxHandler; +#endif + }; +} + +NS_CC_END + +#endif /* __UIEDITTEXT_H__ */ + diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl.h b/cocos/ui/UIEditBox/UIEditBoxImpl.h new file mode 100644 index 0000000000..8413b62bae --- /dev/null +++ b/cocos/ui/UIEditBox/UIEditBoxImpl.h @@ -0,0 +1,103 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __UIEditBoxIMPL_H__ +#define __UIEditBoxIMPL_H__ + +#include "UIEditBox.h" + + +namespace cocos2d { + namespace ui{ + + class CC_GUI_DLL EditBoxImpl + { + public: + /** + * @js NA + */ + EditBoxImpl(EditBox* pEditBox) : _delegate(nullptr),_editBox(pEditBox) {} + /** + * @js NA + * @lua NA + */ + virtual ~EditBoxImpl() {} + + virtual bool initWithSize(const Size& size) = 0; + virtual void setFont(const char* pFontName, int fontSize) = 0; + virtual void setFontColor(const Color3B& color) = 0; + virtual void setPlaceholderFont(const char* pFontName, int fontSize) = 0; + virtual void setPlaceholderFontColor(const Color3B& color) = 0; + virtual void setInputMode(EditBox::InputMode inputMode) = 0; + virtual void setInputFlag(EditBox::InputFlag inputFlag) = 0; + virtual void setMaxLength(int maxLength) = 0; + virtual int getMaxLength() = 0; + virtual void setReturnType(EditBox::KeyboardReturnType returnType) = 0; + virtual bool isEditing() = 0; + + virtual void setText(const char* pText) = 0; + virtual const char* getText(void) = 0; + virtual void setPlaceHolder(const char* pText) = 0; + virtual void doAnimationWhenKeyboardMove(float duration, float distance) = 0; + + virtual void openKeyboard() = 0; + virtual void closeKeyboard() = 0; + + virtual void setPosition(const Vec2& pos) = 0; + virtual void setVisible(bool visible) = 0; + virtual void setContentSize(const Size& size) = 0; + virtual void setAnchorPoint(const Vec2& anchorPoint) = 0; + + /** + * check the editbox's position, update it when needed + */ + virtual void updatePosition(float dt){}; + /** + * @js NA + * @lua NA + */ + virtual void visit(void) = 0; + /** + * @js NA + * @lua NA + */ + virtual void onEnter(void) = 0; + + + void setDelegate(EditBoxDelegate* pDelegate) { _delegate = pDelegate; }; + EditBoxDelegate* getDelegate() { return _delegate; }; + EditBox* getEditBox() { return _editBox; }; + protected: + EditBoxDelegate* _delegate; + EditBox* _editBox; + }; + + // This method must be implemented at each subclass of EditBoxImpl. + extern EditBoxImpl* __createSystemEditBox(EditBox* pEditBox); + + } +} + +#endif /* __UIEditBoxIMPL_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/cocos/ui/UIEditBox/UIEditBoxImplAndroid.cpp similarity index 98% rename from extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp rename to cocos/ui/UIEditBox/UIEditBoxImplAndroid.cpp index b8863a4fa7..338b8defd3 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImplAndroid.cpp @@ -23,16 +23,18 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCEditBoxImplAndroid.h" +#include "UIEditBoxImplAndroid.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) -#include "CCEditBox.h" +#include "UIEditBox.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { @@ -309,7 +311,9 @@ void EditBoxImplAndroid::closeKeyboard() } -NS_CC_EXT_END +} + +NS_CC_END #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h b/cocos/ui/UIEditBox/UIEditBoxImplAndroid.h similarity index 93% rename from extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h rename to cocos/ui/UIEditBox/UIEditBoxImplAndroid.h index 8f4d6a1e95..2b38934752 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h +++ b/cocos/ui/UIEditBox/UIEditBoxImplAndroid.h @@ -23,17 +23,18 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCEDITBOXIMPLANDROID_H__ -#define __CCEDITBOXIMPLANDROID_H__ +#ifndef __UIEDITBOXIMPLANDROID_H__ +#define __UIEDITBOXIMPLANDROID_H__ #include "cocos2d.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) -#include "extensions/ExtensionMacros.h" -#include "CCEditBoxImpl.h" +#include "UIEditBoxImpl.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { class EditBox; @@ -78,7 +79,7 @@ public: * @js NA * @lua NA */ - virtual void onEnter(void); + virtual void onEnter(void); virtual void doAnimationWhenKeyboardMove(float duration, float distance); virtual void openKeyboard(); virtual void closeKeyboard(); @@ -101,9 +102,11 @@ private: }; -NS_CC_EXT_END +} + +NS_CC_END #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) */ -#endif /* __CCEDITBOXIMPLANDROID_H__ */ +#endif /* __UIEDITBOXIMPLANDROID_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h b/cocos/ui/UIEditBox/UIEditBoxImplIOS.h similarity index 91% rename from extensions/GUI/CCEditBox/CCEditBoxImplIOS.h rename to cocos/ui/UIEditBox/UIEditBoxImplIOS.h index 0e666ee6ed..b78ce96da6 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h +++ b/cocos/ui/UIEditBox/UIEditBoxImplIOS.h @@ -23,29 +23,29 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCEditBoxIMPLIOS_H__ -#define __CCEditBoxIMPLIOS_H__ +#ifndef __UIEditBoxIMPLIOS_H__ +#define __UIEditBoxIMPLIOS_H__ #include "cocos2d.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #include "extensions/ExtensionMacros.h" -#include "CCEditBoxImpl.h" +#include "UIEditBoxImpl.h" #import #import -@interface CCCustomUITextField : UITextField +@interface UICustomUITextField : UITextField { } @end -@interface CCEditBoxImplIOS_objc : NSObject +@interface UIEditBoxImplIOS_objc : NSObject { - CCCustomUITextField* textField_; + UICustomUITextField* textField_; void* editBox_; BOOL editState_; } @@ -64,7 +64,9 @@ @end -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { class EditBox; @@ -128,16 +130,18 @@ private: Size _contentSize; Vec2 _position; Vec2 _anchorPoint; - CCEditBoxImplIOS_objc* _systemControl; + UIEditBoxImplIOS_objc* _systemControl; int _maxTextLength; bool _inRetinaMode; }; -NS_CC_EXT_END +} + +NS_CC_END #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) */ -#endif /* __CCEditBoxIMPLIOS_H__ */ +#endif /* __UIEditBoxIMPLIOS_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm similarity index 95% rename from extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm rename to cocos/ui/UIEditBox/UIEditBoxImplIOS.mm index 0c0be51a6d..a2456ed125 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImplIOS.mm @@ -22,20 +22,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCEditBoxImplIOS.h" +#include "UIEditBoxImplIOS.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #define kLabelZOrder 9999 -#include "CCEditBox.h" +#include "UIEditBox.h" #import "CCEAGLView.h" -#define getEditBoxImplIOS() ((cocos2d::extension::EditBoxImplIOS*)editBox_) +#define getEditBoxImplIOS() ((cocos2d::ui::EditBoxImplIOS*)editBox_) static const int CC_EDIT_BOX_PADDING = 5; -@implementation CCCustomUITextField +@implementation UICustomUITextField - (CGRect)textRectForBounds:(CGRect)bounds { auto glview = cocos2d::Director::getInstance()->getOpenGLView(); @@ -50,7 +50,7 @@ static const int CC_EDIT_BOX_PADDING = 5; @end -@implementation CCEditBoxImplIOS_objc +@implementation UIEditBoxImplIOS_objc @synthesize textField = textField_; @synthesize editState = editState_; @@ -71,7 +71,7 @@ static const int CC_EDIT_BOX_PADDING = 5; if (self) { editState_ = NO; - self.textField = [[[CCCustomUITextField alloc] initWithFrame: frameRect] autorelease]; + self.textField = [[[UICustomUITextField alloc] initWithFrame: frameRect] autorelease]; [textField_ setTextColor:[UIColor whiteColor]]; //TODO: need to delete hard code here. @@ -159,14 +159,14 @@ static const int CC_EDIT_BOX_PADDING = 5; { [self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f]; } - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxEditingDidBegin(getEditBoxImplIOS()->getEditBox()); } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox); @@ -183,7 +183,7 @@ static const int CC_EDIT_BOX_PADDING = 5; editState_ = NO; getEditBoxImplIOS()->refreshInactiveText(); - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxEditingDidEnd(getEditBoxImplIOS()->getEditBox()); @@ -191,7 +191,7 @@ static const int CC_EDIT_BOX_PADDING = 5; } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox); @@ -240,14 +240,14 @@ static const int CC_EDIT_BOX_PADDING = 5; - (void) textChanged { // NSLog(@"text is %@", self.textField.text); - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxTextChanged(getEditBoxImplIOS()->getEditBox(), getEditBoxImplIOS()->getText()); } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplIOS()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox); @@ -260,7 +260,9 @@ static const int CC_EDIT_BOX_PADDING = 5; @end -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { @@ -307,7 +309,7 @@ bool EditBoxImplIOS::initWithSize(const Size& size) rect.size.height /= 2.0f; } - _systemControl = [[CCEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this]; + _systemControl = [[UIEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this]; if (!_systemControl) break; initInactiveLabels(size); @@ -393,8 +395,6 @@ void EditBoxImplIOS::setFont(const char* pFontName, int fontSize) _label->setSystemFontName(pFontName); _label->setSystemFontSize(fontSize); - _labelPlaceHolder->setSystemFontName(pFontName); - _labelPlaceHolder->setSystemFontSize(fontSize); } void EditBoxImplIOS::setFontColor(const Color3B& color) @@ -405,7 +405,8 @@ void EditBoxImplIOS::setFontColor(const Color3B& color) void EditBoxImplIOS::setPlaceholderFont(const char* pFontName, int fontSize) { - // TODO: need to be implemented. + _labelPlaceHolder->setSystemFontName(pFontName); + _labelPlaceHolder->setSystemFontSize(fontSize); } void EditBoxImplIOS::setPlaceholderFontColor(const Color3B& color) @@ -668,7 +669,9 @@ void EditBoxImplIOS::onEndEditing() } } -NS_CC_EXT_END +} + +NS_CC_END #endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h b/cocos/ui/UIEditBox/UIEditBoxImplMac.h similarity index 93% rename from extensions/GUI/CCEditBox/CCEditBoxImplMac.h rename to cocos/ui/UIEditBox/UIEditBoxImplMac.h index 34085e8278..ffb53d29ef 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.h +++ b/cocos/ui/UIEditBox/UIEditBoxImplMac.h @@ -23,8 +23,8 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCEditBoxIMPLMAC_H__ -#define __CCEditBoxIMPLMAC_H__ +#ifndef __UIEditBoxIMPLMAC_H__ +#define __UIEditBoxIMPLMAC_H__ #include "cocos2d.h" @@ -33,11 +33,10 @@ #import #import -#include "extensions/ExtensionMacros.h" -#include "CCEditBoxImpl.h" +#include "UIEditBoxImpl.h" -@interface CCEditBoxImplMac : NSObject +@interface UIEditBoxImplMac : NSObject { NSTextField* textField_; NSSecureTextField* secureTextField_; @@ -62,8 +61,11 @@ @end -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { + class EditBox; class EditBoxImplMac : public EditBoxImpl @@ -120,13 +122,15 @@ private: Vec2 _anchorPoint; int _maxTextLength; bool _inRetinaMode; - CCEditBoxImplMac* _sysEdit; + UIEditBoxImplMac* _sysEdit; }; -NS_CC_EXT_END +} + +NS_CC_END #endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) -#endif /* __CCEditBoxIMPLMAC_H__ */ +#endif /* __UIEditBoxIMPLMAC_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm b/cocos/ui/UIEditBox/UIEditBoxImplMac.mm similarity index 95% rename from extensions/GUI/CCEditBox/CCEditBoxImplMac.mm rename to cocos/ui/UIEditBox/UIEditBoxImplMac.mm index 3668a7f134..87bf88e615 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplMac.mm +++ b/cocos/ui/UIEditBox/UIEditBoxImplMac.mm @@ -23,19 +23,19 @@ THE SOFTWARE. ****************************************************************************/ -#include "CCEditBoxImplMac.h" +#include "UIEditBoxImplMac.h" #include "base/CCDirector.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) -#include "CCEditBox.h" +#include "UIEditBox.h" -#define getEditBoxImplMac() ((cocos2d::extension::EditBoxImplMac*)editBox_) +#define getEditBoxImplMac() ((cocos2d::ui::EditBoxImplMac*)editBox_) -@implementation CCEditBoxImplMac +@implementation UIEditBoxImplMac @synthesize textField = textField_; @synthesize secureTextField = secureTextField_; @@ -163,14 +163,14 @@ - (void)controlTextDidBeginEditing:(NSNotification *)notification { editState_ = YES; - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxEditingDidBegin(getEditBoxImplMac()->getEditBox()); } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox); @@ -183,7 +183,7 @@ - (void)controlTextDidEndEditing:(NSNotification *)notification { editState_ = NO; - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxEditingDidEnd(getEditBoxImplMac()->getEditBox()); @@ -191,7 +191,7 @@ } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "ended",pEditBox); @@ -233,14 +233,14 @@ */ - (void)controlTextDidChange:(NSNotification *)notification { - cocos2d::extension::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); + cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplMac()->getDelegate(); if (pDelegate != NULL) { pDelegate->editBoxTextChanged(getEditBoxImplMac()->getEditBox(), getEditBoxImplMac()->getText()); } #if CC_ENABLE_SCRIPT_BINDING - cocos2d::extension::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); + cocos2d::ui::EditBox* pEditBox= getEditBoxImplMac()->getEditBox(); if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler()) { cocos2d::CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "changed",pEditBox); @@ -252,7 +252,9 @@ @end -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { @@ -292,7 +294,7 @@ bool EditBoxImplMac::initWithSize(const Size& size) rect.size.height /= 2.0f; } - _sysEdit = [[CCEditBoxImplMac alloc] initWithFrame:rect editBox:this]; + _sysEdit = [[UIEditBoxImplMac alloc] initWithFrame:rect editBox:this]; if (!_sysEdit) return false; @@ -514,7 +516,9 @@ void EditBoxImplMac::onEnter(void) adjustTextFieldPosition(); } -NS_CC_EXT_END +} + +NS_CC_END #endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp b/cocos/ui/UIEditBox/UIEditBoxImplNone.cpp similarity index 83% rename from extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp rename to cocos/ui/UIEditBox/UIEditBoxImplNone.cpp index 5cac865d3d..7e3899672c 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImplNone.cpp @@ -1,14 +1,18 @@ -#include "CCEditBox.h" +#include "UIEditBox.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID ) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS ) && (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) && (CC_TARGET_PLATFORM != CC_PLATFORM_TIZEN) -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { return NULL; } -NS_CC_EXT_END +} + +NS_CC_END #endif /* #if (..) */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/cocos/ui/UIEditBox/UIEditBoxImplWin.cpp similarity index 98% rename from extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp rename to cocos/ui/UIEditBox/UIEditBoxImplWin.cpp index 0056d54faf..af5e9f8213 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImplWin.cpp @@ -22,14 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCEditBoxImplWin.h" +#include "UIEditBoxImplWin.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -#include "CCEditBox.h" +#include "UIEditBox.h" #include "proj.win32/Win32InputBox.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { @@ -293,6 +295,8 @@ void EditBoxImplWin::onEnter(void) } -NS_CC_EXT_END +} + +NS_CC_END #endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h b/cocos/ui/UIEditBox/UIEditBoxImplWin.h similarity index 92% rename from extensions/GUI/CCEditBox/CCEditBoxImplWin.h rename to cocos/ui/UIEditBox/UIEditBoxImplWin.h index 4d04fb6cce..b4c9cf9f47 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h +++ b/cocos/ui/UIEditBox/UIEditBoxImplWin.h @@ -23,22 +23,22 @@ THE SOFTWARE. ****************************************************************************/ -#ifndef __CCEditBoxIMPLWIN_H__ -#define __CCEditBoxIMPLWIN_H__ +#ifndef __UIEditBoxIMPLWIN_H__ +#define __UIEditBoxIMPLWIN_H__ #include "cocos2d.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -#include "extensions/ExtensionMacros.h" -#include "CCEditBoxImpl.h" -#include "extensions/ExtensionExport.h" +#include "UIEditBoxImpl.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { class EditBox; -class CC_EX_DLL EditBoxImplWin : public EditBoxImpl +class CC_GUI_DLL EditBoxImplWin : public EditBoxImpl { public: /** @@ -108,9 +108,11 @@ private: }; -NS_CC_EXT_END +} + +NS_CC_END #endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ -#endif /* __CCEditBoxIMPLWIN_H__ */ +#endif /* __UIEditBoxIMPLWIN_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp b/cocos/ui/UIEditBox/UIEditBoxImplWp8.cpp similarity index 80% rename from extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp rename to cocos/ui/UIEditBox/UIEditBoxImplWp8.cpp index 245149d164..b8a2f23050 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImplWp8.cpp @@ -22,20 +22,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCEditBoxImplWp8.h" -#include "CCEditBox.h" +#include "UIEditBoxImplWp8.h" +#include "UIEditBox.h" #include "CCGLViewImpl.h" #include "base/CCScriptSupport.h" #include "base/ccUTF8.h" -NS_CC_EXT_BEGIN +NS_CC_BEGIN + +namespace ui { EditBoxImpl* __createSystemEditBox(EditBox* pEditBox) { - return new CCEditBoxImplWp8(pEditBox); + return new UIEditBoxImplWp8(pEditBox); } -CCEditBoxImplWp8::CCEditBoxImplWp8( EditBox* pEditText ) +UIEditBoxImplWp8::UIEditBoxImplWp8( EditBox* pEditText ) : EditBoxImpl(pEditText) , m_pLabel(NULL) , m_pLabelPlaceHolder(NULL) @@ -49,12 +51,12 @@ CCEditBoxImplWp8::CCEditBoxImplWp8( EditBox* pEditText ) } -CCEditBoxImplWp8::~CCEditBoxImplWp8() +UIEditBoxImplWp8::~UIEditBoxImplWp8() { } -void CCEditBoxImplWp8::openKeyboard() +void UIEditBoxImplWp8::openKeyboard() { if (_delegate != NULL) { @@ -92,7 +94,7 @@ void CCEditBoxImplWp8::openKeyboard() GLViewImpl::sharedOpenGLView()->OpenXamlEditBox(stringToPlatformString(placeHolder), stringToPlatformString(getText()), m_nMaxLength, (int)m_eEditBoxInputMode, (int)m_eEditBoxInputFlag, receiveHandler); } -bool CCEditBoxImplWp8::initWithSize( const Size& size ) +bool UIEditBoxImplWp8::initWithSize( const Size& size ) { //! int fontSize = getFontSizeAccordingHeightJni(size.height-12); m_pLabel = Label::createWithSystemFont("", "", size.height-12); @@ -114,7 +116,7 @@ bool CCEditBoxImplWp8::initWithSize( const Size& size ) return true; } -void CCEditBoxImplWp8::setFont( const char* pFontName, int fontSize ) +void UIEditBoxImplWp8::setFont( const char* pFontName, int fontSize ) { if(m_pLabel != NULL) { m_pLabel->setSystemFontName(pFontName); @@ -127,13 +129,13 @@ void CCEditBoxImplWp8::setFont( const char* pFontName, int fontSize ) } } -void CCEditBoxImplWp8::setFontColor( const Color3B& color ) +void UIEditBoxImplWp8::setFontColor( const Color3B& color ) { m_colText = color; m_pLabel->setColor(color); } -void CCEditBoxImplWp8::setPlaceholderFont( const char* pFontName, int fontSize ) +void UIEditBoxImplWp8::setPlaceholderFont( const char* pFontName, int fontSize ) { if(m_pLabelPlaceHolder != NULL) { m_pLabelPlaceHolder->setSystemFontName(pFontName); @@ -141,43 +143,43 @@ void CCEditBoxImplWp8::setPlaceholderFont( const char* pFontName, int fontSize ) } } -void CCEditBoxImplWp8::setPlaceholderFontColor( const Color3B& color ) +void UIEditBoxImplWp8::setPlaceholderFontColor( const Color3B& color ) { m_colPlaceHolder = color; m_pLabelPlaceHolder->setColor(color); } -void CCEditBoxImplWp8::setInputMode( EditBox::InputMode inputMode ) +void UIEditBoxImplWp8::setInputMode( EditBox::InputMode inputMode ) { m_eEditBoxInputMode = inputMode; } -void CCEditBoxImplWp8::setInputFlag(EditBox::InputFlag inputFlag ) +void UIEditBoxImplWp8::setInputFlag(EditBox::InputFlag inputFlag ) { m_eEditBoxInputFlag = inputFlag; } -void CCEditBoxImplWp8::setMaxLength( int maxLength ) +void UIEditBoxImplWp8::setMaxLength( int maxLength ) { m_nMaxLength = maxLength; } -int CCEditBoxImplWp8::getMaxLength() +int UIEditBoxImplWp8::getMaxLength() { return m_nMaxLength; } -void CCEditBoxImplWp8::setReturnType( EditBox::KeyboardReturnType returnType ) +void UIEditBoxImplWp8::setReturnType( EditBox::KeyboardReturnType returnType ) { m_eKeyboardReturnType = returnType; } -bool CCEditBoxImplWp8::isEditing() +bool UIEditBoxImplWp8::isEditing() { return false; } -void CCEditBoxImplWp8::setText( const char* pText ) +void UIEditBoxImplWp8::setText( const char* pText ) { if (pText != NULL) { @@ -215,12 +217,12 @@ void CCEditBoxImplWp8::setText( const char* pText ) } } -const char* CCEditBoxImplWp8::getText( void ) +const char* UIEditBoxImplWp8::getText( void ) { return m_strText.c_str(); } -void CCEditBoxImplWp8::setPlaceHolder( const char* pText ) +void UIEditBoxImplWp8::setPlaceHolder( const char* pText ) { if (pText != NULL) { @@ -234,47 +236,47 @@ void CCEditBoxImplWp8::setPlaceHolder( const char* pText ) } } -void CCEditBoxImplWp8::setPosition( const Vec2& pos ) +void UIEditBoxImplWp8::setPosition( const Vec2& pos ) { } -void CCEditBoxImplWp8::setVisible( bool visible ) +void UIEditBoxImplWp8::setVisible( bool visible ) { } -void CCEditBoxImplWp8::setContentSize( const Size& size ) +void UIEditBoxImplWp8::setContentSize( const Size& size ) { } -void CCEditBoxImplWp8::setAnchorPoint( const Vec2& anchorPoint ) +void UIEditBoxImplWp8::setAnchorPoint( const Vec2& anchorPoint ) { } -void CCEditBoxImplWp8::visit( void ) +void UIEditBoxImplWp8::visit( void ) { } -void CCEditBoxImplWp8::doAnimationWhenKeyboardMove( float duration, float distance ) +void UIEditBoxImplWp8::doAnimationWhenKeyboardMove( float duration, float distance ) { } -void CCEditBoxImplWp8::closeKeyboard() +void UIEditBoxImplWp8::closeKeyboard() { } -void CCEditBoxImplWp8::onEnter( void ) +void UIEditBoxImplWp8::onEnter( void ) { } -Platform::String^ CCEditBoxImplWp8::stringToPlatformString( std::string strSrc ) +Platform::String^ UIEditBoxImplWp8::stringToPlatformString( std::string strSrc ) { // to wide char int nStrLen = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0); @@ -286,7 +288,7 @@ Platform::String^ CCEditBoxImplWp8::stringToPlatformString( std::string strSrc ) return strDst; } -std::string CCEditBoxImplWp8::PlatformStringTostring( Platform::String^ strSrc ) +std::string UIEditBoxImplWp8::PlatformStringTostring( Platform::String^ strSrc ) { const wchar_t* pWStr = strSrc->Data(); int nStrLen = WideCharToMultiByte(CP_UTF8, 0, pWStr, -1, NULL, 0, NULL, NULL); @@ -300,4 +302,6 @@ std::string CCEditBoxImplWp8::PlatformStringTostring( Platform::String^ strSrc ) return strDst; } -NS_CC_EXT_END +} + +NS_CC_END diff --git a/cocos/ui/UIEditBox/UIEditBoxImplWp8.h b/cocos/ui/UIEditBox/UIEditBoxImplWp8.h new file mode 100644 index 0000000000..09d78167cd --- /dev/null +++ b/cocos/ui/UIEditBox/UIEditBoxImplWp8.h @@ -0,0 +1,88 @@ +/**************************************************************************** +Copyright (c) 2014 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __UIEditBoxIMPLWP8_H__ +#define __UIEditBoxIMPLWP8_H__ + +#include "UIEditBoxImpl.h" + +NS_CC_BEGIN + +namespace ui { + class EditBox; + + class CC_GUI_DLL UIEditBoxImplWp8 : public EditBoxImpl + { + public: + UIEditBoxImplWp8(EditBox* pEditText); + virtual ~UIEditBoxImplWp8(); + + virtual bool initWithSize(const Size& size); + virtual void setFont(const char* pFontName, int fontSize); + virtual void setFontColor(const Color3B& color); + virtual void setPlaceholderFont(const char* pFontName, int fontSize); + virtual void setPlaceholderFontColor(const Color3B& color); + virtual void setInputMode(EditBox::InputMode inputMode); + virtual void setInputFlag(EditBox::InputFlag inputFlag); + virtual void setMaxLength(int maxLength); + virtual int getMaxLength(); + virtual void setReturnType(EditBox::KeyboardReturnType returnType); + virtual bool isEditing(); + + virtual void setText(const char* pText); + virtual const char* getText(void); + virtual void setPlaceHolder(const char* pText); + virtual void setPosition(const Vec2& pos); + virtual void setVisible(bool visible); + virtual void setContentSize(const Size& size); + virtual void setAnchorPoint(const Vec2& anchorPoint); + virtual void visit(void); + virtual void doAnimationWhenKeyboardMove(float duration, float distance); + virtual void openKeyboard(); + virtual void closeKeyboard(); + virtual void onEnter(void); + private: + Platform::String^ stringToPlatformString(std::string strSrc); + std::string PlatformStringTostring(Platform::String^ strSrc); + private: + + Label* m_pLabel; + Label* m_pLabelPlaceHolder; + EditBox::InputMode m_eEditBoxInputMode; + EditBox::InputFlag m_eEditBoxInputFlag; + (EditBox::KeyboardReturnType m_eKeyboardReturnType; + + std::string m_strText; + std::string m_strPlaceHolder; + + Color3B m_colText; + Color3B m_colPlaceHolder; + + int m_nMaxLength; + Size m_EditSize; + }; +} + +NS_CC_END + +#endif diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index a7071c3729..13f6f2f92d 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -140,11 +140,28 @@ namespace ui { return true; } + bool Scale9Sprite::initWithBatchNode(cocos2d::SpriteBatchNode *batchnode, const cocos2d::Rect &rect, bool rotated, const cocos2d::Rect &capInsets) + { + Sprite *sprite = Sprite::createWithTexture(batchnode->getTexture()); + return init(sprite, rect, rotated, capInsets); + } + + bool Scale9Sprite::initWithBatchNode(cocos2d::SpriteBatchNode *batchnode, const cocos2d::Rect &rect, const cocos2d::Rect &capInsets) + { + return initWithBatchNode(batchnode, rect, false, capInsets); + } + #define TRANSLATE_X(x, y, xtranslate) \ x+=xtranslate; \ #define TRANSLATE_Y(x, y, ytranslate) \ -y+=ytranslate; \ +y+=ytranslate; \ + + bool Scale9Sprite::updateWithBatchNode(cocos2d::SpriteBatchNode *batchnode, const cocos2d::Rect &originalRect, bool rotated, const cocos2d::Rect &capInsets) + { + Sprite *sprite = Sprite::createWithTexture(batchnode->getTexture()); + return this->updateWithSprite(sprite, originalRect, rotated, capInsets); + } bool Scale9Sprite::updateWithSprite(Sprite* sprite, const Rect& originalRect, bool rotated, const Rect& capInsets) { diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index da54df5de0..6a0d8b7e4f 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -69,6 +69,7 @@ namespace ui { */ static Scale9Sprite* create(const std::string& file, const Rect& rect, const Rect& capInsets); + /** * Creates a 9-slice sprite with a texture file. The whole texture will be * broken down into a 3×3 grid of equal blocks. @@ -233,6 +234,9 @@ namespace ui { virtual bool init(); virtual bool init(Sprite* sprite, const Rect& rect, bool rotated, const Rect& capInsets); virtual bool init(Sprite* sprite, const Rect& rect, const Rect& capInsets); + CC_DEPRECATED_ATTRIBUTE virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets); + CC_DEPRECATED_ATTRIBUTE virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets); + /** * Creates and returns a new sprite object with the specified cap insets. * You use this method to add cap insets to a sprite or to change the existing @@ -244,6 +248,8 @@ namespace ui { Scale9Sprite* resizableSpriteWithCapInsets(const Rect& capInsets); virtual bool updateWithSprite(Sprite* sprite, const Rect& rect, bool rotated, const Rect& capInsets); + CC_DEPRECATED_ATTRIBUTE bool updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& originalRect, bool rotated, const Rect& capInsets); + virtual void setSpriteFrame(SpriteFrame * spriteFrame); // overrides diff --git a/cocos/ui/proj.win32/Win32InputBox.cpp b/cocos/ui/proj.win32/Win32InputBox.cpp new file mode 100644 index 0000000000..da1cb12301 --- /dev/null +++ b/cocos/ui/proj.win32/Win32InputBox.cpp @@ -0,0 +1,383 @@ +#include "Win32InputBox.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + +#include + +#pragma warning (disable: 4312) + +typedef struct _MSDN_DLGTEMPLATEEX +{ + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; + BYTE _rest[1]; // rest of structure +} MSDN_DLGTEMPLATEEX; + +static bool IsDlgTemplateExtended(DLGTEMPLATE *dlgTemplate) +{ + MSDN_DLGTEMPLATEEX *dgExTemplate = (MSDN_DLGTEMPLATEEX *) dlgTemplate; + + // MSDN excerpt: + //* dlgVer + // Specifies the version number of the extended dialog box template. This member must be 1. + //* signature + // Indicates whether a template is an extended dialog box template. + // If signature is 0xFFFF, this is an extended dialog box template. + // In this case, the dlgVer member specifies the template version number. + // If signature is any value other than 0xFFFF, this is a standard dialog box template that uses the DLGTEMPLATE and DLGITEMTEMPLATE structures. + + return (dgExTemplate->dlgVer == 1) && (dgExTemplate->signature == 0xFFFF); +} + +// Use alignment if supported by the compiler +#ifdef _MSC_VER + #if _MSC_VER > 1200 + __declspec(align(4)) + #endif +#endif + +// per the MSDN, the DLGTEMPLATE must be DWORD aligned +// this was generated by the DlgResToDlgTemplate tool +static unsigned char definputbox_dlg[] = +{ + 0x01,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x00,0xc8,0x00,0x06, + 0x00,0x16,0x00,0x11,0x00,0xe7,0x00,0x6d,0x00,0x00,0x00,0x00,0x00,0x57,0x00,0x69, + 0x00,0x6e,0x00,0x33,0x00,0x32,0x00,0x49,0x00,0x6e,0x00,0x70,0x00,0x75,0x00,0x74, + 0x00,0x42,0x00,0x6f,0x00,0x78,0x00,0x00,0x00,0x08,0x00,0xbc,0x02,0x00,0x00,0x4d, + 0x00,0x53,0x00,0x20,0x00,0x53,0x00,0x68,0x00,0x65,0x00,0x6c,0x00,0x6c,0x00,0x20, + 0x00,0x44,0x00,0x6c,0x00,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x00,0x02,0x50,0x06,0x00,0x04,0x00,0x9d,0x00,0x21,0x00,0xe8, + 0x03,0x00,0x00,0xff,0xff,0x82,0x00,0x50,0x00,0x72,0x00,0x6f,0x00,0x6d,0x00,0x70, + 0x00,0x74,0x00,0x3a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x00,0x81,0x50,0x06,0x00,0x25,0x00,0xd8,0x00,0x0e,0x00,0xe9, + 0x03,0x00,0x00,0xff,0xff,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x84,0x10,0xa1,0x50,0x06,0x00,0x37,0x00,0xd8,0x00,0x31,0x00,0xea, + 0x03,0x00,0x00,0xff,0xff,0x81,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x01,0x00,0x03,0x50,0xab,0x00,0x04,0x00,0x33,0x00,0x0e,0x00,0x01, + 0x00,0x00,0x00,0xff,0xff,0x80,0x00,0x4f,0x00,0x4b,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x50,0xab,0x00,0x15,0x00,0x33, + 0x00,0x0e,0x00,0x02,0x00,0x00,0x00,0xff,0xff,0x80,0x00,0x43,0x00,0x41,0x00,0x4e, + 0x00,0x43,0x00,0x45,0x00,0x4c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x02,0x40,0x00,0x00,0x27,0x00,0x08,0x00,0x08,0x00,0xff, + 0xff,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0x00,0x00 +}; + +static LPCTSTR definputbox_buttonnames[] = { _T("OK"), _T("CANCEL") }; +static const INT_PTR definputbox_buttonids[] = { IDOK, IDCANCEL }; + +static const INT + definputbox_id_prompt = 1000, + definputbox_id_edit1 = 1001, + definputbox_id_edit2 = 1002; + +WIN32INPUTBOX_PARAM::WIN32INPUTBOX_PARAM() +{ + bMultiline = false; + hwndOwner = 0; + DlgTemplateName = 0; + hInstance = (HINSTANCE) ::GetModuleHandle(0); + DlgTemplateData = definputbox_dlg; + + bCenter = true; + + dwStylesPlus = 0; + dwExStylesPlus = 0; + dwStylesMinus = 0xFFFFFFFF; + dwExStylesMinus = 0xFFFFFFFF; + + xPos = yPos = -1; + + szResult = 0; + nResultSize = 0; +} + +CWin32InputBox::CWin32InputBox(WIN32INPUTBOX_PARAM *param) +{ + _param = param; +} + +CWin32InputBox::~CWin32InputBox() +{ + +} + +void CWin32InputBox::SetParam(WIN32INPUTBOX_PARAM *param) +{ + _param = param; +} + +WIN32INPUTBOX_PARAM *CWin32InputBox::GetParam() +{ + return _param; +} + +INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param) +{ + // Check mandatory parameters + if (param->szResult == 0) + { + ::SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + LPDLGTEMPLATE dlgTemplate; + + if (param->DlgTemplateName != 0) + { + HMODULE hModule = (HMODULE)param->hInstance; +#ifdef __MINGW32__ + HRSRC rcDlg = ::FindResource(hModule, (LPWSTR)(ULONG_PTR)(size_t)(param->DlgTemplateName), RT_DIALOG); +#else + HRSRC rcDlg = ::FindResource(hModule, MAKEINTRESOURCE(param->DlgTemplateName), RT_DIALOG); +#endif + if (rcDlg == nullptr) + return 0; + + HGLOBAL hglobalDlg = ::LoadResource(hModule, rcDlg); + if (hglobalDlg == nullptr) + return 0; + + dlgTemplate = (LPDLGTEMPLATE) hglobalDlg; + } + else if (param->DlgTemplateData != 0) + { + dlgTemplate = (LPDLGTEMPLATE) param->DlgTemplateData; + } + + MSDN_DLGTEMPLATEEX *dlgTemplateEx = + IsDlgTemplateExtended((LPDLGTEMPLATE) dlgTemplate) ? (MSDN_DLGTEMPLATEEX *) dlgTemplate : 0; + + if (dlgTemplateEx != 0) + { + dlgTemplateEx->exStyle |= param->dwExStylesPlus; + dlgTemplateEx->style |= param->dwStylesPlus; + dlgTemplateEx->exStyle &= param->dwExStylesMinus; + dlgTemplateEx->style &= param->dwStylesMinus; + + if (param->bCenter) + dlgTemplateEx->style |= DS_CENTER; + + if (param->xPos != -1) + dlgTemplateEx->x = param->xPos; + if (param->yPos != -1) + dlgTemplateEx->y = param->yPos; + } + else + { + dlgTemplate->dwExtendedStyle |= param->dwExStylesPlus; + dlgTemplate->style |= param->dwStylesPlus; + dlgTemplate->dwExtendedStyle &= param->dwExStylesMinus; + dlgTemplate->style &= param->dwStylesMinus; + + if (param->bCenter) + dlgTemplate->style |= DS_CENTER; + + if (param->xPos != -1) + dlgTemplate->x = param->xPos; + + if (param->yPos != -1) + dlgTemplate->y = param->yPos; + } + + CWin32InputBox inputbox(param); + + // Resize dialog and SHOW or HIDE multiline + INT_PTR r = ::DialogBoxIndirectParam(param->hInstance, dlgTemplate, param->hwndOwner, (DLGPROC)DlgProc, (LPARAM)&inputbox); + + return r; +} + +INT_PTR CWin32InputBox::InputBox( + LPCSTR szTitle, + LPCSTR szPrompt, + LPSTR szResult, + DWORD nResultSize, + bool bMultiLine, + HWND hwndParent) +{ + WIN32INPUTBOX_PARAM param; + + param.szTitle = szTitle; + param.szPrompt = szPrompt; + param.szResult = szResult; + param.nResultSize = nResultSize; + param.bMultiline = bMultiLine; + param.hwndOwner = hwndParent; + return InputBoxEx(¶m); +} + +void CWin32InputBox::InitDialog() +{ + // Set the button captions + for (size_t i=0;ihDlg, (int) definputbox_buttonids[i], definputbox_buttonnames[i]); + + // Set other controls + ::SetWindowTextA(_param->hDlg, Utf8ToAnsi(_param->szTitle).c_str()); + ::SetDlgItemTextA(_param->hDlg, definputbox_id_prompt, Utf8ToAnsi(_param->szPrompt).c_str()); + + HWND hwndEdit1 = ::GetDlgItem(_param->hDlg, definputbox_id_edit1); + HWND hwndEdit2 = ::GetDlgItem(_param->hDlg, definputbox_id_edit2); + + if (_param->bMultiline) + _hwndEditCtrl = hwndEdit2; + else + _hwndEditCtrl = hwndEdit1; + + ::SetWindowTextA(_hwndEditCtrl, Utf8ToAnsi(_param->szResult).c_str()); + + RECT rectDlg, rectEdit1, rectEdit2; + + ::GetWindowRect(_param->hDlg, &rectDlg); + ::GetWindowRect(hwndEdit1, &rectEdit1); + ::GetWindowRect(hwndEdit2, &rectEdit2); + + if (_param->bMultiline) + { + ::ShowWindow(hwndEdit1, SW_HIDE); + ::SetWindowPos( + hwndEdit2, + HWND_NOTOPMOST, + rectEdit1.left - rectDlg.left, + (rectEdit1.top - rectDlg.top) - (rectEdit1.bottom - rectEdit1.top), + 0, + 0, + SWP_NOSIZE | SWP_NOZORDER); + + ::SetWindowPos( + _param->hDlg, + HWND_NOTOPMOST, + 0, + 0, + rectDlg.right - rectDlg.left, + rectDlg.bottom - rectDlg.top - (rectEdit1.bottom - rectEdit1.top), + SWP_NOMOVE); + + } + else + { + ::SetWindowPos( + _param->hDlg, + HWND_NOTOPMOST, + 0, + 0, + rectDlg.right - rectDlg.left, + rectEdit1.bottom - rectDlg.top + 5, + SWP_NOMOVE); + + ::ShowWindow(hwndEdit2, SW_HIDE); + } +} + +// Message handler for about box. +LRESULT CALLBACK CWin32InputBox::DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + CWin32InputBox *_this = (CWin32InputBox *) ::GetWindowLongPtr(hDlg, GWLP_USERDATA); + WIN32INPUTBOX_PARAM *param = _this ? _this->GetParam() : 0; + + switch (message) + { + case WM_INITDIALOG: + { + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR) lParam); + + _this = (CWin32InputBox *) lParam; + _this->_param->hDlg = hDlg; + _this->InitDialog(); + return TRUE; + } + + case WM_COMMAND: + { +#ifdef _MY_DEBUG + CHAR buf[1024]; + static int i=0; + sprintf(buf, "WM_COMMAND: %09d wParam=%08X lParam=%08X\n", i++, wParam, lParam); + OutputDebugString(buf); +#endif + INT_PTR buttonId = LOWORD(wParam); + for (size_t i=0; + i_hwndEditCtrl, + _this->_param->szResult, + _this->_param->nResultSize); + + std::string strUtf8 = AnsiToUtf8(_this->_param->szResult); + + memset(_this->_param->szResult, 0, _this->_param->nResultSize); + strncpy(_this->_param->szResult, strUtf8.c_str(), _this->_param->nResultSize-1); + + ::EndDialog(hDlg, buttonId); + return TRUE; + } + } + } + break; + } + return FALSE; +} + + +std::string CWin32InputBox::AnsiToUtf8(std::string strAnsi) +{ + std::string ret; + if (strAnsi.length() > 0) + { + int nWideStrLength = MultiByteToWideChar(CP_ACP, 0, strAnsi.c_str(), -1, nullptr, 0); + WCHAR* pwszBuf = (WCHAR*)malloc((nWideStrLength+1)*sizeof(WCHAR)); + memset(pwszBuf, 0, (nWideStrLength+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, strAnsi.c_str(), -1, pwszBuf, (nWideStrLength+1)*sizeof(WCHAR)); + + int nUtf8Length = WideCharToMultiByte( CP_UTF8,0,pwszBuf,-1,nullptr,0,nullptr,FALSE ); + char* pszUtf8Buf = (char*)malloc((nUtf8Length+1)*sizeof(char)); + memset(pszUtf8Buf, 0, (nUtf8Length+1)*sizeof(char)); + + WideCharToMultiByte(CP_UTF8, 0, pwszBuf, -1, pszUtf8Buf, (nUtf8Length+1)*sizeof(char), nullptr, FALSE); + ret = pszUtf8Buf; + + free(pszUtf8Buf); + free(pwszBuf); + } + return ret; +} + +std::string CWin32InputBox::Utf8ToAnsi(std::string strUTF8) +{ + std::string ret; + if (strUTF8.length() > 0) + { + int nWideStrLength = MultiByteToWideChar(CP_UTF8, 0, strUTF8.c_str(), -1, nullptr, 0); + WCHAR* pwszBuf = (WCHAR*)malloc((nWideStrLength+1)*sizeof(WCHAR)); + memset(pwszBuf, 0, (nWideStrLength+1)*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, strUTF8.c_str(), -1, pwszBuf, (nWideStrLength+1)*sizeof(WCHAR)); + + int nAnsiStrLength = WideCharToMultiByte( CP_ACP,0,pwszBuf,-1,nullptr,0,nullptr,FALSE ); + char* pszAnsiBuf = (char*)malloc((nAnsiStrLength+1)*sizeof(char)); + memset(pszAnsiBuf, 0, (nAnsiStrLength+1)*sizeof(char)); + + WideCharToMultiByte(CP_ACP, 0, pwszBuf, -1, pszAnsiBuf, (nAnsiStrLength+1)*sizeof(char), nullptr, FALSE); + ret = pszAnsiBuf; + + free(pszAnsiBuf); + free(pwszBuf); + } + + return ret; +} + + + +#endif /* #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ diff --git a/cocos/ui/proj.win32/Win32InputBox.h b/cocos/ui/proj.win32/Win32InputBox.h new file mode 100644 index 0000000000..1fd46a5593 --- /dev/null +++ b/cocos/ui/proj.win32/Win32InputBox.h @@ -0,0 +1,106 @@ +#ifndef __03022006__WIN32INPUTBOX__ +#define __03022006__WIN32INPUTBOX__ + +#include "cocos2d.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +/* + +This library is (c) Elias Bachaalany aka lallous +You may use this library under the following license agreement: + +The zlib/libpng License. +--------------------------- +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, including commercial applications, +and to alter it and redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; + you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. +2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +*/ + +#include +#include + +class CWin32InputBox; + +// Structure used to orient the inputbox behavior +struct WIN32INPUTBOX_PARAM +{ + friend class CWin32InputBox; + + // + IN OPTIONAL bool bMultiline; + + // Pass this as none zero so to use this memory dlg template + IN OPTIONAL LPVOID DlgTemplateData; + + // Pass this as none ZERO so to load DLGTEMPLATE from resources + IN OPTIONAL LPCSTR DlgTemplateName; + + // passing both "DlgTemplateName" and "DlgTemplateData" ZERO will cause + // the dialog to use his default embedded resource + + // Center on monitor or owner window? + IN OPTIONAL bool bCenter; + + // Want to add more styles to the dialog? + IN OPTIONAL DWORD dwStylesPlus, dwStylesMinus; + IN OPTIONAL DWORD dwExStylesPlus, dwExStylesMinus; + + IN LPCSTR szTitle, szPrompt; + + // Return buffer + OUT LPSTR szResult; + IN DWORD nResultSize; + + // Owner window + HWND hwndOwner; + HINSTANCE hInstance; + + short xPos, yPos; + + WIN32INPUTBOX_PARAM(); +private: + HWND hDlg; +}; + +class CWin32InputBox +{ +private: + WIN32INPUTBOX_PARAM *_param; + static LRESULT CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); + HWND _hwndEditCtrl; + + void InitDialog(); + void SetParam(WIN32INPUTBOX_PARAM *); + WIN32INPUTBOX_PARAM * GetParam(); + +public: + + CWin32InputBox(WIN32INPUTBOX_PARAM *); + ~CWin32InputBox(); + + static INT_PTR InputBoxEx(WIN32INPUTBOX_PARAM *); + static INT_PTR InputBox( + LPCSTR szTitle, + LPCSTR szPrompt, + LPSTR szResult, + DWORD nResultSize, + bool bMultiLine = false, + HWND hwndParent = 0); + + static std::string AnsiToUtf8(std::string strAnsi); + static std::string Utf8ToAnsi(std::string strUTF8); +}; + +#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ + +#endif diff --git a/cocos/ui/proj.win32/libui.vcxproj b/cocos/ui/proj.win32/libui.vcxproj new file mode 100644 index 0000000000..92003d88cd --- /dev/null +++ b/cocos/ui/proj.win32/libui.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {21b2c324-891f-48ea-ad1a-5ae13de12e28} + + + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} + + + + {7E06E92C-537A-442B-9E4A-4761C84F8A1A} + libui + libui + + + + DynamicLibrary + true + v100 + v110 + v110_xp + v120 + v120_xp + Unicode + + + DynamicLibrary + false + v100 + v110 + v110_xp + v120 + v120_xp + true + Unicode + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + + + + Level3 + Disabled + + + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USEGUIDLL;%(PreprocessorDefinitions) + true + 4267;4251;4244;%(DisableSpecificWarnings) + false + OldStyle + + + true + $(OutDir);%(AdditionalLibraryDirectories) + opengl32.lib;glew32.lib;%(AdditionalDependencies) + + + + + Level3 + MinSpace + true + true + + + WIN32;_WINDOWS;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USEGUIDLL;%(PreprocessorDefinitions) + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + None + false + + + true + true + true + $(OutDir);%(AdditionalLibraryDirectories) + opengl32.lib;glew32.lib;%(AdditionalDependencies) + + + + + + \ No newline at end of file diff --git a/cocos/ui/proj.win32/libui.vcxproj.filters b/cocos/ui/proj.win32/libui.vcxproj.filters new file mode 100644 index 0000000000..2933d8b07f --- /dev/null +++ b/cocos/ui/proj.win32/libui.vcxproj.filters @@ -0,0 +1,195 @@ + + + + + {e31ab7d3-b8b2-467f-9e08-fd5fe168b491} + + + {f9d13563-9e5e-4b35-b0e7-d41f587efa42} + + + {ed8a2ae0-5690-4d0d-829b-7c07164c0597} + + + {5f6e9e52-fbe7-4073-ac71-98632f9e6781} + + + {b59b178a-b7e0-4826-ba07-44c46cd29a10} + + + {08fb4468-821b-4e5c-9298-8b57a3152a5b} + + + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + System + + + System + + + BaseClasses + + + Layouts + + + Layouts + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + Layouts + + + Layouts + + + Layouts + + + Layouts + + + System + + + System + + + BaseClasses + + + UIWidgets\UIEditBox + + + UIWidgets\UIEditBox + + + UIWidgets\UIEditBox + + + UIWidgets\UIEditBox + + + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets\ScrollWidget + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + System + + + System + + + BaseClasses + + + Layouts + + + Layouts + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + UIWidgets + + + Layouts + + + Layouts + + + Layouts + + + Layouts + + + System + + + BaseClasses + + + UIWidgets\UIEditBox + + + UIWidgets\UIEditBox + + + UIWidgets\UIEditBox + + + \ No newline at end of file diff --git a/cocos/ui/proj.wp8/libGUI.vcxproj b/cocos/ui/proj.wp8/libGUI.vcxproj index 5e2e4e6453..47ec5d9d10 100644 --- a/cocos/ui/proj.wp8/libGUI.vcxproj +++ b/cocos/ui/proj.wp8/libGUI.vcxproj @@ -184,6 +184,9 @@ + + + @@ -210,6 +213,8 @@ + + diff --git a/cocos/ui/proj.wp8/libGUI.vcxproj.filters b/cocos/ui/proj.wp8/libGUI.vcxproj.filters index 7a7b4ae6b4..c0a7f8250b 100644 --- a/cocos/ui/proj.wp8/libGUI.vcxproj.filters +++ b/cocos/ui/proj.wp8/libGUI.vcxproj.filters @@ -87,6 +87,15 @@ BaseClasses + + UIWidgets + + + UIWidgets + + + UIWidgets + @@ -161,5 +170,11 @@ BaseClasses + + UIWidgets + + + UIWidgets + \ No newline at end of file diff --git a/extensions/Android.mk b/extensions/Android.mk index 89877aa54d..2603f2f3d2 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -18,11 +18,6 @@ GUI/CCControlExtension/CCControlStepper.cpp \ GUI/CCControlExtension/CCControlSwitch.cpp \ GUI/CCControlExtension/CCControlUtils.cpp \ GUI/CCControlExtension/CCInvocation.cpp \ -GUI/CCControlExtension/CCScale9Sprite.cpp \ -GUI/CCEditBox/CCEditBox.cpp \ -GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ -GUI/CCEditBox/CCEditBoxImplNone.cpp \ -GUI/CCEditBox/CCEditBoxImplWin.cpp \ GUI/CCScrollView/CCScrollView.cpp \ GUI/CCScrollView/CCTableView.cpp \ GUI/CCScrollView/CCTableViewCell.cpp \ @@ -33,6 +28,10 @@ LOCAL_STATIC_LIBRARIES := cocos2dx_internal_static LOCAL_STATIC_LIBRARIES += cocos_curl_static LOCAL_STATIC_LIBRARIES += box2d_static +GU/CCEditBox/CCEditBox.cpp \ +GUI/CCEditBox/CCEditBoxImplAndroid.cpp \ +GUI/CCEditBox/CCEditBoxImplNone.cpp \ +GUI/CCEditBox/CCEditBoxImplWin.cpp \ LOCAL_CXXFLAGS += -fexceptions LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. \ diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt deleted file mode 100644 index b3c609beb5..0000000000 --- a/extensions/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -set(EXTENSIONS_SRC - assets-manager/AssetsManager.cpp - GUI/CCControlExtension/CCControl.cpp - GUI/CCControlExtension/CCControlButton.cpp - GUI/CCControlExtension/CCControlColourPicker.cpp - GUI/CCControlExtension/CCControlHuePicker.cpp - GUI/CCControlExtension/CCControlPotentiometer.cpp - GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp - GUI/CCControlExtension/CCControlSlider.cpp - GUI/CCControlExtension/CCControlStepper.cpp - GUI/CCControlExtension/CCControlSwitch.cpp - GUI/CCControlExtension/CCControlUtils.cpp - GUI/CCControlExtension/CCInvocation.cpp - GUI/CCControlExtension/CCScale9Sprite.cpp - GUI/CCEditBox/CCEditBox.cpp - GUI/CCEditBox/CCEditBoxImplAndroid.cpp - GUI/CCEditBox/CCEditBoxImplNone.cpp - GUI/CCEditBox/CCEditBoxImplWin.cpp - GUI/CCScrollView/CCScrollView.cpp - GUI/CCScrollView/CCTableView.cpp - GUI/CCScrollView/CCTableViewCell.cpp - physics-nodes/CCPhysicsDebugNode.cpp - physics-nodes/CCPhysicsSprite.cpp -) - -if(WIN32) - ADD_DEFINITIONS(-DUNICODE -D_UNICODE) - - set(PLATFORM_EXTENSIONS_SRC - proj.win32/Win32InputBox.cpp - ) -elseif(APPLE) - -else() - -endif() - -include_directories( - .. -) - -add_library(extensions STATIC - ${EXTENSIONS_SRC} - ${PLATFORM_EXTENSIONS_SRC} -) - -set_target_properties(extensions - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" -) - diff --git a/extensions/ExtensionDeprecated.cpp b/extensions/ExtensionDeprecated.cpp new file mode 100644 index 0000000000..d3e3e65e5d --- /dev/null +++ b/extensions/ExtensionDeprecated.cpp @@ -0,0 +1,25 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "ExtensionDeprecated.h" diff --git a/extensions/ExtensionDeprecated.h b/extensions/ExtensionDeprecated.h new file mode 100644 index 0000000000..8abdf919b6 --- /dev/null +++ b/extensions/ExtensionDeprecated.h @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __cocos2d_libs__ExtensionDeprecated__ +#define __cocos2d_libs__ExtensionDeprecated__ + +#include "ui/UIEditBox/UIEditBox.h" +#include "ExtensionMacros.h" + +NS_CC_EXT_BEGIN + +CC_DEPRECATED_ATTRIBUTE typedef ui::EditBox EditBox; +CC_DEPRECATED_ATTRIBUTE typedef ui::EditBoxDelegate EditBoxDelegate; +CC_DEPRECATED_ATTRIBUTE typedef ui::Scale9Sprite Scale9Sprite; + +NS_CC_EXT_END + +#endif /* defined(__cocos2d_libs__ExtensionDeprecated__) */ diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index f7cc5b71b6..9a69de517e 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -26,7 +26,6 @@ */ #include "CCControlButton.h" -#include "CCScale9Sprite.h" #include "2d/CCLabel.h" #include "2d/CCAction.h" #include "2d/CCActionInterval.h" @@ -64,10 +63,10 @@ ControlButton::~ControlButton() bool ControlButton::init() { - return this->initWithLabelAndBackgroundSprite(Label::createWithSystemFont("", "Helvetica", 12), Scale9Sprite::create()); + return this->initWithLabelAndBackgroundSprite(Label::createWithSystemFont("", "Helvetica", 12), cocos2d::ui::Scale9Sprite::create()); } -bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* backgroundSprite) +bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprite* backgroundSprite) { if (Control::init()) { @@ -121,7 +120,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b } } -ControlButton* ControlButton::create(Node* label, Scale9Sprite* backgroundSprite) +ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite) { ControlButton *pRet = new (std::nothrow) ControlButton(); pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite); @@ -131,7 +130,7 @@ ControlButton* ControlButton::create(Node* label, Scale9Sprite* backgroundSprite bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize) { - return initWithLabelAndBackgroundSprite(Label::createWithSystemFont(title, fontName, fontSize), Scale9Sprite::create()); + return initWithLabelAndBackgroundSprite(Label::createWithSystemFont(title, fontName, fontSize), cocos2d::ui::Scale9Sprite::create()); } ControlButton* ControlButton::create(const std::string& title, const std::string& fontName, float fontSize) @@ -142,13 +141,13 @@ ControlButton* ControlButton::create(const std::string& title, const std::string return pRet; } -bool ControlButton::initWithBackgroundSprite(Scale9Sprite* sprite) +bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite) { Label *label = Label::createWithSystemFont("", "Arial", 30);// return initWithLabelAndBackgroundSprite(label, sprite); } -ControlButton* ControlButton::create(Scale9Sprite* sprite) +ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite) { ControlButton *pRet = new (std::nothrow) ControlButton(); pRet->initWithBackgroundSprite(sprite); @@ -423,7 +422,7 @@ const std::string& ControlButton::getTitleBMFontForState(State state) } -Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state) +ui::Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state) { auto backgroundSprite = _backgroundSpriteDispatchTable.at((int)state); if (backgroundSprite) @@ -434,7 +433,7 @@ Scale9Sprite* ControlButton::getBackgroundSpriteForState(State state) } -void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, State state) +void ControlButton::setBackgroundSpriteForState(ui::Scale9Sprite* sprite, State state) { Size oldPreferredSize = _preferredSize; @@ -470,7 +469,7 @@ void ControlButton::setBackgroundSpriteForState(Scale9Sprite* sprite, State stat void ControlButton::setBackgroundSpriteFrameForState(SpriteFrame * spriteFrame, State state) { - Scale9Sprite * sprite = Scale9Sprite::createWithSpriteFrame(spriteFrame); + ui::Scale9Sprite * sprite = ui::Scale9Sprite::createWithSpriteFrame(spriteFrame); this->setBackgroundSpriteForState(sprite, state); } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index f7484e2172..2ead117306 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -32,9 +32,8 @@ #include "CCControl.h" #include "CCInvocation.h" -#include "CCScale9Sprite.h" #include "base/CCMap.h" -#include "extensions/ExtensionExport.h" +#include "ui/UIScale9Sprite.h" NS_CC_EXT_BEGIN @@ -56,8 +55,8 @@ class CC_EX_DLL ControlButton : public Control { public: static ControlButton* create(); - static ControlButton* create(Scale9Sprite* sprite); - static ControlButton* create(Node* label, Scale9Sprite* backgroundSprite); + static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite); + static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite); static ControlButton* create(const std::string& title, const std::string& fontName, float fontSize); virtual void needsLayout(void); @@ -149,7 +148,7 @@ public: * @param state The state that uses the background sprite. Possible values are * described in "CCControlState". */ - virtual Scale9Sprite* getBackgroundSpriteForState(State state); + virtual cocos2d::ui::Scale9Sprite* getBackgroundSpriteForState(State state); /** * Sets the background sprite to use for the specified button state. @@ -158,7 +157,7 @@ public: * @param state The state that uses the specified image. The values are described * in "CCControlState". */ - virtual void setBackgroundSpriteForState(Scale9Sprite* sprite, State state); + virtual void setBackgroundSpriteForState(cocos2d::ui::Scale9Sprite* sprite, State state); /** * Sets the background spriteFrame to use for the specified button state. @@ -203,8 +202,8 @@ CC_CONSTRUCTOR_ACCESS: virtual ~ControlButton(); virtual bool init() override; - virtual bool initWithLabelAndBackgroundSprite(Node* label, Scale9Sprite* backgroundSprite); - virtual bool initWithBackgroundSprite(Scale9Sprite* sprite); + virtual bool initWithLabelAndBackgroundSprite(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite); + virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite); virtual bool initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize); protected: @@ -222,7 +221,7 @@ protected: CC_SYNTHESIZE_RETAIN(Node*, _titleLabel, TitleLabel); /** The current background sprite. */ - CC_SYNTHESIZE_RETAIN(Scale9Sprite*, _backgroundSprite, BackgroundSprite); + CC_SYNTHESIZE_RETAIN(cocos2d::ui::Scale9Sprite*, _backgroundSprite, BackgroundSprite); /** The prefered size of the button, if label is larger it will be expanded. */ CC_PROPERTY_PASS_BY_REF(Size, _preferredSize, PreferredSize); @@ -238,7 +237,7 @@ protected: std::unordered_map _titleColorDispatchTable; Map _titleLabelDispatchTable; - Map _backgroundSpriteDispatchTable; + Map _backgroundSpriteDispatchTable; /* Define the button margin for Top/Bottom edge */ CC_SYNTHESIZE_READONLY(int, _marginV, VerticalMargin); diff --git a/extensions/GUI/CCControlExtension/CCControlExtensions.h b/extensions/GUI/CCControlExtension/CCControlExtensions.h index c4548bf535..2cbae97035 100644 --- a/extensions/GUI/CCControlExtension/CCControlExtensions.h +++ b/extensions/GUI/CCControlExtension/CCControlExtensions.h @@ -25,7 +25,6 @@ THE SOFTWARE. #ifndef __CCCONTROL_EXTENSIONS_H__ #define __CCCONTROL_EXTENSIONS_H__ -#include "CCScale9Sprite.h" #include "CCControl.h" #include "CCControlButton.h" #include "CCControlColourPicker.h" diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp b/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp deleted file mode 100644 index 021de0489e..0000000000 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.cpp +++ /dev/null @@ -1,816 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Created by Jung Sang-Taik on 12. 3. 16.. -Copyright (c) 2012 Neofect. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "CCScale9Sprite.h" -#include "base/CCPlatformMacros.h" -#include "2d/CCSprite.h" -#include "2d/CCSpriteFrameCache.h" - -NS_CC_EXT_BEGIN - -Scale9Sprite::Scale9Sprite() -: _spritesGenerated(false) -, _spriteFrameRotated(false) -, _positionsAreDirty(false) -, _scale9Image(nullptr) -, _topLeft(nullptr) -, _top(nullptr) -, _topRight(nullptr) -, _left(nullptr) -, _centre(nullptr) -, _right(nullptr) -, _bottomLeft(nullptr) -, _bottom(nullptr) -, _bottomRight(nullptr) -, _opacityModifyRGB(false) -, _insetLeft(0) -, _insetTop(0) -, _insetRight(0) -, _insetBottom(0) -{ - -} - -Scale9Sprite::~Scale9Sprite() -{ - CC_SAFE_RELEASE(_topLeft); - CC_SAFE_RELEASE(_top); - CC_SAFE_RELEASE(_topRight); - CC_SAFE_RELEASE(_left); - CC_SAFE_RELEASE(_centre); - CC_SAFE_RELEASE(_right); - CC_SAFE_RELEASE(_bottomLeft); - CC_SAFE_RELEASE(_bottom); - CC_SAFE_RELEASE(_bottomRight); - CC_SAFE_RELEASE(_scale9Image); -} - -bool Scale9Sprite::init() -{ - return this->initWithBatchNode(nullptr, Rect::ZERO, Rect::ZERO); -} - -bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets) -{ - return this->initWithBatchNode(batchnode, rect, false, capInsets); -} - -bool Scale9Sprite::initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets) -{ - if(batchnode) - { - this->updateWithBatchNode(batchnode, rect, rotated, capInsets); - } - this->setCascadeColorEnabled(true); - this->setCascadeOpacityEnabled(true); - this->setAnchorPoint(Vec2(0.5f, 0.5f)); - this->_positionsAreDirty = true; - - return true; -} - -#define TRANSLATE_X(x, y, xtranslate) \ - x+=xtranslate; \ - -#define TRANSLATE_Y(x, y, ytranslate) \ - y+=ytranslate; \ - -bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& originalRect, bool rotated, const Rect& capInsets) -{ - GLubyte opacity = getOpacity(); - Color3B color = getColor(); - Rect rect(originalRect); - - // Release old sprites - this->removeAllChildrenWithCleanup(true); - - CC_SAFE_RELEASE(this->_centre); - CC_SAFE_RELEASE(this->_top); - CC_SAFE_RELEASE(this->_topLeft); - CC_SAFE_RELEASE(this->_topRight); - CC_SAFE_RELEASE(this->_left); - CC_SAFE_RELEASE(this->_right); - CC_SAFE_RELEASE(this->_bottomLeft); - CC_SAFE_RELEASE(this->_bottom); - CC_SAFE_RELEASE(this->_bottomRight); - - - if(this->_scale9Image != batchnode) - { - CC_SAFE_RELEASE(this->_scale9Image); - _scale9Image = batchnode; - CC_SAFE_RETAIN(_scale9Image); - } - - if (!_scale9Image) - { - return false; - } - - _capInsets = capInsets; - _spriteFrameRotated = rotated; - - // If there is no given rect - if ( rect.equals(Rect::ZERO) ) - { - // Get the texture size as original - Size textureSize = _scale9Image->getTextureAtlas()->getTexture()->getContentSize(); - - rect = Rect(0, 0, textureSize.width, textureSize.height); - } - - // Set the given rect's size as original size - _spriteRect = rect; - _originalSize = rect.size; - _preferredSize = _originalSize; - _capInsetsInternal = capInsets; - - float w = rect.size.width; - float h = rect.size.height; - - // If there is no specified center region - if ( _capInsetsInternal.equals(Rect::ZERO) ) - { - // log("... cap insets not specified : using default cap insets ..."); - _capInsetsInternal = Rect(w/3, h/3, w/3, h/3); - } - - float left_w = _capInsetsInternal.origin.x; - float center_w = _capInsetsInternal.size.width; - float right_w = rect.size.width - (left_w + center_w); - - float top_h = _capInsetsInternal.origin.y; - float center_h = _capInsetsInternal.size.height; - float bottom_h = rect.size.height - (top_h + center_h); - - // calculate rects - - // ... top row - float x = 0.0; - float y = 0.0; - - // top left - Rect lefttopbounds = Rect(x, y, left_w, top_h); - - // top center - TRANSLATE_X(x, y, left_w); - Rect centertopbounds = Rect(x, y, center_w, top_h); - - // top right - TRANSLATE_X(x, y, center_w); - Rect righttopbounds = Rect(x, y, right_w, top_h); - - // ... center row - x = 0.0; - y = 0.0; - TRANSLATE_Y(x, y, top_h); - - // center left - Rect leftcenterbounds = Rect(x, y, left_w, center_h); - - // center center - TRANSLATE_X(x, y, left_w); - Rect centerbounds = Rect(x, y, center_w, center_h); - - // center right - TRANSLATE_X(x, y, center_w); - Rect rightcenterbounds = Rect(x, y, right_w, center_h); - - // ... bottom row - x = 0.0; - y = 0.0; - TRANSLATE_Y(x, y, top_h); - TRANSLATE_Y(x, y, center_h); - - // bottom left - Rect leftbottombounds = Rect(x, y, left_w, bottom_h); - - // bottom center - TRANSLATE_X(x, y, left_w); - Rect centerbottombounds = Rect(x, y, center_w, bottom_h); - - // bottom right - TRANSLATE_X(x, y, center_w); - Rect rightbottombounds = Rect(x, y, right_w, bottom_h); - - if (!rotated) { - // log("!rotated"); - - AffineTransform t = AffineTransform::IDENTITY; - t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y); - - centerbounds = RectApplyAffineTransform(centerbounds, t); - rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); - leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); - righttopbounds = RectApplyAffineTransform(righttopbounds, t); - lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); - rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); - leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); - centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); - centertopbounds = RectApplyAffineTransform(centertopbounds, t); - - // Centre - _centre = Sprite::createWithTexture(_scale9Image->getTexture(), centerbounds); - _centre->retain(); - this->addChild(_centre); - - - // Top - _top = Sprite::createWithTexture(_scale9Image->getTexture(), centertopbounds); - _top->retain(); - this->addChild(_top); - - // Bottom - _bottom = Sprite::createWithTexture(_scale9Image->getTexture(), centerbottombounds); - _bottom->retain(); - this->addChild(_bottom); - - // Left - _left = Sprite::createWithTexture(_scale9Image->getTexture(), leftcenterbounds); - _left->retain(); - this->addChild(_left); - - // Right - _right = Sprite::createWithTexture(_scale9Image->getTexture(), rightcenterbounds); - _right->retain(); - this->addChild(_right); - - // Top left - _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), lefttopbounds); - _topLeft->retain(); - this->addChild(_topLeft); - - // Top right - _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), righttopbounds); - _topRight->retain(); - this->addChild(_topRight); - - // Bottom left - _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), leftbottombounds); - _bottomLeft->retain(); - this->addChild(_bottomLeft); - - // Bottom right - _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rightbottombounds); - _bottomRight->retain(); - this->addChild(_bottomRight); - } else { - // set up transformation of coordinates - // to handle the case where the sprite is stored rotated - // in the spritesheet - // log("rotated"); - - AffineTransform t = AffineTransform::IDENTITY; - - Rect rotatedcenterbounds = centerbounds; - Rect rotatedrightbottombounds = rightbottombounds; - Rect rotatedleftbottombounds = leftbottombounds; - Rect rotatedrighttopbounds = righttopbounds; - Rect rotatedlefttopbounds = lefttopbounds; - Rect rotatedrightcenterbounds = rightcenterbounds; - Rect rotatedleftcenterbounds = leftcenterbounds; - Rect rotatedcenterbottombounds = centerbottombounds; - Rect rotatedcentertopbounds = centertopbounds; - - t = AffineTransformTranslate(t, rect.size.height+rect.origin.x, rect.origin.y); - t = AffineTransformRotate(t, 1.57079633f); - - centerbounds = RectApplyAffineTransform(centerbounds, t); - rightbottombounds = RectApplyAffineTransform(rightbottombounds, t); - leftbottombounds = RectApplyAffineTransform(leftbottombounds, t); - righttopbounds = RectApplyAffineTransform(righttopbounds, t); - lefttopbounds = RectApplyAffineTransform(lefttopbounds, t); - rightcenterbounds = RectApplyAffineTransform(rightcenterbounds, t); - leftcenterbounds = RectApplyAffineTransform(leftcenterbounds, t); - centerbottombounds = RectApplyAffineTransform(centerbottombounds, t); - centertopbounds = RectApplyAffineTransform(centertopbounds, t); - - rotatedcenterbounds.origin = centerbounds.origin; - rotatedrightbottombounds.origin = rightbottombounds.origin; - rotatedleftbottombounds.origin = leftbottombounds.origin; - rotatedrighttopbounds.origin = righttopbounds.origin; - rotatedlefttopbounds.origin = lefttopbounds.origin; - rotatedrightcenterbounds.origin = rightcenterbounds.origin; - rotatedleftcenterbounds.origin = leftcenterbounds.origin; - rotatedcenterbottombounds.origin = centerbottombounds.origin; - rotatedcentertopbounds.origin = centertopbounds.origin; - - // Centre - _centre = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbounds, true); - _centre->retain(); - this->addChild(_centre, 0); - - // Top - _top = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcentertopbounds, true); - _top->retain(); - this->addChild(_top); - - // Bottom - _bottom = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedcenterbottombounds, true); - _bottom->retain(); - this->addChild(_bottom); - - // Left - _left = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftcenterbounds, true); - _left->retain(); - this->addChild(_left); - - // Right - _right = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightcenterbounds, true); - _right->retain(); - this->addChild(_right); - - // Top left - _topLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedlefttopbounds, true); - _topLeft->retain(); - this->addChild(_topLeft); - - // Top right - _topRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrighttopbounds, true); - _topRight->retain(); - this->addChild(_topRight); - - // Bottom left - _bottomLeft = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedleftbottombounds, true); - _bottomLeft->retain(); - this->addChild(_bottomLeft); - - // Bottom right - _bottomRight = Sprite::createWithTexture(_scale9Image->getTexture(), rotatedrightbottombounds, true); - _bottomRight->retain(); - this->addChild(_bottomRight); - } - - this->setContentSize(rect.size); -// this->addChild(_scale9Image); - - if (_spritesGenerated) - { - // Restore color and opacity - this->setOpacity(opacity); - this->setColor(color); - } - _spritesGenerated = true; - - return true; -} - -void Scale9Sprite::setContentSize(const Size &size) -{ - Node::setContentSize(size); - this->_positionsAreDirty = true; -} - -void Scale9Sprite::updatePositions() -{ - // Check that instances are non-nullptr - if(!((_topLeft) && - (_topRight) && - (_bottomRight) && - (_bottomLeft) && - (_centre))) { - // if any of the above sprites are nullptr, return - return; - } - - Size size = this->_contentSize; - - float sizableWidth = size.width - _topLeft->getContentSize().width - _topRight->getContentSize().width; - float sizableHeight = size.height - _topLeft->getContentSize().height - _bottomRight->getContentSize().height; - - float horizontalScale = sizableWidth/_centre->getContentSize().width; - float verticalScale = sizableHeight/_centre->getContentSize().height; - - _centre->setScaleX(horizontalScale); - _centre->setScaleY(verticalScale); - - float rescaledWidth = _centre->getContentSize().width * horizontalScale; - float rescaledHeight = _centre->getContentSize().height * verticalScale; - - float leftWidth = _bottomLeft->getContentSize().width; - float bottomHeight = _bottomLeft->getContentSize().height; - - _bottomLeft->setAnchorPoint(Vec2(0,0)); - _bottomRight->setAnchorPoint(Vec2(0,0)); - _topLeft->setAnchorPoint(Vec2(0,0)); - _topRight->setAnchorPoint(Vec2(0,0)); - _left->setAnchorPoint(Vec2(0,0)); - _right->setAnchorPoint(Vec2(0,0)); - _top->setAnchorPoint(Vec2(0,0)); - _bottom->setAnchorPoint(Vec2(0,0)); - _centre->setAnchorPoint(Vec2(0,0)); - - // Position corners - _bottomLeft->setPosition(0,0); - _bottomRight->setPosition(leftWidth+rescaledWidth,0); - _topLeft->setPosition(0, bottomHeight+rescaledHeight); - _topRight->setPosition(leftWidth+rescaledWidth, bottomHeight+rescaledHeight); - - // Scale and position borders - _left->setPosition(0, bottomHeight); - _left->setScaleY(verticalScale); - _right->setPosition(leftWidth+rescaledWidth,bottomHeight); - _right->setScaleY(verticalScale); - _bottom->setPosition(leftWidth,0); - _bottom->setScaleX(horizontalScale); - _top->setPosition(leftWidth,bottomHeight+rescaledHeight); - _top->setScaleX(horizontalScale); - - // Position centre - _centre->setPosition(leftWidth, bottomHeight); -} - -bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets) -{ - SpriteBatchNode *batchnode = SpriteBatchNode::create(file, 9); - bool pReturn = this->initWithBatchNode(batchnode, rect, capInsets); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect, const Rect& capInsets) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithFile(file, rect, capInsets) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect) -{ - bool pReturn = this->initWithFile(file, rect, Rect::ZERO); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithFile(file, rect) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - - -bool Scale9Sprite::initWithFile(const Rect& capInsets, const std::string& file) -{ - bool pReturn = this->initWithFile(file, Rect::ZERO, capInsets); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const std::string& file) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithFile(capInsets, file) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -bool Scale9Sprite::initWithFile(const std::string& file) -{ - bool pReturn = this->initWithFile(file, Rect::ZERO); - return pReturn; - -} - -Scale9Sprite* Scale9Sprite::create(const std::string& file) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithFile(file) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets) -{ - Texture2D* texture = spriteFrame->getTexture(); - CCASSERT(texture != nullptr, "CCTexture must be not nil"); - - SpriteBatchNode *batchnode = SpriteBatchNode::createWithTexture(texture, 9); - CCASSERT(batchnode != nullptr, "CCSpriteBatchNode must be not nil"); - - bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), capInsets); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame, capInsets) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} -bool Scale9Sprite::initWithSpriteFrame(SpriteFrame* spriteFrame) -{ - CCASSERT(spriteFrame != nullptr, "Invalid spriteFrame for sprite"); - bool pReturn = this->initWithSpriteFrame(spriteFrame, Rect::ZERO); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets) -{ - CCASSERT((SpriteFrameCache::getInstance()) != nullptr, "SpriteFrameCache::getInstance() must be non-nullptr"); - - SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); - CCASSERT(frame != nullptr, "CCSpriteFrame must be non-nullptr"); - - if (nullptr == frame) return false; - - bool pReturn = this->initWithSpriteFrame(frame, capInsets); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName) -{ - bool pReturn = this->initWithSpriteFrameName(spriteFrameName, Rect::ZERO); - return pReturn; -} - -Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - - log("Could not allocate Scale9Sprite()"); - return nullptr; - -} - -Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets) -{ - Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite(); - if ( pReturn && pReturn->initWithBatchNode(_scale9Image, _spriteRect, capInsets) ) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -Scale9Sprite* Scale9Sprite::create() -{ - Scale9Sprite *pReturn = new (std::nothrow) Scale9Sprite(); - if (pReturn && pReturn->init()) - { - pReturn->autorelease(); - return pReturn; - } - CC_SAFE_DELETE(pReturn); - return nullptr; -} - -/** sets the opacity. - @warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed. - Values goes from 0 to 255, where 255 means fully opaque. - */ - -void Scale9Sprite::setPreferredSize(Size preferedSize) -{ - this->setContentSize(preferedSize); - this->_preferredSize = preferedSize; -} - -Size Scale9Sprite::getPreferredSize() -{ - return this->_preferredSize; -} - -void Scale9Sprite::setCapInsets(Rect capInsets) -{ - Size contentSize = this->_contentSize; - this->updateWithBatchNode(this->_scale9Image, this->_spriteRect, _spriteFrameRotated, capInsets); - this->setContentSize(contentSize); -} - -Rect Scale9Sprite::getCapInsets() -{ - return _capInsets; -} - -void Scale9Sprite::updateCapInset() -{ - Rect insets; - if (this->_insetLeft == 0 && this->_insetTop == 0 && this->_insetRight == 0 && this->_insetBottom == 0) - { - insets = Rect::ZERO; - } - else - { - insets = Rect(_insetLeft, - _insetTop, - _spriteRect.size.width-_insetLeft-_insetRight, - _spriteRect.size.height-_insetTop-_insetBottom); - } - this->setCapInsets(insets); -} - -void Scale9Sprite::setOpacityModifyRGB(bool var) -{ - if (!_scale9Image) - { - return; - } - _opacityModifyRGB = var; - - for(auto child : _scale9Image->getChildren()){ - child->setOpacityModifyRGB(_opacityModifyRGB); - } -} - -bool Scale9Sprite::isOpacityModifyRGB() const -{ - return _opacityModifyRGB; -} - -void Scale9Sprite::setSpriteFrame(SpriteFrame * spriteFrame) -{ - SpriteBatchNode * batchnode = SpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); - this->updateWithBatchNode(batchnode, spriteFrame->getRect(), spriteFrame->isRotated(), Rect::ZERO); - - // Reset insets - this->_insetLeft = 0; - this->_insetTop = 0; - this->_insetRight = 0; - this->_insetBottom = 0; -} - -float Scale9Sprite::getInsetLeft() -{ - return this->_insetLeft; -} - -float Scale9Sprite::getInsetTop() -{ - return this->_insetTop; -} - -float Scale9Sprite::getInsetRight() -{ - return this->_insetRight; -} - -float Scale9Sprite::getInsetBottom() -{ - return this->_insetBottom; -} - -void Scale9Sprite::setInsetLeft(float insetLeft) -{ - this->_insetLeft = insetLeft; - this->updateCapInset(); -} - -void Scale9Sprite::setInsetTop(float insetTop) -{ - this->_insetTop = insetTop; - this->updateCapInset(); -} - -void Scale9Sprite::setInsetRight(float insetRight) -{ - this->_insetRight = insetRight; - this->updateCapInset(); -} - -void Scale9Sprite::setInsetBottom(float insetBottom) -{ - this->_insetBottom = insetBottom; - this->updateCapInset(); -} - -void Scale9Sprite::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) -{ - if(this->_positionsAreDirty) - { - this->updatePositions(); - this->_positionsAreDirty = false; - } - Node::visit(renderer, parentTransform, parentFlags); -} - -void Scale9Sprite::setColor(const Color3B& color) -{ - if (!_scale9Image) - { - return; - } - - Node::setColor(color); - - for(auto child : _scale9Image->getChildren()){ - child->setColor(color); - } -} - -void Scale9Sprite::setOpacity(GLubyte opacity) -{ - if (!_scale9Image) - { - return; - } - Node::setOpacity(opacity); - - for(auto child : _scale9Image->getChildren()){ - child->setOpacity(opacity); - } -} - -void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor) -{ - if (!_scale9Image) - { - return; - } - Node::updateDisplayedColor(parentColor); - - for(auto child : _scale9Image->getChildren()){ - child->updateDisplayedColor(parentColor); - } -} - -void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity) -{ - if (!_scale9Image) - { - return; - } - Node::updateDisplayedOpacity(parentOpacity); - - for(auto child : _scale9Image->getChildren()){ - child->updateDisplayedOpacity(parentOpacity); - } -} - -NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCScale9Sprite.h b/extensions/GUI/CCControlExtension/CCScale9Sprite.h deleted file mode 100644 index fc1dea95ba..0000000000 --- a/extensions/GUI/CCControlExtension/CCScale9Sprite.h +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Created by Jung Sang-Taik on 12. 3. 16.. -Copyright (c) 2012 Neofect. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CCScale9Sprite_H__ -#define __CCScale9Sprite_H__ - -#include "2d/CCNode.h" -#include "2d/CCSpriteFrame.h" -#include "2d/CCSpriteBatchNode.h" -#include "extensions/ExtensionExport.h" -#include "../../ExtensionMacros.h" - -NS_CC_EXT_BEGIN - -/** - * @addtogroup GUI - * @{ - * @addtogroup control_extension - * @{ - */ - -/** - * A 9-slice sprite for cocos2d. - * - * 9-slice scaling allows you to specify how scaling is applied - * to specific areas of a sprite. With 9-slice scaling (3x3 grid), - * you can ensure that the sprite does not become distorted when - * scaled. - * - * @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html - */ -class CC_EX_DLL Scale9Sprite : public Node -{ -public: - /** - * @js ctor - */ - Scale9Sprite(); - /** - * @js NA - * @lua NA - */ - virtual ~Scale9Sprite(); - -public: - static Scale9Sprite* create(); - - /** - * Creates a 9-slice sprite with a texture file, a delimitation zone and - * with the specified cap insets. - * - * @see initWithFile(const char *file, const Rect& rect, const Rect& capInsets) - */ - static Scale9Sprite* create(const std::string& file, const Rect& rect, const Rect& capInsets); - - /** - * Creates a 9-slice sprite with a texture file. The whole texture will be - * broken down into a 3×3 grid of equal blocks. - * - * @see initWithFile(const Rect& capInsets, const char *file) - */ - static Scale9Sprite* create(const Rect& capInsets, const std::string& file); - - /** - * Creates a 9-slice sprite with a texture file and a delimitation zone. The - * texture will be broken down into a 3×3 grid of equal blocks. - * - * @see initWithFile(const char *file, const Rect& rect) - */ - static Scale9Sprite* create(const std::string& file, const Rect& rect); - - /** - * Creates a 9-slice sprite with a texture file. The whole texture will be - * broken down into a 3×3 grid of equal blocks. - * - * @see initWithFile(const char *file) - */ - static Scale9Sprite* create(const std::string& file); - - /** - * Creates a 9-slice sprite with an sprite frame. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @see initWithSpriteFrame(SpriteFrame *spriteFrame) - */ - static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame); - - /** - * Creates a 9-slice sprite with an sprite frame and the centre of its zone. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @see initWithSpriteFrame(SpriteFrame *spriteFrame, const Rect& capInsets) - */ - static Scale9Sprite* createWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets); - - /** - * Creates a 9-slice sprite with an sprite frame name. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @see initWithSpriteFrameName(const char *spriteFrameName) - */ - static Scale9Sprite* createWithSpriteFrameName(const std::string& spriteFrameName); - - /** - * Creates a 9-slice sprite with an sprite frame name and the centre of its - * zone. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @see initWithSpriteFrameName(const char *spriteFrameName, const Rect& capInsets) - */ - static Scale9Sprite* createWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets); - - /** - * Initializes a 9-slice sprite with a texture file, a delimitation zone and - * with the specified cap insets. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param file The name of the texture file. - * @param rect The rectangle that describes the sub-part of the texture that - * is the whole image. If the shape is the whole texture, set this to the - * texture's full rect. - * @param capInsets The values to use for the cap insets. - */ - virtual bool initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets); - - /** - * Initializes a 9-slice sprite with a texture file and a delimitation zone. The - * texture will be broken down into a 3×3 grid of equal blocks. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param file The name of the texture file. - * @param rect The rectangle that describes the sub-part of the texture that - * is the whole image. If the shape is the whole texture, set this to the - * texture's full rect. - */ - virtual bool initWithFile(const std::string& file, const Rect& rect); - - /** - * Initializes a 9-slice sprite with a texture file and with the specified cap - * insets. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param file The name of the texture file. - * @param capInsets The values to use for the cap insets. - */ - virtual bool initWithFile(const Rect& capInsets, const std::string& file); - - /** - * Initializes a 9-slice sprite with a texture file. The whole texture will be - * broken down into a 3×3 grid of equal blocks. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param file The name of the texture file. - */ - virtual bool initWithFile(const std::string& file); - - /** - * Initializes a 9-slice sprite with an sprite frame and with the specified - * cap insets. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param spriteFrame The sprite frame object. - * @param capInsets The values to use for the cap insets. - */ - virtual bool initWithSpriteFrame(SpriteFrame* spriteFrame, const Rect& capInsets); - - /** - * Initializes a 9-slice sprite with an sprite frame. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param spriteFrame The sprite frame object. - */ - virtual bool initWithSpriteFrame(SpriteFrame* spriteFrame); - - /** - * Initializes a 9-slice sprite with an sprite frame name and with the specified - * cap insets. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param spriteFrameName The sprite frame name. - * @param capInsets The values to use for the cap insets. - */ - virtual bool initWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets); - - /** - * Initializes a 9-slice sprite with an sprite frame name. - * Once the sprite is created, you can then call its "setContentSize:" method - * to resize the sprite will all it's 9-slice goodness intract. - * It respects the anchorPoint too. - * - * @param spriteFrameName The sprite frame name. - */ - virtual bool initWithSpriteFrameName(const std::string& spriteFrameName); - - virtual bool init(); - virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets); - virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, const Rect& capInsets); - - /** - * Creates and returns a new sprite object with the specified cap insets. - * You use this method to add cap insets to a sprite or to change the existing - * cap insets of a sprite. In both cases, you get back a new image and the - * original sprite remains untouched. - * - * @param capInsets The values to use for the cap insets. - */ - Scale9Sprite* resizableSpriteWithCapInsets(const Rect& capInsets); - - virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets); - virtual void setSpriteFrame(SpriteFrame * spriteFrame); - - // overrides - virtual void setContentSize(const Size & size) override; - /** - * @js NA - * @lua NA - */ - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; - virtual void setOpacityModifyRGB(bool bValue) override; - virtual bool isOpacityModifyRGB(void) const override; - virtual void setOpacity(GLubyte opacity) override; - virtual void setColor(const Color3B& color) override; - virtual void updateDisplayedOpacity(GLubyte parentOpacity) override; - virtual void updateDisplayedColor(const Color3B& parentColor) override; - -protected: - void updateCapInset(); - void updatePositions(); - - bool _spritesGenerated; - Rect _spriteRect; - bool _spriteFrameRotated; - Rect _capInsetsInternal; - bool _positionsAreDirty; - - SpriteBatchNode* _scale9Image; - Sprite* _topLeft; - Sprite* _top; - Sprite* _topRight; - Sprite* _left; - Sprite* _centre; - Sprite* _right; - Sprite* _bottomLeft; - Sprite* _bottom; - Sprite* _bottomRight; - - bool _opacityModifyRGB; - - /** Original sprite's size. */ - CC_SYNTHESIZE_READONLY(Size, _originalSize, OriginalSize); - /** Prefered sprite's size. By default the prefered size is the original size. */ - - //if the preferredSize component is given as -1, it is ignored - CC_PROPERTY(Size, _preferredSize, PreferredSize); - /** - * The end-cap insets. - * On a non-resizeable sprite, this property is set to CGRect::ZERO; the sprite - * does not use end caps and the entire sprite is subject to stretching. - */ - CC_PROPERTY(Rect, _capInsets, CapInsets); - /** Sets the left side inset */ - CC_PROPERTY(float, _insetLeft, InsetLeft); - /** Sets the top side inset */ - CC_PROPERTY(float, _insetTop, InsetTop); - /** Sets the right side inset */ - CC_PROPERTY(float, _insetRight, InsetRight); - /** Sets the bottom side inset */ - CC_PROPERTY(float, _insetBottom, InsetBottom); -}; - -// end of GUI group -/// @} -/// @} - -NS_CC_EXT_END - -#endif // __CCScale9Sprite_H__ diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h deleted file mode 100644 index 9203cbfaac..0000000000 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ /dev/null @@ -1,452 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2012 James Chen - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCEDITTEXT_H__ -#define __CCEDITTEXT_H__ - -#include "base/CCIMEDelegate.h" -#include "extensions/ExtensionMacros.h" -#include "../CCControlExtension/CCControlExtensions.h" -#include "extensions/ExtensionExport.h" - -NS_CC_EXT_BEGIN - -class EditBox; -class EditBoxImpl; - - -class CC_EX_DLL EditBoxDelegate -{ -public: - /** - * @js NA - * @lua NA - */ - virtual ~EditBoxDelegate() {}; - - /** - * This method is called when an edit box gains focus after keyboard is shown. - * @param editBox The edit box object that generated the event. - * @js NA - * @lua NA - */ - virtual void editBoxEditingDidBegin(EditBox* editBox) {}; - - - /** - * This method is called when an edit box loses focus after keyboard is hidden. - * @param editBox The edit box object that generated the event. - * @js NA - * @lua NA - */ - virtual void editBoxEditingDidEnd(EditBox* editBox) {}; - - /** - * This method is called when the edit box text was changed. - * @param editBox The edit box object that generated the event. - * @param text The new text. - * @js NA - * @lua NA - */ - virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) {}; - - /** - * This method is called when the return button was pressed or the outside area of keyboard was touched. - * @param editBox The edit box object that generated the event. - * @js NA - * @lua NA - */ - virtual void editBoxReturn(EditBox* editBox) = 0; - -}; - -/** - * \brief Class for edit box. - * - * You can use this widget to gather small amounts of text from the user. - * - */ - -class CC_EX_DLL EditBox -: public ControlButton -, public IMEDelegate -{ -public: - enum class KeyboardReturnType - { - DEFAULT, - DONE, - SEND, - SEARCH, - GO - }; - - /** - * \brief The EditBox::InputMode defines the type of text that the user is allowed - * to enter. - */ - enum class InputMode - { - /** - * The user is allowed to enter any text, including line breaks. - */ - ANY, - - /** - * The user is allowed to enter an e-mail address. - */ - EMAIL_ADDRESS, - - /** - * The user is allowed to enter an integer value. - */ - NUMERIC, - - /** - * The user is allowed to enter a phone number. - */ - PHONE_NUMBER, - - /** - * The user is allowed to enter a URL. - */ - URL, - - /** - * The user is allowed to enter a real number value. - * This extends kEditBoxInputModeNumeric by allowing a decimal point. - */ - DECIMAL, - - /** - * The user is allowed to enter any text, except for line breaks. - */ - SINGLE_LINE, - }; - - /** - * \brief The EditBox::InputFlag defines how the input text is displayed/formatted. - */ - enum class InputFlag - { - /** - * Indicates that the text entered is confidential data that should be - * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. - */ - PASSWORD, - - /** - * Indicates that the text entered is sensitive data that the - * implementation must never store into a dictionary or table for use - * in predictive, auto-completing, or other accelerated input schemes. - * A credit card number is an example of sensitive data. - */ - SENSITIVE, - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each word should be capitalized. - */ - INITIAL_CAPS_WORD, - - /** - * This flag is a hint to the implementation that during text editing, - * the initial letter of each sentence should be capitalized. - */ - INITIAL_CAPS_SENTENCE, - - /** - * Capitalize all characters automatically. - */ - INTIAL_CAPS_ALL_CHARACTERS, - }; - - /** - * create a edit box with size. - * @return An autorelease pointer of EditBox, you don't need to release it only if you retain it again. - */ - static EditBox* create(const Size& size, Scale9Sprite* pNormal9SpriteBg, Scale9Sprite* pPressed9SpriteBg = NULL, Scale9Sprite* pDisabled9SpriteBg = NULL); - - /** - * Constructor. - * @js ctor - */ - EditBox(void); - - /** - * Destructor. - * @js NA - * @lua NA - */ - virtual ~EditBox(void); - - /** - * Init edit box with specified size. This method should be invoked right after constructor. - * @param size The size of edit box. - */ - bool initWithSizeAndBackgroundSprite(const Size& size, Scale9Sprite* pNormal9SpriteBg); - - /** - * Gets/Sets the delegate for edit box. - * @lua NA - */ - void setDelegate(EditBoxDelegate* pDelegate); - /** - * @js NA - * @lua NA - */ - EditBoxDelegate* getDelegate(); - -#if CC_ENABLE_SCRIPT_BINDING - /** - * Registers a script function that will be called for EditBox events. - * - * This handler will be removed automatically after onExit() called. - * @code - * -- lua sample - * local function editboxEventHandler(eventType) - * if eventType == "began" then - * -- triggered when an edit box gains focus after keyboard is shown - * elseif eventType == "ended" then - * -- triggered when an edit box loses focus after keyboard is hidden. - * elseif eventType == "changed" then - * -- triggered when the edit box text was changed. - * elseif eventType == "return" then - * -- triggered when the return button was pressed or the outside area of keyboard was touched. - * end - * end - * - * local editbox = EditBox:create(Size(...), Scale9Sprite:create(...)) - * editbox = registerScriptEditBoxHandler(editboxEventHandler) - * @endcode - * - * @param handler A number that indicates a lua function. - * @js NA - * @lua NA - */ - void registerScriptEditBoxHandler(int handler); - - /** - * Unregisters a script function that will be called for EditBox events. - * @js NA - * @lua NA - */ - void unregisterScriptEditBoxHandler(void); - /** - * get a script Handler - * @js NA - * @lua NA - */ - int getScriptEditBoxHandler(void){ return _scriptEditBoxHandler ;} - -#endif // #if CC_ENABLE_SCRIPT_BINDING - - /** - * Set the text entered in the edit box. - * @param pText The given text. - */ - void setText(const char* pText); - - /** - * Get the text entered in the edit box. - * @return The text entered in the edit box. - */ - const char* getText(void); - - /** - * Set the font. - * @param pFontName The font name. - * @param fontSize The font size. - */ - void setFont(const char* pFontName, int fontSize); - - /** - * Set the font name. - * @param pFontName The font name. - */ - void setFontName(const char* pFontName); - - /** - * Set the font size. - * @param fontSize The font size. - */ - void setFontSize(int fontSize); - - /** - * Set the font color of the widget's text. - */ - void setFontColor(const Color3B& color); - - /** - * Set the placeholder's font. - * @param pFontName The font name. - * @param fontSize The font size. - */ - void setPlaceholderFont(const char* pFontName, int fontSize); - - /** - * Set the placeholder's font name. - * @param pFontName The font name. - */ - void setPlaceholderFontName(const char* pFontName); - - /** - * Set the placeholder's font size. - * @param fontSize The font size. - */ - void setPlaceholderFontSize(int fontSize); - - /** - * Set the font color of the placeholder text when the edit box is empty. - * Not supported on IOS. - */ - void setPlaceholderFontColor(const Color3B& color); - - /** - * Set a text in the edit box that acts as a placeholder when an - * edit box is empty. - * @param pText The given text. - */ - void setPlaceHolder(const char* pText); - - /** - * Get a text in the edit box that acts as a placeholder when an - * edit box is empty. - */ - const char* getPlaceHolder(void); - - /** - * Set the input mode of the edit box. - * @param inputMode One of the EditBox::InputMode constants. - */ - void setInputMode(InputMode inputMode); - - /** - * Sets the maximum input length of the edit box. - * Setting this value enables multiline input mode by default. - * Available on Android, iOS and Windows Phone. - * - * @param maxLength The maximum length. - */ - void setMaxLength(int maxLength); - - /** - * Gets the maximum input length of the edit box. - * - * @return Maximum input length. - */ - int getMaxLength(); - - /** - * Set the input flags that are to be applied to the edit box. - * @param inputFlag One of the EditBox::InputFlag constants. - */ - void setInputFlag(InputFlag inputFlag); - - /** - * Set the return type that are to be applied to the edit box. - * @param returnType One of the EditBox::KeyboardReturnType constants. - */ - void setReturnType(EditBox::KeyboardReturnType returnType); - - /* override functions */ - virtual void setPosition(const Vec2& pos) override; - virtual void setVisible(bool visible) override; - virtual void setContentSize(const Size& size) override; - virtual void setAnchorPoint(const Vec2& anchorPoint) override; - /** - * @js NA - * @lua NA - */ - virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; - /** - * @js NA - * @lua NA - */ - virtual void onEnter(void) override; - /** - * @js NA - * @lua NA - */ - virtual void onExit(void) override; - /** - * @js NA - * @lua NA - */ - virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) override; - /** - * @js NA - * @lua NA - */ - virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) override; - /** - * @js NA - * @lua NA - */ - virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) override; - /** - * @js NA - * @lua NA - */ - virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override; - - /* callback funtions - * @js NA - * @lua NA - */ - void touchDownAction(Ref *sender, Control::EventType controlEvent); - -protected: - void updatePosition(float dt); - EditBoxImpl* _editBoxImpl; - EditBoxDelegate* _delegate; - - InputMode _editBoxInputMode; - InputFlag _editBoxInputFlag; - EditBox::KeyboardReturnType _keyboardReturnType; - - std::string _text; - std::string _placeHolder; - - std::string _fontName; - std::string _placeholderFontName; - - int _fontSize; - int _placeholderFontSize; - - Color3B _colText; - Color3B _colPlaceHolder; - - int _maxLength; - float _adjustHeight; -#if CC_ENABLE_SCRIPT_BINDING - int _scriptEditBoxHandler; -#endif -}; - -NS_CC_EXT_END - -#endif /* __CCEDITTEXT_H__ */ - diff --git a/extensions/GUI/CCEditBox/CCEditBoxImpl.h b/extensions/GUI/CCEditBox/CCEditBoxImpl.h deleted file mode 100644 index 79d3d8f3fa..0000000000 --- a/extensions/GUI/CCEditBox/CCEditBoxImpl.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2012 James Chen - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __CCEditBoxIMPL_H__ -#define __CCEditBoxIMPL_H__ - -#include "extensions/ExtensionMacros.h" -#include "CCEditBox.h" -#include "extensions/ExtensionExport.h" - -NS_CC_EXT_BEGIN - - -class CC_EX_DLL EditBoxImpl -{ -public: - /** - * @js NA - */ - EditBoxImpl(EditBox* pEditBox) : _delegate(nullptr),_editBox(pEditBox) {} - /** - * @js NA - * @lua NA - */ - virtual ~EditBoxImpl() {} - - virtual bool initWithSize(const Size& size) = 0; - virtual void setFont(const char* pFontName, int fontSize) = 0; - virtual void setFontColor(const Color3B& color) = 0; - virtual void setPlaceholderFont(const char* pFontName, int fontSize) = 0; - virtual void setPlaceholderFontColor(const Color3B& color) = 0; - virtual void setInputMode(EditBox::InputMode inputMode) = 0; - virtual void setInputFlag(EditBox::InputFlag inputFlag) = 0; - virtual void setMaxLength(int maxLength) = 0; - virtual int getMaxLength() = 0; - virtual void setReturnType(EditBox::KeyboardReturnType returnType) = 0; - virtual bool isEditing() = 0; - - virtual void setText(const char* pText) = 0; - virtual const char* getText(void) = 0; - virtual void setPlaceHolder(const char* pText) = 0; - virtual void doAnimationWhenKeyboardMove(float duration, float distance) = 0; - - virtual void openKeyboard() = 0; - virtual void closeKeyboard() = 0; - - virtual void setPosition(const Vec2& pos) = 0; - virtual void setVisible(bool visible) = 0; - virtual void setContentSize(const Size& size) = 0; - virtual void setAnchorPoint(const Vec2& anchorPoint) = 0; - - /** - * check the editbox's position, update it when needed - */ - virtual void updatePosition(float dt){}; - /** - * @js NA - * @lua NA - */ - virtual void visit(void) = 0; - /** - * @js NA - * @lua NA - */ - virtual void onEnter(void) = 0; - - - void setDelegate(EditBoxDelegate* pDelegate) { _delegate = pDelegate; }; - EditBoxDelegate* getDelegate() { return _delegate; }; - EditBox* getEditBox() { return _editBox; }; -protected: - EditBoxDelegate* _delegate; - EditBox* _editBox; -}; - -// This method must be implemented at each subclass of EditBoxImpl. -extern EditBoxImpl* __createSystemEditBox(EditBox* pEditBox); - - -NS_CC_EXT_END - -#endif /* __CCEditBoxIMPL_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h deleted file mode 100644 index 4513ec6dfd..0000000000 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -Copyright (c) 2014 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __CCEditBoxIMPLWP8_H__ -#define __CCEditBoxIMPLWP8_H__ - -#include "ExtensionMacros.h" -#include "CCEditBoxImpl.h" - -NS_CC_EXT_BEGIN - -class CCEditBox; - -class CCEditBoxImplWp8 : public EditBoxImpl -{ -public: - CCEditBoxImplWp8(EditBox* pEditText); - virtual ~CCEditBoxImplWp8(); - - virtual bool initWithSize(const Size& size); - virtual void setFont(const char* pFontName, int fontSize); - virtual void setFontColor(const Color3B& color); - virtual void setPlaceholderFont(const char* pFontName, int fontSize); - virtual void setPlaceholderFontColor(const Color3B& color); - virtual void setInputMode(EditBox::InputMode inputMode); - virtual void setInputFlag(EditBox::InputFlag inputFlag); - virtual void setMaxLength(int maxLength); - virtual int getMaxLength(); - virtual void setReturnType(EditBox::KeyboardReturnType returnType); - virtual bool isEditing(); - - virtual void setText(const char* pText); - virtual const char* getText(void); - virtual void setPlaceHolder(const char* pText); - virtual void setPosition(const Vec2& pos); - virtual void setVisible(bool visible); - virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Vec2& anchorPoint); - virtual void visit(void); - virtual void doAnimationWhenKeyboardMove(float duration, float distance); - virtual void openKeyboard(); - virtual void closeKeyboard(); - virtual void onEnter(void); -private: - Platform::String^ stringToPlatformString(std::string strSrc); - std::string PlatformStringTostring(Platform::String^ strSrc); -private: - - Label* m_pLabel; - Label* m_pLabelPlaceHolder; - EditBox::InputMode m_eEditBoxInputMode; - EditBox::InputFlag m_eEditBoxInputFlag; - (EditBox::KeyboardReturnType m_eKeyboardReturnType; - - std::string m_strText; - std::string m_strPlaceHolder; - - Color3B m_colText; - Color3B m_colPlaceHolder; - - int m_nMaxLength; - Size m_EditSize; -}; - -NS_CC_EXT_END - -#endif diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index a204f40e43..6f742b7046 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -7,12 +7,12 @@ #include "GUI/CCControlExtension/CCControlExtensions.h" #include "GUI/CCScrollView/CCScrollView.h" #include "GUI/CCScrollView/CCTableView.h" -#include "GUI/CCEditBox/CCEditBox.h" // Physics integration #include "physics-nodes/CCPhysicsDebugNode.h" #include "physics-nodes/CCPhysicsSprite.h" #include "assets-manager/AssetsManager.h" +#include "ExtensionDeprecated.h" #endif /* __COCOS2D_EXT_H__ */ diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 25d6d414cb..fce55eac65 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -764,7 +764,6 @@ "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java", "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java", "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java", - "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java", "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java", "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java", "cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java", @@ -997,6 +996,20 @@ "cocos/ui/UICheckBox.h", "cocos/ui/UIDeprecated.cpp", "cocos/ui/UIDeprecated.h", + "cocos/ui/UIEditBox/UIEditBox.cpp", + "cocos/ui/UIEditBox/UIEditBox.h", + "cocos/ui/UIEditBox/UIEditBoxImpl.h", + "cocos/ui/UIEditBox/UIEditBoxImplAndroid.cpp", + "cocos/ui/UIEditBox/UIEditBoxImplAndroid.h", + "cocos/ui/UIEditBox/UIEditBoxImplIOS.h", + "cocos/ui/UIEditBox/UIEditBoxImplIOS.mm", + "cocos/ui/UIEditBox/UIEditBoxImplMac.h", + "cocos/ui/UIEditBox/UIEditBoxImplMac.mm", + "cocos/ui/UIEditBox/UIEditBoxImplNone.cpp", + "cocos/ui/UIEditBox/UIEditBoxImplWin.cpp", + "cocos/ui/UIEditBox/UIEditBoxImplWin.h", + "cocos/ui/UIEditBox/UIEditBoxImplWp8.cpp", + "cocos/ui/UIEditBox/UIEditBoxImplWp8.h", "cocos/ui/UIHBox.cpp", "cocos/ui/UIHBox.h", "cocos/ui/UIHelper.cpp", @@ -1048,6 +1061,10 @@ "cocos/ui/UIWebViewImpl_iOS.mm", "cocos/ui/UIWidget.cpp", "cocos/ui/UIWidget.h", + "cocos/ui/proj.win32/Win32InputBox.cpp", + "cocos/ui/proj.win32/Win32InputBox.h", + "cocos/ui/proj.win32/libui.vcxproj", + "cocos/ui/proj.win32/libui.vcxproj.filters", "cocos/ui/proj.wp8/libGUI.vcxproj", "cocos/ui/proj.wp8/libGUI.vcxproj.filters", "docs/CODING_STYLE.md", @@ -1058,7 +1075,8 @@ "docs/doxygen.config", "download-deps.py", "extensions/Android.mk", - "extensions/CMakeLists.txt", + "extensions/ExtensionDeprecated.cpp", + "extensions/ExtensionDeprecated.h", "extensions/ExtensionExport.h", "extensions/ExtensionMacros.h", "extensions/GUI/CCControlExtension/CCControl.cpp", @@ -1084,22 +1102,6 @@ "extensions/GUI/CCControlExtension/CCControlUtils.h", "extensions/GUI/CCControlExtension/CCInvocation.cpp", "extensions/GUI/CCControlExtension/CCInvocation.h", - "extensions/GUI/CCControlExtension/CCScale9Sprite.cpp", - "extensions/GUI/CCControlExtension/CCScale9Sprite.h", - "extensions/GUI/CCEditBox/CCEditBox.cpp", - "extensions/GUI/CCEditBox/CCEditBox.h", - "extensions/GUI/CCEditBox/CCEditBoxImpl.h", - "extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp", - "extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h", - "extensions/GUI/CCEditBox/CCEditBoxImplIOS.h", - "extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm", - "extensions/GUI/CCEditBox/CCEditBoxImplMac.h", - "extensions/GUI/CCEditBox/CCEditBoxImplMac.mm", - "extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp", - "extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp", - "extensions/GUI/CCEditBox/CCEditBoxImplWin.h", - "extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp", - "extensions/GUI/CCEditBox/CCEditBoxImplWp8.h", "extensions/GUI/CCScrollView/CCScrollView.cpp", "extensions/GUI/CCScrollView/CCScrollView.h", "extensions/GUI/CCScrollView/CCTableView.cpp", @@ -3694,7 +3696,6 @@ "cocos/scripting/lua-bindings/auto/api/EaseSineIn.lua", "cocos/scripting/lua-bindings/auto/api/EaseSineInOut.lua", "cocos/scripting/lua-bindings/auto/api/EaseSineOut.lua", - "cocos/scripting/lua-bindings/auto/api/EditBox.lua", "cocos/scripting/lua-bindings/auto/api/Event.lua", "cocos/scripting/lua-bindings/auto/api/EventAcceleration.lua", "cocos/scripting/lua-bindings/auto/api/EventController.lua", @@ -4029,6 +4030,8 @@ "cocos/scripting/lua-bindings/manual/cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h", "cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp", "cocos/scripting/lua-bindings/manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h", + "cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.cpp", + "cocos/scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h", "cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp", "cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.hpp", "cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.cpp", diff --git a/templates/cpp-template-default/proj.android/README.md b/templates/cpp-template-default/proj.android/README.md deleted file mode 100644 index ff6c44369c..0000000000 --- a/templates/cpp-template-default/proj.android/README.md +++ /dev/null @@ -1,36 +0,0 @@ -## Prerequisites: - -* Android NDK -* Android SDK **OR** Eclipse ADT Bundle -* Android AVD target installed - -## Building project - -There are two ways of building Android projects. - -1. Eclipse -2. Command Line - -### Import Project in Eclipse - -####Step 1: C/C++ Environment Variable `NDK_ROOT` - -* Eclipse->Preferences->C/C++->Build->**Environment**. -* Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) -* Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -####Step 2: Adding and running from Eclipse - -![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) - -1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory and Add the project -3. Click **Run as Android Application** to run on connected device or emulator. - -That's all !!! - -### Running project from Command Line - - $ cd NEW_PROJECTS_DIR/MyGame - $ cocos run -p android -j 4 diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp index 2bbc729319..8bd26e143a 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -65,12 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching() auto engine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); lua_State* L = engine->getLuaStack()->getLuaState(); - lua_getglobal(L, "_G"); - if (lua_istable(L,-1))//stack:...,_G, - { - lua_module_register(L); - } - lua_pop(L, 1);//statck:... + lua_module_register(L); LuaStack* stack = engine->getLuaStack(); stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA")); diff --git a/tests/cpp-empty-test/proj.android/README.md b/tests/cpp-empty-test/proj.android/README.md deleted file mode 100644 index 312835611a..0000000000 --- a/tests/cpp-empty-test/proj.android/README.md +++ /dev/null @@ -1,87 +0,0 @@ -## Prerequisites: - -* Android NDK -* Android SDK **OR** Eclipse ADT Bundle -* Android AVD target installed - -## Building project - -There are two ways of building Android projects. - -1. Eclipse -2. Command Line - -### Import Project in Eclipse - -#### Features: - -1. Complete workflow from Eclipse, including: - * Build C++. - * Clean C++. - * Build and Run whole project. - * Logcat view. - * Debug Java code. - * Javascript editor. - * Project management. -2. True C++ editing, including: - * Code completion. - * Jump to definition. - * Refactoring tools etc. - * Quick open C++ files. - - -#### Setup Eclipse Environment (only once) - - -**NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. - -1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) - - **OR** - - Install Eclipse with Java. Add ADT and CDT plugins. - -2. Only for Windows - 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). - 2. Add `Cygwin\bin` directory to system PATH variable. - 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. - -3. Set up Variables: - 1. Path Variable `COCOS2DX`: - * Eclipse->Preferences->General->Workspace->**Linked Resources** - * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. - ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) - - 2. C/C++ Environment Variable `NDK_ROOT`: - * Eclipse->Preferences->C/C++->Build->**Environment**. - * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) - * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -4. Import libcocos2dx library project: - 1. File->New->Project->Android Project From Existing Code. - 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. - 3. Click **Finish** to add project. - -#### Adding and running from Eclipse - -![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) - -1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/` -3. Add the project -4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. - - -### Running project from Command Line - - $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ - $ export NDK_ROOT=/path/to/ndk - $ ./build_native.sh - $ ant debug install - -If the last command results in sdk.dir missing error then do: - - $ android list target - $ android update project -p . -t (id from step 6) - $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) diff --git a/tests/cpp-tests/Android.mk b/tests/cpp-tests/Android.mk index 71ff77954d..dba250329b 100644 --- a/tests/cpp-tests/Android.mk +++ b/tests/cpp-tests/Android.mk @@ -70,6 +70,7 @@ Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp \ Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp \ Classes/UITest/CocoStudioGUITest/UIScene.cpp \ Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp \ +Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp \ Classes/UITest/CocoStudioGUITest/UISceneManager.cpp \ Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp \ Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp \ @@ -123,12 +124,10 @@ Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControl Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ -Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp \ Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp \ Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp \ Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ -Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ Classes/FileUtilsTest/FileUtilsTest.cpp \ diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index d86b9d7bc4..815cfb7e43 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -2,7 +2,6 @@ set(APP_NAME cpp-tests) if(WIN32) set(PLATFORM_SRC - Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp proj.win32/main.cpp @@ -124,7 +123,6 @@ set(SAMPLE_SRC Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp - Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp Classes/NewRendererTest/NewRendererTest.cpp Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp Classes/FontTest/FontTest.cpp diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 2fef6f9aa3..6981d7c7aa 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -91,8 +91,8 @@ bool ControlButtonTest_HelloVariableSize::init() ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title) { /** Creates and return a button with a default background and title color. */ - auto backgroundButton = Scale9Sprite::create("extensions/button.png"); - auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); + auto backgroundButton = cocos2d::extension::Scale9Sprite::create("extensions/button.png"); + auto backgroundHighlightedButton = cocos2d::extension::Scale9Sprite::create("extensions/buttonHighlighted.png"); auto titleButton = Label::createWithTTF(title, "fonts/Marker Felt.ttf", 30); @@ -258,7 +258,7 @@ bool ControlButtonTest_Styling::init() layer->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f); // Add the black background - auto backgroundButton = Scale9Sprite::create("extensions/buttonBackground.png"); + auto backgroundButton = cocos2d::extension::Scale9Sprite::create("extensions/buttonBackground.png"); backgroundButton->setContentSize(Size(max_w + 14, max_h + 14)); backgroundButton->setPosition(screenSize.width / 2.0f, screenSize.height / 2.0f); addChild(backgroundButton); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp deleted file mode 100644 index ccb0ef030a..0000000000 --- a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// -// EditBoxTest.cpp -// TestCpp -// -// Created by James on 8/14/12. -// -// - -#include "EditBoxTest.h" -#include "../ExtensionsTest.h" - -USING_NS_CC; -USING_NS_CC_EXT; - - -EditBoxTest::EditBoxTest() -{ - auto glview = Director::getInstance()->getOpenGLView(); - auto visibleOrigin = glview->getVisibleOrigin(); - auto visibleSize = glview->getVisibleSize(); - - auto pBg = Sprite::create("Images/HelloWorld.png"); - pBg->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2); - addChild(pBg); - - _TTFShowEditReturn = Label::createWithSystemFont("No edit control return!", "", 30); - _TTFShowEditReturn->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50); - addChild(_TTFShowEditReturn); - - // Back Menu - auto itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(EditBoxTest::toExtensionsMainLayer, this)); - itemBack->setPosition(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25); - auto menuBack = Menu::create(itemBack, nullptr); - menuBack->setPosition(Vec2::ZERO); - addChild(menuBack); - - auto editBoxSize = Size(visibleSize.width - 100, 60); - - // top - _editName = EditBox::create(editBoxSize, Scale9Sprite::create("extensions/green_edit.png")); - _editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); - _editName->setFontName("Paint Boy"); - _editName->setFontSize(25); - _editName->setFontColor(Color3B::RED); - _editName->setPlaceHolder("Name:"); - _editName->setPlaceholderFontColor(Color3B::WHITE); - _editName->setMaxLength(8); - _editName->setReturnType(EditBox::KeyboardReturnType::DONE); - _editName->setDelegate(this); - addChild(_editName); - - // middle - _editPassword = EditBox::create(editBoxSize, Scale9Sprite::create("extensions/orange_edit.png")); - _editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - _editPassword->setFont("American Typewriter", 30); -#else - _editPassword->setFont("American Typewriter", 80); - _editPassword->setPlaceholderFont("American Typewriter", 80); -#endif - _editPassword->setFontColor(Color3B::GREEN); - _editPassword->setPlaceHolder("Password:"); - _editPassword->setMaxLength(6); - _editPassword->setInputFlag(EditBox::InputFlag::PASSWORD); - _editPassword->setInputMode(EditBox::InputMode::SINGLE_LINE); - _editPassword->setDelegate(this); - addChild(_editPassword); - - // bottom - _editEmail = EditBox::create(Size(editBoxSize.width, editBoxSize.height), Scale9Sprite::create("extensions/yellow_edit.png")); - _editEmail->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); - _editEmail->setAnchorPoint(Vec2(0.5, 1.0f)); - _editEmail->setPlaceHolder("Email:"); - _editEmail->setInputMode(EditBox::InputMode::EMAIL_ADDRESS); - _editEmail->setDelegate(this); - addChild(_editEmail); - - this->setPosition(10, 20); -} - -EditBoxTest::~EditBoxTest() -{ - -} - -void EditBoxTest::toExtensionsMainLayer(cocos2d::Ref *sender) -{ - auto scene = new (std::nothrow) ExtensionsTestScene(); - scene->runThisTest(); - scene->release(); -} - -void EditBoxTest::editBoxEditingDidBegin(cocos2d::extension::EditBox* editBox) -{ - log("editBox %p DidBegin !", editBox); -} - -void EditBoxTest::editBoxEditingDidEnd(cocos2d::extension::EditBox* editBox) -{ - log("editBox %p DidEnd !", editBox); -} - -void EditBoxTest::editBoxTextChanged(cocos2d::extension::EditBox* editBox, const std::string& text) -{ - log("editBox %p TextChanged, text: %s ", editBox, text.c_str()); -} - -void EditBoxTest::editBoxReturn(EditBox* editBox) -{ - log("editBox %p was returned !",editBox); - - if (_editName == editBox) - { - _TTFShowEditReturn->setString("Name EditBox return !"); - } - else if (_editPassword == editBox) - { - _TTFShowEditReturn->setString("Password EditBox return !"); - } - else if (_editEmail == editBox) - { - _TTFShowEditReturn->setString("Email EditBox return !"); - } -} - -void runEditBoxTest() -{ - auto scene = Scene::create(); - EditBoxTest *layer = new (std::nothrow) EditBoxTest(); - scene->addChild(layer); - - Director::getInstance()->replaceScene(scene); - layer->release(); -} diff --git a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h b/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h deleted file mode 100644 index 3cef026dbd..0000000000 --- a/tests/cpp-tests/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// EditBoxTest.h -// TestCpp -// -// Created by James on 8/14/12. -// -// - -#ifndef __TestCpp__CCEditBoxTest__ -#define __TestCpp__CCEditBoxTest__ - -#include "cocos2d.h" -#include "extensions/cocos-ext.h" - -class EditBoxTest : public cocos2d::Layer, public cocos2d::extension::EditBoxDelegate -{ -public: - EditBoxTest(); - virtual ~EditBoxTest(); - void toExtensionsMainLayer(cocos2d::Ref *sender); - - virtual void editBoxEditingDidBegin(cocos2d::extension::EditBox* editBox); - virtual void editBoxEditingDidEnd(cocos2d::extension::EditBox* editBox); - virtual void editBoxTextChanged(cocos2d::extension::EditBox* editBox, const std::string& text); - virtual void editBoxReturn(cocos2d::extension::EditBox* editBox); -private: - cocos2d::Label* _TTFShowEditReturn; - cocos2d::extension::EditBox* _editName; - cocos2d::extension::EditBox* _editPassword; - cocos2d::extension::EditBox* _editEmail; -}; - -void runEditBoxTest(); - -#endif /* defined(__TestCpp__CCEditBoxTest__) */ diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp index 3a09e2da85..10d31a2900 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -18,11 +18,6 @@ #include "NetworkTest/SocketIOTest.h" #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) -#include "EditBoxTest/EditBoxTest.h" -#endif - -#include "Scale9SpriteTest/Scale9SpriteTest.h" enum { @@ -36,15 +31,6 @@ static struct { } g_extensionsTests[] = { { "NotificationCenterTest", [](Ref* sender) { runNotificationCenterTest(); } }, - { "Scale9SpriteTest", [](Ref* sender) { - auto scene = new (std::nothrow) S9SpriteTestScene(); - if (scene) - { - scene->runThisTest(); - scene->release(); - } - } - }, { "CCControlButtonTest", [](Ref *sender){ ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager(); auto scene = pManager->currentControlScene(); @@ -68,10 +54,7 @@ static struct { { "SocketIOTest", [](Ref *sender){ runSocketIOTest();} }, #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - { "EditBoxTest", [](Ref *sender){ runEditBoxTest();} - }, -#endif + { "TableViewTest", [](Ref *sender){ runTableViewTest();} }, { "CocoStudioArmatureTest", [](Ref *sender) { ArmatureTestScene *scene = new (std::nothrow) ArmatureTestScene(); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp deleted file mode 100644 index c8cc71acbf..0000000000 --- a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp +++ /dev/null @@ -1,784 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013 Surith Thekkiam - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "Scale9SpriteTest.h" -#include "testResource.h" -#include "cocos2d.h" -#include "extensions/cocos-ext.h" - -USING_NS_CC_EXT; - -static std::function createFunctions[] = { - CL(S9BatchNodeBasic), - CL(S9FrameNameSpriteSheet), - CL(S9FrameNameSpriteSheetRotated), - CL(S9BatchNodeScaledNoInsets), - CL(S9FrameNameSpriteSheetScaledNoInsets), - CL(S9FrameNameSpriteSheetRotatedScaledNoInsets), - CL(S9BatchNodeScaleWithCapInsets), - CL(S9FrameNameSpriteSheetInsets), - CL(S9FrameNameSpriteSheetInsetsScaled), - CL(S9FrameNameSpriteSheetRotatedInsets), - CL(S9_TexturePacker), - CL(S9FrameNameSpriteSheetRotatedInsetsScaled), - CL(S9FrameNameSpriteSheetRotatedSetCapInsetLater), - CL(S9CascadeOpacityAndColor), - CL(S9ZOrder), - CL(S9Flip) -}; - -static int sceneIdx=-1; -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) - -static Layer* nextAction() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYER; - - auto layer = (createFunctions[sceneIdx])(); - return layer; -} - -static Layer* backAction() -{ - sceneIdx--; - int total = MAX_LAYER; - if( sceneIdx < 0 ) - sceneIdx += total; - - auto layer = (createFunctions[sceneIdx])(); - return layer; -} - -static Layer* restartAction() -{ - auto layer = (createFunctions[sceneIdx])(); - return layer; -} - -void S9SpriteTestScene::runThisTest() -{ - sceneIdx = -1; - addChild(nextAction()); - - Director::getInstance()->replaceScene(this); -} - -//------------------------------------------------------------------ -// -// S9SpriteTestDemo -// -//------------------------------------------------------------------ - -void S9SpriteTestDemo::onEnter() -{ - BaseTest::onEnter(); - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - CCLOG("sprite frames added to sprite frame cache..."); -} - -void S9SpriteTestDemo::restartCallback(Ref* sender) -{ - auto s = new (std::nothrow) S9SpriteTestScene(); - s->addChild( restartAction() ); - Director::getInstance()->replaceScene(s); - s->release(); -} - -void S9SpriteTestDemo::nextCallback(Ref* sender) -{ - auto s = new (std::nothrow) S9SpriteTestScene(); - s->addChild( nextAction() ); - Director::getInstance()->replaceScene(s); - s->release(); -} - -void S9SpriteTestDemo::backCallback(Ref* sender) -{ - auto s = new (std::nothrow) S9SpriteTestScene(); - s->addChild( backAction() ); - Director::getInstance()->replaceScene(s); - s->release(); -} - - -// S9BatchNodeBasic - -void S9BatchNodeBasic::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9BatchNodeBasic ..."); - - auto batchNode = SpriteBatchNode::create("Images/blocks9.png"); - log("batchNode created with : Images/blocks9.png"); - - auto blocks = Scale9Sprite::create(); - log("... created"); - - blocks->updateWithBatchNode(batchNode, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); - log("... updateWithBatchNode"); - - blocks->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks); - log("this->addChild"); - - log("... S9BatchNodeBasic done."); -} - -std::string S9BatchNodeBasic::title() const -{ - return "Scale9Sprite created empty and updated from SpriteBatchNode"; -} - -std::string S9BatchNodeBasic::subtitle() const -{ - return "updateWithBatchNode(); capInsets=full size"; -} - - -// S9FrameNameSpriteSheet - -void S9FrameNameSpriteSheet::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheet ..."); - - auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); - log("... created"); - - blocks->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks); - log("this->addChild"); - - log("... S9FrameNameSpriteSheet done."); -} - -std::string S9FrameNameSpriteSheet::title() const -{ - return "Scale9Sprite from sprite sheet"; -} - -std::string S9FrameNameSpriteSheet::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets"; -} - -// -//// S9FrameNameSpriteSheetRotated -// -void S9FrameNameSpriteSheetRotated::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetRotated ..."); - - auto blocks = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - log("... created"); - - blocks->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetRotated done."); -} - -std::string S9FrameNameSpriteSheetRotated::title() const -{ - return "Scale9Sprite from sprite sheet (stored rotated)"; -} - -std::string S9FrameNameSpriteSheetRotated::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets"; -} - -// -//// S9BatchNodeScaledNoInsets -// - -void S9BatchNodeScaledNoInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9BatchNodeScaledNoInsets ..."); - - // scaled without insets - auto batchNode_scaled = SpriteBatchNode::create("Images/blocks9.png"); - log("batchNode_scaled created with : Images/blocks9.png"); - - auto blocks_scaled = Scale9Sprite::create(); - log("... created"); - blocks_scaled->updateWithBatchNode(batchNode_scaled, Rect(0, 0, 96, 96), false, Rect(0, 0, 96, 96)); - log("... updateWithBatchNode"); - - blocks_scaled->setPosition(Vec2(x, y)); - log("... setPosition"); - - blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - log("... setContentSize"); - - this->addChild(blocks_scaled); - log("this->addChild"); - - log("... S9BtchNodeScaledNoInsets done."); -} - -std::string S9BatchNodeScaledNoInsets::title() const -{ - return "Scale9Sprite created empty and updated from SpriteBatchNode"; -} - -std::string S9BatchNodeScaledNoInsets::subtitle() const -{ - return "updateWithBatchNode(); capInsets=full size; rendered 4 X width, 2 X height"; -} - -// -//// S9FrameNameSpriteSheetScaledNoInsets -// - -void S9FrameNameSpriteSheetScaledNoInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetScaledNoInsets ..."); - - auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9.png"); - log("... created"); - - blocks_scaled->setPosition(Vec2(x, y)); - log("... setPosition"); - - blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - log("... setContentSize"); - - this->addChild(blocks_scaled); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetScaledNoInsets done."); -} - -std::string S9FrameNameSpriteSheetScaledNoInsets::title() const -{ - return "Scale9Sprite from sprite sheet"; -} - -std::string S9FrameNameSpriteSheetScaledNoInsets::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height"; -} - - -// -//// S9FrameNameSpriteSheetRotatedScaledNoInsets -// - -void S9FrameNameSpriteSheetRotatedScaledNoInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetRotatedScaledNoInsets ..."); - - auto blocks_scaled = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - log("... created"); - - blocks_scaled->setPosition(Vec2(x, y)); - log("... setPosition"); - - blocks_scaled->setContentSize(Size(96 * 4, 96*2)); - log("... setContentSize"); - - this->addChild(blocks_scaled); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetRotatedScaledNoInsets done."); -} - -std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::title() const -{ - return "Scale9Sprite from sprite sheet (stored rotated)"; -} - -std::string S9FrameNameSpriteSheetRotatedScaledNoInsets::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height"; -} - -// -// -//// S9BatchNodeScaleWithCapInsets -// - -void S9BatchNodeScaleWithCapInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9BatchNodeScaleWithCapInsets ..."); - - auto batchNode_scaled_with_insets = SpriteBatchNode::create("Images/blocks9.png"); - log("batchNode_scaled_with_insets created with : Images/blocks9.png"); - - auto blocks_scaled_with_insets = Scale9Sprite::create(); - log("... created"); - - blocks_scaled_with_insets->updateWithBatchNode(batchNode_scaled_with_insets, Rect(0, 0, 96, 96), false, Rect(32, 32, 32, 32)); - log("... updateWithBatchNode"); - - blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - log("... setContentSize"); - - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_scaled_with_insets); - log("this->addChild"); - - log("... S9BatchNodeScaleWithCapInsets done."); -} - -std::string S9BatchNodeScaleWithCapInsets::title() const -{ - return "Scale9Sprite created empty and updated from SpriteBatchNode"; -} - -std::string S9BatchNodeScaleWithCapInsets::subtitle() const -{ - return "updateWithBatchNode(); capInsets=(32, 32, 32, 32)"; -} - -// -//// S9FrameNameSpriteSheetInsets -// - -void S9FrameNameSpriteSheetInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetInsets ..."); - - auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - log("... created"); - - blocks_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_with_insets); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetInsets done."); -} - -std::string S9FrameNameSpriteSheetInsets::title() const -{ - return "Scale9Sprite scaled with insets sprite sheet"; -} - -std::string S9FrameNameSpriteSheetInsets::subtitle() const -{ - return "createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)"; -} - -// -//// S9FrameNameSpriteSheetInsetsScaled -// -void S9FrameNameSpriteSheetInsetsScaled::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetInsetsScaled ..."); - - auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - log("... created"); - - blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - log("... setContentSize"); - - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_scaled_with_insets); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetInsetsScaled done."); -} - -std::string S9FrameNameSpriteSheetInsetsScaled::title() const -{ - return "Scale9Sprite scaled with insets sprite sheet"; -} - -std::string S9FrameNameSpriteSheetInsetsScaled::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height"; -} - -//// S9FrameNameSpriteSheetRotatedInsets -// - -void S9FrameNameSpriteSheetRotatedInsets::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetRotatedInsets ..."); - - auto blocks_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png", Rect(32, 32, 32, 32)); - log("... created"); - - blocks_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_with_insets); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetRotatedInsets done."); -} - -std::string S9FrameNameSpriteSheetRotatedInsets::title() const -{ - return "Scale9Sprite scaled with insets sprite sheet (stored rotated)"; -} - -std::string S9FrameNameSpriteSheetRotatedInsets::subtitle() const -{ - return "createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)"; -} - -// -//// S9_TexturePacker -// - -void S9_TexturePacker::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_ui_plist); - - float x = winSize.width / 4; - float y = 0 + (winSize.height / 2); - - log("S9_TexturePacker ..."); - - auto s = Scale9Sprite::createWithSpriteFrameName("button_normal.png"); - log("... created"); - - s->setPosition(Vec2(x, y)); - log("... setPosition"); - - s->setContentSize(Size(14 * 16, 10 * 16)); - log("... setContentSize"); - - this->addChild(s); - log("this->addChild"); - - x = winSize.width * 3/4; - - auto s2 = Scale9Sprite::createWithSpriteFrameName("button_actived.png"); - log("... created"); - - s2->setPosition(Vec2(x, y)); - log("... setPosition"); - - s2->setContentSize(Size(14 * 16, 10 * 16)); - log("... setContentSize"); - - this->addChild(s2); - log("this->addChild"); - - log("... S9_TexturePacker done."); -} - -std::string S9_TexturePacker::title() const -{ - return "Scale9Sprite from a spritesheet created with TexturePacker"; -} - -std::string S9_TexturePacker::subtitle() const -{ - return "createWithSpriteFrameName('button_normal.png');createWithSpriteFrameName('button_actived.png');"; -} - -// -//// S9FrameNameSpriteSheetRotatedInsetsScaled -// - -void S9FrameNameSpriteSheetRotatedInsetsScaled::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("S9FrameNameSpriteSheetRotatedInsetsScaled ..."); - - auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9.png", Rect(32, 32, 32, 32)); - log("... created"); - - blocks_scaled_with_insets->setContentSize(Size(96 * 4.5, 96 * 2.5)); - log("... setContentSize"); - - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_scaled_with_insets); - log("this->addChild"); - - log("... S9FrameNameSpriteSheetRotatedInsetsScaled done."); -} - -std::string S9FrameNameSpriteSheetRotatedInsetsScaled::title() const -{ - return "Scale9Sprite scaled with insets sprite sheet (stored rotated)"; -} - -std::string S9FrameNameSpriteSheetRotatedInsetsScaled::subtitle() const -{ - return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height"; -} - -// -//// Scale9FrameNameSpriteSheetRotatedSetCapInsetLater -// - -void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - log("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ..."); - - auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - log("... created"); - - blocks_scaled_with_insets->setInsetLeft(32); - blocks_scaled_with_insets->setInsetRight(32); - - blocks_scaled_with_insets->setPreferredSize(Size(32*5.5f, 32*4)); - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - this->addChild(blocks_scaled_with_insets); - log("this->addChild"); - - log("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done."); -} - -std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::title() const -{ - return "Scale9Sprite from sprite sheet (stored rotated), with setting CapInset later"; -} - -std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::subtitle() const -{ - return "createWithSpriteFrameName(); setInsetLeft(32); setInsetRight(32);"; -} - -// -//// S9CascadeOpacityAndColor -// - -void S9CascadeOpacityAndColor::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - auto rgba = Layer::create(); - rgba->setCascadeColorEnabled(true); - rgba->setCascadeOpacityEnabled(true); - this->addChild(rgba); - - log("S9CascadeOpacityAndColor ..."); - - auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - log("... created"); - - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - log("... setPosition"); - - rgba->addChild(blocks_scaled_with_insets); - auto actions = Sequence::create(FadeIn::create(1), - TintTo::create(1, 0, 255, 0), - TintTo::create(1, 255, 255, 255), - FadeOut::create(1), - nullptr); - auto repeat = RepeatForever::create(actions); - rgba->runAction(repeat); - log("this->addChild"); - - log("... S9CascadeOpacityAndColor done."); -} - -std::string S9CascadeOpacityAndColor::title() const -{ - return "Scale9Sprite and a Layer parent with setCascadeOpacityEnable(true) and setCascadeColorEnable(true)"; -} - -std::string S9CascadeOpacityAndColor::subtitle() const -{ - return "when parent change color/opacity, Scale9Sprite should also change"; -} - -// -//// S9ZOrder -// - -void S9ZOrder::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - - blocks_scaled_with_insets->setPosition(Vec2(x, y)); - this->addChild(blocks_scaled_with_insets); - - Sprite *normalSprite = Sprite::createWithSpriteFrameName("blocks9r.png"); - normalSprite->setColor(Color3B::RED); - blocks_scaled_with_insets->addChild(normalSprite); - - auto topLabel = Label::createWithSystemFont("I Must be On the Top", "Arial", 15); - topLabel->setPosition(Vec2(20,20)); - blocks_scaled_with_insets->addChild(topLabel); - - auto bottomLabel = Label::createWithSystemFont("I Must be On the Bottom", "Arial", 15); - bottomLabel->setPosition(Vec2(80,80)); - bottomLabel->setColor(Color3B::BLUE); - blocks_scaled_with_insets->addChild(bottomLabel,-1); - -} - -std::string S9ZOrder::title() const -{ - return "Scale9Sprite ZOrder issue"; -} - -std::string S9ZOrder::subtitle() const -{ - return "When adding nodes to Scale9Sprite, it should be added on top itself"; -} - -// -//// S9Flip -// - -void S9Flip::onEnter() -{ - S9SpriteTestDemo::onEnter(); - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - - auto normalSprite = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - - normalSprite->setPosition(Vec2(x, y )); - this->addChild(normalSprite); - - - auto normalLabel = Label::createWithSystemFont("Normal Sprite","Airal",10); - normalLabel->setPosition(normalSprite->getPosition() + Vec2(0, normalSprite->getContentSize().height/2 + 10)); - this->addChild(normalLabel); - - - - auto flipXSprite = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - - flipXSprite->setPosition(Vec2(x - 120, y )); - this->addChild(flipXSprite); - - flipXSprite->setScaleX(-1); - - auto flipXLabel = Label::createWithSystemFont("Sprite FlipX","Airal",10); - flipXLabel->setPosition(flipXSprite->getPosition() + Vec2(0, flipXSprite->getContentSize().height/2 + 10)); - this->addChild(flipXLabel); - - - auto flipYSprite = Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); - - flipYSprite->setPosition(Vec2(x + 120, y)); - this->addChild(flipYSprite); - - flipYSprite->setScaleY(-1); - - auto flipYLabel = Label::createWithSystemFont("Sprite FlipY","Airal",10); - flipYLabel->setPosition(flipYSprite->getPosition() + Vec2(0, flipYSprite->getContentSize().height/2 + 10)); - this->addChild(flipYLabel); - - -} - -std::string S9Flip::title() const -{ - return "Scale9Sprite Flip issue"; -} - -std::string S9Flip::subtitle() const -{ - return "When Flipped, the scale9Sprite should behavior like a normal node"; -} diff --git a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h b/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h deleted file mode 100644 index a5448fb86e..0000000000 --- a/tests/cpp-tests/Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.h +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013 Surith Thekkiam - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "testBasic.h" -#include "BaseTest.h" - - -class S9SpriteTestScene : public TestScene -{ -public: - virtual void runThisTest(); -}; - -class S9SpriteTestDemo : public BaseTest -{ -public: - virtual void onEnter() override; - - virtual void restartCallback(Ref* sender); - virtual void nextCallback(Ref* sender); - virtual void backCallback(Ref* sender); -}; - -// S9BatchNodeBasic - -class S9BatchNodeBasic : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9BatchNodeBasic); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheet - -class S9FrameNameSpriteSheet : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheet); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetRotated - -class S9FrameNameSpriteSheetRotated : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetRotated); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9BatchNodeScaledNoInsets - -class S9BatchNodeScaledNoInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9BatchNodeScaledNoInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetScaledNoInsets - -class S9FrameNameSpriteSheetScaledNoInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetScaledNoInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetRotatedScaledNoInsets - -class S9FrameNameSpriteSheetRotatedScaledNoInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetRotatedScaledNoInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - - -// S9BatchNodeScaleWithCapInsets - -class S9BatchNodeScaleWithCapInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9BatchNodeScaleWithCapInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetInsets - -class S9FrameNameSpriteSheetInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetInsetsScaled - -class S9FrameNameSpriteSheetInsetsScaled : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetInsetsScaled); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetRotatedInsets - -class S9FrameNameSpriteSheetRotatedInsets : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetRotatedInsets); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9_TexturePacker - -class S9_TexturePacker : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9_TexturePacker); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetRotatedInsetsScaled - -class S9FrameNameSpriteSheetRotatedInsetsScaled : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetRotatedInsetsScaled); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9FrameNameSpriteSheetRotatedInsetsScaled - -class S9FrameNameSpriteSheetRotatedSetCapInsetLater : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9FrameNameSpriteSheetRotatedSetCapInsetLater); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// S9CascadeOpacityAndColor - -class S9CascadeOpacityAndColor : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9CascadeOpacityAndColor); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// Scale9Sprite ZOrder - -class S9ZOrder : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9ZOrder); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; - -// Scale9Sprite Flip - -class S9Flip : public S9SpriteTestDemo -{ -public: - CREATE_FUNC(S9Flip); - - virtual void onEnter() override; - - virtual std::string title() const override; - virtual std::string subtitle() const override; -}; diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index dc4bad49dd..2790a989f5 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -73,6 +73,7 @@ static std::function createFunctions[] = CL(NodeGlobalZValueTest), CL(NodeNormalizedPositionTest1), CL(NodeNormalizedPositionTest2), + CL(NodeNormalizedPositionBugTest), CL(NodeNameTest), }; @@ -1227,11 +1228,49 @@ void NodeNormalizedPositionTest2::update(float dt) Size s = Size(_copyContentSize.width*norm, _copyContentSize.height*norm); setContentSize(s); - CCLOG("s: %f,%f", s.width, s.height); } +//------------------------------------------------------------------ +// +// NodeNormalizedPositionBugTest +// +//------------------------------------------------------------------ +NodeNormalizedPositionBugTest::NodeNormalizedPositionBugTest() +: _accum(0) +{ + Vec2 position; + + position = Vec2(0.5,0.5); + + + sprite = Sprite::create("Images/grossini.png"); + sprite->setNormalizedPosition(position); + addChild(sprite); + + scheduleUpdate(); +} + +std::string NodeNormalizedPositionBugTest::title() const +{ + return "NodeNormalizedPositionBugTest"; +} + +std::string NodeNormalizedPositionBugTest::subtitle() const +{ + return "When changing sprite normalizedPosition, the sprite doesn't move!"; +} + +void NodeNormalizedPositionBugTest::update(float dt) +{ + _accum += dt; + + // for 5 seconds + float norm = clampf(sinf(_accum), 0, 1.0); + sprite->setNormalizedPosition(Vec2(norm,norm)); +} + std::string NodeNameTest::title() const { return "getName()/setName()/getChildByName()/enumerateChildren()"; diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 068bdb7cfd..a7ab77894b 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -295,6 +295,21 @@ protected: float _accum; }; +class NodeNormalizedPositionBugTest : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeNormalizedPositionBugTest); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +protected: + NodeNormalizedPositionBugTest(); + + void update(float dt); + float _accum; + Sprite *sprite; +}; + class NodeNameTest : public TestCocosNodeDemo { public: diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 6905ba7701..de96938730 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -44,6 +44,18 @@ g_guisTests[] = } }, #endif + { + "EditBox Test", + [](Ref* sender) + { + UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); + sceneManager->setCurrentUISceneId(kUIEditBoxTest); + sceneManager->setMinUISceneId(kUIEditBoxTest); + sceneManager->setMaxUISceneId(kUIEditBoxTest); + Scene* scene = sceneManager->currentUIScene(); + Director::getInstance()->replaceScene(scene); + } + }, { "focus test", [](Ref* sender) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp new file mode 100644 index 0000000000..121f6a1fb0 --- /dev/null +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "UIEditBoxTest.h" +#include "testResource.h" + +// UIEditBoxTest +UIEditBoxTest::UIEditBoxTest() +{ + +} + +UIEditBoxTest::~UIEditBoxTest() +{ +} + +bool UIEditBoxTest::init() +{ + if (UIScene::init()) + { + auto glview = Director::getInstance()->getOpenGLView(); + auto visibleOrigin = glview->getVisibleOrigin(); + auto visibleSize = glview->getVisibleSize(); + + auto pBg = Sprite::create("Images/HelloWorld.png"); + pBg->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); + addChild(pBg); + + _TTFShowEditReturn = Label::createWithSystemFont("No edit control return!", "Arial", 30); + _TTFShowEditReturn->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)); + addChild(_TTFShowEditReturn); + + + auto editBoxSize = Size(visibleSize.width - 100, 60); + + // top + std::string pNormalSprite = "extensions/green_edit.png"; + _editName = ui::EditBox::create(editBoxSize, ui::Scale9Sprite::create(pNormalSprite)); + _editName->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); + _editName->setFontName("Paint Boy"); + _editName->setFontSize(25); + _editName->setFontColor(Color3B::RED); + _editName->setPlaceHolder("Name:"); + _editName->setPlaceholderFontColor(Color3B::WHITE); + _editName->setMaxLength(8); + _editName->setReturnType(ui::EditBox::KeyboardReturnType::DONE); + _editName->setDelegate(this); + addChild(_editName); + + // middle + _editPassword = ui::EditBox::create(editBoxSize, "extensions/orange_edit.png"); + _editPassword->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + _editPassword->setFont("American Typewriter", 30); +#else + _editPassword->setFont("American Typewriter", 80); + _editPassword->setPlaceholderFont("American Typewriter", 80); +#endif + _editPassword->setFontColor(Color3B::GREEN); + _editPassword->setPlaceHolder("Password:"); + _editPassword->setMaxLength(6); + _editPassword->setInputFlag(ui::EditBox::InputFlag::PASSWORD); + _editPassword->setInputMode(ui::EditBox::InputMode::SINGLE_LINE); + _editPassword->setDelegate(this); + addChild(_editPassword); + + // bottom + _editEmail = ui::EditBox::create(Size(editBoxSize.width, editBoxSize.height), "extensions/yellow_edit.png"); + _editEmail->setPosition(Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); + _editEmail->setAnchorPoint(Vec2(0.5, 1.0f)); + _editEmail->setPlaceHolder("Email:"); + _editEmail->setInputMode(ui::EditBox::InputMode::EMAIL_ADDRESS); + _editEmail->setDelegate(this); + addChild(_editEmail); + + this->setPosition(Vec2(10, 20)); + + + + return true; + } + return false; +} + +void UIEditBoxTest::editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox) +{ + log("editBox %p DidBegin !", editBox); +} + +void UIEditBoxTest::editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox) +{ + log("editBox %p DidEnd !", editBox); +} + +void UIEditBoxTest::editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) +{ + log("editBox %p TextChanged, text: %s ", editBox, text.c_str()); +} + +void UIEditBoxTest::editBoxReturn(ui::EditBox* editBox) +{ + log("editBox %p was returned !",editBox); + + if (_editName == editBox) + { + _TTFShowEditReturn->setString("Name EditBox return !"); + } + else if (_editPassword == editBox) + { + _TTFShowEditReturn->setString("Password EditBox return !"); + } + else if (_editEmail == editBox) + { + _TTFShowEditReturn->setString("Email EditBox return !"); + } +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h new file mode 100644 index 0000000000..3d93dd7717 --- /dev/null +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIEditBoxTest.h @@ -0,0 +1,52 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __cocos2d_tests__UIEditBoxTest__ +#define __cocos2d_tests__UIEditBoxTest__ + +#include "UIScene.h" + +class UIEditBoxTest : public UIScene, public cocos2d::ui::EditBoxDelegate +{ +public: + UIEditBoxTest(); + ~UIEditBoxTest(); + bool init(); + + virtual void editBoxEditingDidBegin(cocos2d::ui::EditBox* editBox); + virtual void editBoxEditingDidEnd(cocos2d::ui::EditBox* editBox); + virtual void editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text); + virtual void editBoxReturn(cocos2d::ui::EditBox* editBox); + + +protected: + cocos2d::Label* _TTFShowEditReturn; + cocos2d::ui::EditBox* _editName; + cocos2d::ui::EditBox* _editPassword; + cocos2d::ui::EditBox* _editEmail; + + UI_SCENE_CREATE_FUNC(UIEditBoxTest) +}; + +#endif /* defined(__cocos2d_tests__UIEditBoxTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h index 3279022d33..dcdca668bb 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScene.h @@ -31,7 +31,7 @@ USING_NS_CC; USING_NS_CC_EXT; -using namespace ui; +using namespace cocos2d::ui; #define UI_SCENE_CREATE_FUNC(UIScene) \ public: \ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index 535b85c4ad..ab9a713c83 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -23,6 +23,9 @@ #include "UIWebViewTest/UIWebViewTest.h" #endif #include "UIScale9SpriteTest.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#include "UIEditBoxTest.h" +#endif USING_NS_CC; @@ -36,6 +39,9 @@ static const char* s_testArray[] = "UIButtonTest_RemoveSelf", "UIButtonTestSwitchScale9", "UIButtonTestZoomScale", +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) + "UIEditBoxTest", +#endif "UICheckBoxTest", "UISliderTest", "UISliderTest_Scale9", @@ -373,6 +379,11 @@ Scene *UISceneManager::currentUIScene() return UIS9Flip::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIS9ChangeAnchorPoint: return UIS9ChangeAnchorPoint::sceneWithTitle(s_testArray[_currentUISceneId]); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) + case kUIEditBoxTest: + return UIEditBoxTest::sceneWithTitle(s_testArray[_currentUISceneId]); +#endif + } return nullptr; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index 6bf7c2c2c9..fe0ed8e067 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -38,6 +38,7 @@ enum kUIButtonTest_RemoveSelf, kUIButtonTestSwitchScale9, kUIButtonTestZoomScale, + kUIEditBoxTest, kUICheckBoxTest, kUISliderTest, kUISliderTest_Scale9, diff --git a/tests/cpp-tests/proj.android/README.md b/tests/cpp-tests/proj.android/README.md deleted file mode 100644 index a4670ebabc..0000000000 --- a/tests/cpp-tests/proj.android/README.md +++ /dev/null @@ -1,87 +0,0 @@ -## Prerequisites: - -* Android NDK -* Android SDK **OR** Eclipse ADT Bundle -* Android AVD target installed - -## Building project - -There are two ways of building Android projects. - -1. Eclipse -2. Command Line - -### Import Project in Eclipse - -#### Features: - -1. Complete workflow from Eclipse, including: - * Build C++. - * Clean C++. - * Build and Run whole project. - * Logcat view. - * Debug Java code. - * Javascript editor. - * Project management. -2. True C++ editing, including: - * Code completion. - * Jump to definition. - * Refactoring tools etc. - * Quick open C++ files. - - -#### Setup Eclipse Environment (only once) - - -**NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. - -1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) - - **OR** - - Install Eclipse with Java. Add ADT and CDT plugins. - -2. Only for Windows - 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). - 2. Add `Cygwin\bin` directory to system PATH variable. - 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. - -3. Set up Variables: - 1. Path Variable `COCOS2DX`: - * Eclipse->Preferences->General->Workspace->**Linked Resources** - * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. - ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) - - 2. C/C++ Environment Variable `NDK_ROOT`: - * Eclipse->Preferences->C/C++->Build->**Environment**. - * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) - * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -4. Import libcocos2dx library project: - 1. File->New->Project->Android Project From Existing Code. - 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. - 3. Click **Finish** to add project. - -#### Adding and running from Eclipse - -![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) - -1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/CppTests/proj.android/` -3. Add the project -4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. - - -### Running project from Command Line - - $ cd cocos2d-x/samples/Cpp/CppTests/proj.android/ - $ export NDK_ROOT=/path/to/ndk - $ ./build_native.sh - $ ant debug install - -If the last command results in sdk.dir missing error then do: - - $ android list target - $ android update project -p . -t (id from step 6) - $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 1fa1eec21b..7f132bd32d 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -159,11 +159,9 @@ - - @@ -202,6 +200,7 @@ + @@ -347,11 +346,9 @@ - - @@ -390,6 +387,7 @@ + diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters index e815660d53..f0e771d566 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters @@ -202,9 +202,6 @@ {a4c2111f-cf9f-492c-884d-3de24715adce} - - {18a69e7e-8ca7-475a-bfbb-7296baab16ce} - {0ef55f53-411a-4661-b5d5-13930da52e68} @@ -220,9 +217,6 @@ {81ec2355-7efd-49e0-b6cb-b1bba23fbbc8} - - {3d73aa04-d66e-43d3-921f-b867a753c113} - {a6e7d28e-46a3-46c4-9735-b39e96f776f0} @@ -594,9 +588,6 @@ Classes\FileUtilsTest - - Classes\ExtensionsTest\EditBoxTest - Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest @@ -618,9 +609,6 @@ Classes - - Classes\ExtensionsTest\Scale9SpriteTest - Classes\ExtensionsTest\NetworkTest @@ -867,6 +855,9 @@ Classes\Sprite3DTest + + Classes\UITest\CocostudioGUISceneTest + @@ -1307,9 +1298,6 @@ Classes\FileUtilsTest - - Classes\ExtensionsTest\EditBoxTest - Classes\ExtensionsTest\CocosBuilderTest\TimelineCallbackTest @@ -1334,9 +1322,6 @@ Classes - - Classes\ExtensionsTest\Scale9SpriteTest - Classes\ExtensionsTest\NetworkTest @@ -1601,5 +1586,8 @@ Classes\Sprite3DTest + + Classes\UITest\CocostudioGUISceneTest + \ No newline at end of file diff --git a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj index 16806e1f8c..60ea821193 100644 --- a/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj +++ b/tests/cpp-tests/proj.wp8-xaml/cpp-testsComponent/cpp-testsComponent.vcxproj @@ -250,6 +250,7 @@ + @@ -453,6 +454,7 @@ + diff --git a/tests/game-controller-test/proj.android/README.md b/tests/game-controller-test/proj.android/README.md deleted file mode 100644 index 312835611a..0000000000 --- a/tests/game-controller-test/proj.android/README.md +++ /dev/null @@ -1,87 +0,0 @@ -## Prerequisites: - -* Android NDK -* Android SDK **OR** Eclipse ADT Bundle -* Android AVD target installed - -## Building project - -There are two ways of building Android projects. - -1. Eclipse -2. Command Line - -### Import Project in Eclipse - -#### Features: - -1. Complete workflow from Eclipse, including: - * Build C++. - * Clean C++. - * Build and Run whole project. - * Logcat view. - * Debug Java code. - * Javascript editor. - * Project management. -2. True C++ editing, including: - * Code completion. - * Jump to definition. - * Refactoring tools etc. - * Quick open C++ files. - - -#### Setup Eclipse Environment (only once) - - -**NOTE:** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before. - -1. Download Eclipse ADT bundle from [Google ADT homepage](http://developer.android.com/sdk/index.html) - - **OR** - - Install Eclipse with Java. Add ADT and CDT plugins. - -2. Only for Windows - 1. Install [Cygwin](http://www.cygwin.com/) with make (select make package from the list during the install). - 2. Add `Cygwin\bin` directory to system PATH variable. - 3. Add this line `none /cygdrive cygdrive binary,noacl,posix=0,user 0 0` to `Cygwin\etc\fstab` file. - -3. Set up Variables: - 1. Path Variable `COCOS2DX`: - * Eclipse->Preferences->General->Workspace->**Linked Resources** - * Click **New** button to add a Path Variable `COCOS2DX` pointing to the root cocos2d-x directory. - ![Example](https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png) - - 2. C/C++ Environment Variable `NDK_ROOT`: - * Eclipse->Preferences->C/C++->Build->**Environment**. - * Click **Add** button and add a new variable `NDK_ROOT` pointing to the root NDK directory. - ![Example](https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png) - * Only for Windows: Add new variables **CYGWIN** with value `nodosfilewarning` and **SHELLOPTS** with value `igncr` - -4. Import libcocos2dx library project: - 1. File->New->Project->Android Project From Existing Code. - 2. Click **Browse** button and open `cocos2d-x/cocos2dx/platform/android/java` directory. - 3. Click **Finish** to add project. - -#### Adding and running from Eclipse - -![Example](https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png) ![Import](https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png) - -1. File->New->Project->Android Project From Existing Code -2. **Browse** to your project directory. eg: `cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/` -3. Add the project -4. Click **Run** or **Debug** to compile C++ followed by Java and to run on connected device or emulator. - - -### Running project from Command Line - - $ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/ - $ export NDK_ROOT=/path/to/ndk - $ ./build_native.sh - $ ant debug install - -If the last command results in sdk.dir missing error then do: - - $ android list target - $ android update project -p . -t (id from step 6) - $ android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6) diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 03e0829edb..3b474c792f 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = AssetsManager.* Scale9Sprite Control.* ControlButton.* EditBox$ ScrollView$ TableView$ TableViewCell$ +classes = AssetsManager.* Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -39,7 +39,6 @@ classes = AssetsManager.* Scale9Sprite Control.* ControlButton.* EditBox$ Scroll skip = .*Delegate::[*], .*Loader.*::[*], *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV], - EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], AssetsManager::[(g|s)etDelegate], AssetsManagerDelegateProtocol::[*], Control::[removeHandleOfControlEvent addHandleOfControlEvent], diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 32baa60dae..a25e3b67b9 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -48,7 +48,7 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* ActionManagerEx::[initWithDictionary initWithBinary], DisplayManager::[initDisplayList (s|g)etCurrentDecorativeDisplay getDecorativeDisplayByIndex], Tween::[(s|g)etMovementBoneData], - GUIReader::[storeFileDesignSize getFileDesignSize getParseCallBackMap getParseObjectMap], + GUIReader::[registerTypeAndCallBack storeFileDesignSize getFileDesignSize getParseCallBackMap getParseObjectMap], ActionNode::[initWithDictionary], ActionObject::[initWithDictionary initWithBinary], BaseData::[copy subtract],