From 8f2f524f2d4c131037817b9913208fe3858b7903 Mon Sep 17 00:00:00 2001 From: dualface Date: Fri, 18 Oct 2013 11:30:28 +0800 Subject: [PATCH 001/185] fix tolua_fix, cleanup peertable after object deleted --- cocos/scripting/lua/bindings/tolua_fix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/lua/bindings/tolua_fix.c b/cocos/scripting/lua/bindings/tolua_fix.c index 870db00d75..259a05242e 100644 --- a/cocos/scripting/lua/bindings/tolua_fix.c +++ b/cocos/scripting/lua/bindings/tolua_fix.c @@ -128,7 +128,11 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) lua_pop(L, 3); return -3; } - + + // cleanup peertable + lua_pushvalue(L, TOLUA_NOPEER); + lua_setfenv(L, -2); + ud = (void**)lua_touserdata(L, -1); lua_pop(L, 1); /* stack: mt ubox */ if (ud == NULL) From 969b464b9b4097a6b57aa92182788a825763abcf Mon Sep 17 00:00:00 2001 From: ondesly Date: Wed, 23 Oct 2013 12:29:59 +0400 Subject: [PATCH 002/185] android & ios screen size change support --- cocos/2d/platform/android/CCApplication.cpp | 4 +++ cocos/2d/platform/android/CCApplication.h | 7 +++++ cocos/2d/platform/android/nativeactivity.cpp | 27 +++++++++++++++++++ cocos/2d/platform/ios/CCApplication.h | 7 +++++ cocos/2d/platform/ios/CCApplication.mm | 4 +++ .../proj.ios_mac/ios/RootViewController.mm | 11 +++++++- .../proj.ios_mac/ios/RootViewController.mm | 12 +++++++-- .../proj.ios_mac/ios/RootViewController.mm | 11 +++++++- 8 files changed, 79 insertions(+), 4 deletions(-) diff --git a/cocos/2d/platform/android/CCApplication.cpp b/cocos/2d/platform/android/CCApplication.cpp index 61b3f288cd..07c5814b3e 100644 --- a/cocos/2d/platform/android/CCApplication.cpp +++ b/cocos/2d/platform/android/CCApplication.cpp @@ -128,4 +128,8 @@ Application::Platform Application::getTargetPlatform() return Platform::OS_ANDROID; } +void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { + +} + NS_CC_END diff --git a/cocos/2d/platform/android/CCApplication.h b/cocos/2d/platform/android/CCApplication.h index e321266c81..d9b7d00f34 100644 --- a/cocos/2d/platform/android/CCApplication.h +++ b/cocos/2d/platform/android/CCApplication.h @@ -50,6 +50,13 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief This function will be called when the application screen size is changed. + @param new width + @param new height + */ + virtual void applicationScreenSizeChanged(int newWidth, int newHeight); + protected: static Application * sm_pSharedApplication; }; diff --git a/cocos/2d/platform/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index fa4fb434d4..1cc60c406c 100644 --- a/cocos/2d/platform/android/nativeactivity.cpp +++ b/cocos/2d/platform/android/nativeactivity.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "CCDirector.h" #include "CCApplication.h" @@ -69,6 +70,9 @@ struct engine { struct saved_state state; }; +static bool isContentRectChanged = false; +static std::chrono::steady_clock::time_point timeRectChanged; + static struct engine engine; static char* editboxText = NULL; @@ -556,6 +560,11 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) { } } +static void onContentRectChanged(ANativeActivity* activity, const ARect* rect) { + timeRectChanged = std::chrono::steady_clock::now(); + isContentRectChanged = true; +} + /** * This is the main entry point of a native application that is using * android_native_app_glue. It runs in its own thread, with its own @@ -584,6 +593,9 @@ void android_main(struct android_app* state) { engine.state = *(struct saved_state*)state->savedState; } + // Screen size change support + state->activity->callbacks->onContentRectChanged = onContentRectChanged; + // loop waiting for stuff to do. while (1) { @@ -671,5 +683,20 @@ void android_main(struct android_app* state) { } else { LOG_RENDER_DEBUG("android_main : !engine.animating"); } + + // Check if screen size changed + if (isContentRectChanged) { + std::chrono::duration duration( + std::chrono::duration_cast>(std::chrono::steady_clock::now() - timeRectChanged)); + + // Wait about 30 ms to get new width and height. Without waiting we can get old values sometime + if (duration.count() > 30) { + isContentRectChanged = false; + + int32_t newWidth = ANativeWindow_getWidth(engine.app->window); + int32_t newHeight = ANativeWindow_getHeight(engine.app->window); + cocos2d::Application::getInstance()->applicationScreenSizeChanged(newWidth, newHeight); + } + } } } diff --git a/cocos/2d/platform/ios/CCApplication.h b/cocos/2d/platform/ios/CCApplication.h index 86be67bd29..a281a4f554 100644 --- a/cocos/2d/platform/ios/CCApplication.h +++ b/cocos/2d/platform/ios/CCApplication.h @@ -76,6 +76,13 @@ public: */ virtual Platform getTargetPlatform(); + /** + @brief This function will be called when the application screen size is changed. + @param new width + @param new height + */ + virtual void applicationScreenSizeChanged(int newWidth, int newHeight); + protected: static Application * sm_pSharedApplication; }; diff --git a/cocos/2d/platform/ios/CCApplication.mm b/cocos/2d/platform/ios/CCApplication.mm index 8c8d543c2e..c09a0aa8a9 100644 --- a/cocos/2d/platform/ios/CCApplication.mm +++ b/cocos/2d/platform/ios/CCApplication.mm @@ -146,4 +146,8 @@ Application::Platform Application::getTargetPlatform() } } +void Application::applicationScreenSizeChanged(int newWidth, int newHeight) { + +} + NS_CC_END diff --git a/template/multi-platform-cpp/proj.ios_mac/ios/RootViewController.mm b/template/multi-platform-cpp/proj.ios_mac/ios/RootViewController.mm index 906aeaf082..187b274b91 100644 --- a/template/multi-platform-cpp/proj.ios_mac/ios/RootViewController.mm +++ b/template/multi-platform-cpp/proj.ios_mac/ios/RootViewController.mm @@ -1,5 +1,6 @@ #import "RootViewController.h" - +#import "cocos2d.h" +#import "EAGLView.h" @implementation RootViewController @@ -43,6 +44,14 @@ return YES; } +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + + CGSize s = CGSizeMake([[CCEAGLView sharedEGLView] getWidth], [[CCEAGLView sharedEGLView] getHeight]); + + cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height); +} + //fix not hide status on ios7 - (BOOL)prefersStatusBarHidden { diff --git a/template/multi-platform-js/proj.ios_mac/ios/RootViewController.mm b/template/multi-platform-js/proj.ios_mac/ios/RootViewController.mm index a0f626dcd6..187b274b91 100644 --- a/template/multi-platform-js/proj.ios_mac/ios/RootViewController.mm +++ b/template/multi-platform-js/proj.ios_mac/ios/RootViewController.mm @@ -1,6 +1,6 @@ - #import "RootViewController.h" - +#import "cocos2d.h" +#import "EAGLView.h" @implementation RootViewController @@ -44,6 +44,14 @@ return YES; } +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + + CGSize s = CGSizeMake([[CCEAGLView sharedEGLView] getWidth], [[CCEAGLView sharedEGLView] getHeight]); + + cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height); +} + //fix not hide status on ios7 - (BOOL)prefersStatusBarHidden { diff --git a/template/multi-platform-lua/proj.ios_mac/ios/RootViewController.mm b/template/multi-platform-lua/proj.ios_mac/ios/RootViewController.mm index a00da00584..093a9b4c3a 100644 --- a/template/multi-platform-lua/proj.ios_mac/ios/RootViewController.mm +++ b/template/multi-platform-lua/proj.ios_mac/ios/RootViewController.mm @@ -24,7 +24,8 @@ ****************************************************************************/ #import "RootViewController.h" - +#import "cocos2d.h" +#import "EAGLView.h" @implementation RootViewController @@ -68,6 +69,14 @@ return YES; } +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + + CGSize s = CGSizeMake([[CCEAGLView sharedEGLView] getWidth], [[CCEAGLView sharedEGLView] getHeight]); + + cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height); +} + //fix not hide status on ios7 - (BOOL)prefersStatusBarHidden { From 2e3b3be1250d96010f3b6387fae1871adaf952e0 Mon Sep 17 00:00:00 2001 From: lite3 Date: Tue, 29 Oct 2013 22:53:01 +0800 Subject: [PATCH 003/185] config android_mk_generator --- .../android_mk_generator.py | 22 ++++++++++++++----- tools/android-mk-generator/config.py | 6 +---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tools/android-mk-generator/android_mk_generator.py b/tools/android-mk-generator/android_mk_generator.py index 3e42d908d5..8e3386a47b 100755 --- a/tools/android-mk-generator/android_mk_generator.py +++ b/tools/android-mk-generator/android_mk_generator.py @@ -6,15 +6,27 @@ import os.path import cStringIO import re +def get_cur_dir(): + path = sys.path[0] + if os.path.isdir(path): + return path + elif os.path.isfile(path): + return os.path.dirname(path) + +CUR_DIR = get_cur_dir() +COCOS_ROOT = os.path.abspath(os.path.join(CUR_DIR, "../../")) +CONFIG = os.path.abspath(os.path.join(CUR_DIR, "./config.py")) +print 'CONFIG:' + CONFIG +print 'COCOS_ROOT:' + COCOS_ROOT + + try: import PathUtils except ImportError, e: - sys.path.append(os.path.abspath(os.path.join(os.curdir, "../pylib"))) + sys.path.append(os.path.abspath(os.path.join(CUR_DIR, "../pylib"))) import PathUtils -COCOS_ROOT = "../../" -COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, COCOS_ROOT)) def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): utils = PathUtils.PathUtils(COCOS_ROOT) @@ -24,7 +36,7 @@ def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): filestrio = cStringIO.StringIO() for filename in filelst: filestrio.write(' \\\n') - filestrio.write("$(LOCAL_PATH)/"+os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, mkfile)))) + filestrio.write(os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, mkfile)))) filestrio.write('\n') # read mk file @@ -65,7 +77,7 @@ def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): mkstrio.close() def main(): - config = open("./config.py") + config = open(CONFIG) params = eval(config.read()) config.close() diff --git a/tools/android-mk-generator/config.py b/tools/android-mk-generator/config.py index f7cdc3f389..d524577587 100644 --- a/tools/android-mk-generator/config.py +++ b/tools/android-mk-generator/config.py @@ -20,9 +20,5 @@ { 'mkfile' : 'external/chipmunk/Android.mk', 'pathes' : ("external/chipmunk/",), -}, -{ - 'mkfile' : 'cocos2dx/platform/android/Android.mk', - 'pathes' : ('cocos2dx/platform/android/',), -}, +} ] \ No newline at end of file From 51f30a01d5b88b745e3ad1d684a704fd01dd1a37 Mon Sep 17 00:00:00 2001 From: lite3 Date: Wed, 30 Oct 2013 16:43:19 +0800 Subject: [PATCH 004/185] replace os.path.samefile os.path.samefile not work at windows. --- tools/pylib/PathUtils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/pylib/PathUtils.py b/tools/pylib/PathUtils.py index 12237a1e5e..c1c42b13bf 100644 --- a/tools/pylib/PathUtils.py +++ b/tools/pylib/PathUtils.py @@ -26,14 +26,14 @@ class PathUtils: for dir in self.__exclude: dir = os.path.abspath(os.path.join(self.__root, dir)) if os.path.isdir(dir) and os.path.isdir(curDir[:len(dir)]): - if os.path.samefile(dir, curDir[:len(dir)]): + if self.samefile(dir, curDir[:len(dir)]): return False if self.__rep.match(fileName): # check file is exclude or not for file in self.__exclude: if os.path.isfile(os.path.join(self.__root, file)): - if os.path.samefile(realFilePath, os.path.join(self.__root, file)): + if self.samefile(realFilePath, os.path.join(self.__root, file)): return False return True @@ -46,7 +46,10 @@ class PathUtils: if self.__check_file_matchs(os.path.join(dirname, name)): if type(lst) is types.ListType: lst += [os.path.abspath(os.path.join(dirname, name))] - + + def samefile(self, path1, path2): + return os.stat(path1) == os.stat(path2) + def set_root(self, root): "set the root path" self._root = root From 21d7dcaf3ac9c868783737f603242c91e8683aec Mon Sep 17 00:00:00 2001 From: lite3 Date: Wed, 30 Oct 2013 16:44:21 +0800 Subject: [PATCH 005/185] add some options Usage: android_mk_generator.py [options] Options: -h, --help show this help message and exit -c CONFIG, --config=CONFIG config file path. -r ROOTPATH, --rootpath=ROOTPATH class root path for mkfile, pathes, exclude. --- .../android_mk_generator.py | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/tools/android-mk-generator/android_mk_generator.py b/tools/android-mk-generator/android_mk_generator.py index 8e3386a47b..8078f6f58c 100755 --- a/tools/android-mk-generator/android_mk_generator.py +++ b/tools/android-mk-generator/android_mk_generator.py @@ -16,9 +16,8 @@ def get_cur_dir(): CUR_DIR = get_cur_dir() COCOS_ROOT = os.path.abspath(os.path.join(CUR_DIR, "../../")) CONFIG = os.path.abspath(os.path.join(CUR_DIR, "./config.py")) -print 'CONFIG:' + CONFIG -print 'COCOS_ROOT:' + COCOS_ROOT - +# print 'CONFIG:' + CONFIG +# print 'COCOS_ROOT:' + COCOS_ROOT try: import PathUtils @@ -85,4 +84,39 @@ def main(): gen_android_mk(**param) if __name__ == "__main__": - sys.exit(main()) \ No newline at end of file + from optparse import OptionParser + + parser = OptionParser() + + parser.add_option('-c', '--config', + type='string', + dest='config', + help="config file path.") + + parser.add_option('-r', '--rootpath', + action='store', + dest='rootpath', + help='class root path for mkfile, pathes, exclude.') + + options, args = parser.parse_args() + + if options.config: + CONFIG = os.path.abspath(os.path.join(os.curdir, options.config)) + + if options.rootpath: + COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, options.rootpath)) + + # print 'CONFIG:', CONFIG + # print 'COCOS_ROOT:', COCOS_ROOT + + error = '' + if not os.path.isfile(CONFIG): + error+='config must be file.\n' + + if not os.path.isdir(COCOS_ROOT): + error+='rootpath must be directory.\n' + + if error != '': + parser.exit(2, "{exception}".format(exception=error)) + + sys.exit(main()) From 8b1d3af720c334546f7d1cb4cf86d4bbddd66b6f Mon Sep 17 00:00:00 2001 From: Luis Parravicini Date: Tue, 5 Nov 2013 23:55:24 -0300 Subject: [PATCH 006/185] added | operator for Control::EventType --- .../GUI/CCControlExtension/CCControl.cpp | 5 +++++ extensions/GUI/CCControlExtension/CCControl.h | 2 ++ .../CCControlButtonTest.cpp | 19 ++++++++++++++++++- .../CCControlButtonTest/CCControlButtonTest.h | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 13d86e629c..15fe7b1a8d 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -326,4 +326,9 @@ bool Control::hasVisibleParents() const } return true; } + +Control::EventType operator|(Control::EventType a, Control::EventType b) { + return static_cast(static_cast(a) | static_cast(b)); +} + NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControl.h b/extensions/GUI/CCControlExtension/CCControl.h index d8644a516f..12533f7041 100644 --- a/extensions/GUI/CCControlExtension/CCControl.h +++ b/extensions/GUI/CCControlExtension/CCControl.h @@ -262,6 +262,8 @@ protected: CC_SYNTHESIZE_READONLY(State, _state, State); }; +Control::EventType operator|(Control::EventType a, Control::EventType b); + // end of GUI group /// @} /// @} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index a7fe134383..d5914b2db1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -110,6 +110,7 @@ ControlButton *ControlButtonTest_HelloVariableSize::standardButtonWithTitle(cons ControlButtonTest_Event::ControlButtonTest_Event() : _displayValueLabel(NULL) +, _displayBitmaskLabel(NULL) { } @@ -117,6 +118,7 @@ ControlButtonTest_Event::ControlButtonTest_Event() ControlButtonTest_Event::~ControlButtonTest_Event() { CC_SAFE_RELEASE_NULL(_displayValueLabel); + CC_SAFE_RELEASE_NULL(_displayBitmaskLabel); } bool ControlButtonTest_Event::init() @@ -130,7 +132,13 @@ bool ControlButtonTest_Event::init() _displayValueLabel->setAnchorPoint(Point(0.5f, -1)); _displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(_displayValueLabel, 1); - + + setDisplayBitmaskLabel(LabelTTF::create("No bitmask event", "Marker Felt", 24)); + _displayBitmaskLabel->setAnchorPoint(Point(0.5f, -1)); + Point bitmaskLabelPos = _displayValueLabel->getPosition() - Point(0, _displayBitmaskLabel->getBoundingBox().size.height); + _displayBitmaskLabel->setPosition(bitmaskLabelPos); + addChild(_displayBitmaskLabel, 1); + // Add the button auto backgroundButton = Scale9Sprite::create("extensions/button.png"); auto backgroundHighlightedButton = Scale9Sprite::create("extensions/buttonHighlighted.png"); @@ -162,11 +170,20 @@ bool ControlButtonTest_Event::init() controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE); controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchUpOutsideAction), Control::EventType::TOUCH_UP_OUTSIDE); controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchCancelAction), Control::EventType::TOUCH_CANCEL); + // test for issue 2882 + controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(ControlButtonTest_Event::touchBitmaskAction), + Control::EventType::TOUCH_DOWN | Control::EventType::DRAG_INSIDE | Control::EventType::DRAG_OUTSIDE | Control::EventType::DRAG_ENTER | Control::EventType::DRAG_EXIT | Control::EventType::TOUCH_UP_INSIDE | Control::EventType::TOUCH_UP_OUTSIDE | Control::EventType::TOUCH_CANCEL | Control::EventType::VALUE_CHANGED); + return true; } return false; } +void ControlButtonTest_Event::touchBitmaskAction(Object *senderz, Control::EventType controlEvent) +{ + _displayBitmaskLabel->setString(String::createWithFormat("using bitmask (%d)", controlEvent)->getCString()); +} + void ControlButtonTest_Event::touchDownAction(Object *senderz, Control::EventType controlEvent) { _displayValueLabel->setString(String::createWithFormat("Touch Down")->getCString()); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index 6e4d602107..1efbf9c604 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -54,8 +54,10 @@ public: void touchUpInsideAction(Object *sender, Control::EventType controlEvent); void touchUpOutsideAction(Object *sender, Control::EventType controlEvent); void touchCancelAction(Object *sender, Control::EventType controlEvent); + void touchBitmaskAction(Object *sender, Control::EventType controlEvent); protected: CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayValueLabel, DisplayValueLabel) + CC_SYNTHESIZE_RETAIN(LabelTTF *, _displayBitmaskLabel, DisplayBitmaskLabel) CONTROL_SCENE_CREATE_FUNC(ControlButtonTest_Event) }; From b7173cd60d086217a930dd5e51c78769f7ce1a75 Mon Sep 17 00:00:00 2001 From: Michael Contento Date: Wed, 6 Nov 2013 14:42:31 +0100 Subject: [PATCH 007/185] add Sprite::setScale(float, float) --- cocos/2d/CCSprite.cpp | 6 ++++++ cocos/2d/CCSprite.h | 1 + 2 files changed, 7 insertions(+) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index fa6f4878b0..63aa9fb5bb 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -840,6 +840,12 @@ void Sprite::setScale(float fScale) SET_DIRTY_RECURSIVELY(); } +void Sprite::setScale(float scaleX, float scaleY) +{ + Node::setScale(scaleX, scaleY); + SET_DIRTY_RECURSIVELY(); +} + void Sprite::setVertexZ(float fVertexZ) { Node::setVertexZ(fVertexZ); diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 7ebf7ff616..0c0b652972 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -494,6 +494,7 @@ public: /// @name Functions inherited from Node virtual void setScaleX(float scaleX) override; virtual void setScaleY(float scaleY) override; + virtual void setScale(float scaleX, float scaleY) override; /** * @js NA * @lua NA From 998b7986465d1288ad683d0e8263965b379778ae Mon Sep 17 00:00:00 2001 From: Oleg Loginov Date: Thu, 7 Nov 2013 01:43:26 +0400 Subject: [PATCH 008/185] ignore output files from script make-all-linux-project.sh --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 8acdd3504c..d16b0398e7 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,8 @@ tools/jenkins_scripts/mac/android/userconf.ini # CTags tags + +# ignore files, created with make-all-linux-project script +/lib +/build/linux-build + From 6a1a7743035d100d3638315573fbffc9aeb354ad Mon Sep 17 00:00:00 2001 From: samuele3 Date: Thu, 7 Nov 2013 10:16:02 +0800 Subject: [PATCH 009/185] issue #2868:Config cocoStudio GUI lua binding files and add a few script files --- .../CocoStudioGUITest/CocoStudioGUITest.lua | 266 ++++++++++++++++++ .../CocoStudioGUITest/UIScene.lua | 71 +++++ .../CocoStudioTest/CocoStudioTest.lua | 113 ++++++++ .../TestLua/Resources/luaScript/mainMenu.lua | 2 + tools/tolua/cocos2dx_studio.ini | 18 +- 5 files changed, 462 insertions(+), 8 deletions(-) create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua new file mode 100644 index 0000000000..92fb321a47 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -0,0 +1,266 @@ +local cocoStudioGuiArray = +{ + { + title = "UIButtonTest", + func = function () + --return new UIButtonTest() + print("come in UIButtonTest") + return cc.Scene:create() + end + }, + { + title = "UIButtonTest_Scale9", + func = function () + --return new UIButtonTest_Scale9(); + end + }, + -- { + -- title: "UIButtonTest_PressedAction", + -- -- func: function () { + -- -- return new UIButtonTest_PressedAction(); + -- -- } + -- }, + -- { + -- title: "UITextButtonTest", + -- -- func: function () { + -- -- return new UITextButtonTest(); + -- -- } + -- }, + -- { + -- title: "UITextButtonTest_Scale9", + -- -- func: function () { + -- -- return new UITextButtonTest_Scale9(); + -- -- } + -- }, + -- { + -- title: "UICheckBoxTest", + -- -- func: function () { + -- -- return new UICheckBoxTest(); + -- -- } + -- }, + -- { + -- title: "UISliderTest", + -- -- func: function () { + -- -- return new UISliderTest(); + -- -- } + -- }, + -- { + -- title: "UIButtonTest", + -- -- func: function () { + -- -- return new UISliderTest_Scale9(); + -- -- } + -- }, + -- { + -- title: "UIImageViewTest", + -- -- func: function () { + -- -- return new UIImageViewTest(); + -- -- } + -- }, + -- { + -- title: "UIImageViewTest_Scale9", + -- -- func: function () { + -- -- return new UIImageViewTest_Scale9(); + -- -- } + -- }, + -- { + -- title: "UILoadingBarTest_Left", + -- -- func: function () { + -- -- return new UILoadingBarTest_Left(); + -- -- } + -- }, + -- { + -- title: "UILoadingBarTest_Right", + -- -- func: function () { + -- -- return new UILoadingBarTest_Right(); + -- -- } + -- }, + -- { + -- title: "UILoadingBarTest_Left_Scale9", + -- -- func: function () { + -- -- return new UILoadingBarTest_Left_Scale9(); + -- -- } + -- }, + -- { + -- title: "UILoadingBarTest_Right_Scale9", + -- -- func: function () { + -- -- return new UILoadingBarTest_Right_Scale9(); + -- -- } + -- }, + -- { + -- title: "UILabelAtlasTest", + -- -- func: function () { + -- -- return new UILabelAtlasTest(); + -- -- } + -- }, + -- { + -- title: "UILabelTest", + -- -- func: function () { + -- -- return new UILabelTest(); + -- -- } + -- }, + -- { + -- title: "UITextAreaTest", + -- -- func: function () { + -- -- return new UITextAreaTest(); + -- -- } + -- }, + -- { + -- title: "UILabelBMFontTest", + -- -- func: function () { + -- -- return new UILabelBMFontTest(); + -- -- } + -- }, + -- { + -- title: "UITextFieldTest", + -- -- func: function () { + -- -- return new UITextFieldTest(); + -- -- } + -- }, + -- { + -- title: "UITextFieldTest_MaxLength", + -- -- func: function () { + -- -- return new UITextFieldTest_MaxLength(); + -- -- } + -- }, + -- { + -- title: "UITextFieldTest_Password", + -- -- func: function () { + -- -- return new UITextFieldTest_Password(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest", + -- -- func: function () { + -- -- return new UIPanelTest(); + -- -- } + -- }, + -- { title: "UIPanelTest_Color", + -- -- func: function () { + -- -- return new UIPanelTest_Color(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest_Gradient", + -- -- func: function () { + -- -- return new UIPanelTest_Gradient(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest_BackGroundImage", + -- -- func: function () { + -- -- return new UIPanelTest_BackGroundImage(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest_BackGroundImage_Scale9", + -- -- func: function () { + -- -- return new UIPanelTest_BackGroundImage_Scale9(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest_Layout_Linear_Vertical", + -- -- func: function () { + -- -- return new UIPanelTest_Layout_Linear_Vertical(); + -- -- } + -- }, + -- { + -- title: "UIPanelTest_Layout_Linear_Horizontal", + -- -- func: function () { + -- -- return new UIPanelTest_Layout_Linear_Horizontal(); + -- -- } + -- }, + -- { + -- title: "UIScrollViewTest_Vertical", + -- -- func: function () { + -- -- return new UIScrollViewTest_Vertical(); + -- -- } + -- }, + -- { + -- title: "UIScrollViewTest_Horizontal", + -- -- func: function () { + -- -- return new UIScrollViewTest_Horizontal(); + -- -- } + -- }, + -- { + -- title: "UIPageViewTest", + -- -- func: function () { + -- -- return new UIPageViewTest(); + -- -- } + -- }, + -- { + -- title: "UIListViewTest_Vertical", + -- -- func: function () { + -- -- return new UIListViewTest_Vertical(); + -- -- } + -- }, + -- { + -- title: "UIListViewTest_Horizontal", + -- -- func: function () { + -- -- return new UIListViewTest_Horizontal(); + -- -- } + -- }, + -- { + -- title: "UIDragPanelTest", + -- -- func: function () { + -- -- return new UIDragPanelTest(); + -- -- } + -- }, + -- { + -- title: "UIDragPanelTest_Bounce", + -- -- func: function () { + -- -- return new UIDragPanelTest_Bounce(); + -- -- } + -- }, + -- { + -- title: "UINodeContainerTest", + -- -- func: function () { + -- -- return new UINodeContainerTest(); + -- -- } + -- } +} + +guiSceneManager = guiSceneManager or {} +guiSceneManager.currentUISceneIdx = 1 + +function guiSceneManager.nextUIScene() + guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray) + if 1 == guiSceneManager.currentUISceneIdx then + guiSceneManager.currentUISceneIdx = table.getn(cocoStudioGuiArray) + end + + return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() +end + +function guiSceneManager.previousUIScene() + + guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx - 1 + if guiSceneManager.currentUISceneIdx <= 0 then + guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx + table.getn(cocoStudioGuiArray) + end + + return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() +end + +function guiSceneManager.currentUIScene() + return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() +end + +function guiSceneManager:getInstance() + local gsMgr = _G.guiSceneManager + if gsMgr then return gsMgr end + + gsMgr = {} + _G.guiSceneManager = gsMgr + setmetatable(o, self) + self.__index = self + return gsMgr +end + +function guiSceneManager:purge() + _G.guiSceneManager = nil +end + +function runCocosGUITestScene() + local scene = guiSceneManager:getInstance().currentUIScene() + cc.Director:getInstance():replaceScene(scene) +end diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua new file mode 100644 index 0000000000..eaa574baac --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua @@ -0,0 +1,71 @@ +UIScene = class("UIScene") +UIScene.__index = UIScene +UIScene._uiLayer= nil +UIScene._widget=nil +UIScene._sceneTitle=nil +UIScene._topDisplayLabel=nil +UIScene._bottomDisplayLabel=nil + +function UIScene.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIScene) + return target +end + +function UIScene:init() + self._uiLayer = ccs.UILayer:create() + self._uiLayer:scheduleUpdate() + self:addChild(this._uiLayer) + + self._widget = ccs.UIHelper:getInstance():createWidgetFromJsonFile("res/cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + --back_label:addTouchEventListener(this.toExtensionsMainLayer, this) + + local left_button = self._uiLayer:getWidgetByName("left_Button") + --left_button:addTouchEventListener(this.previousCallback ,this) + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + --middle_button.addTouchEventListener(this.restartCallback ,this) + + local right_button = self._uiLayer:getWidgetByName("right_Button") + --right_button.addTouchEventListener(this.nextCallback ,this) + + local winSize = cc.Director:getInstance():getWinSize() + local scale = winSize.height / 320 + self._uiLayer:setAnchorPoint(cc.p(0,0)) + self._uiLayer:setScale(scale) + self._uiLayer:setPosition(cc.p((winSize.width - 480 * scale) / 2, (winSize.height - 320 * scale) / 2)) + + local widgetSize = self._widget.getRect().size + local eventLabel = ccs.UILabel:create() + eventLabel:setText("") + eventLabel:setFontName("Marker Felt") + eventLabel:setFontSize(32) + eventLabel:setAnchorPoint(cc.p(0.5, -1)) + eventLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(eventLabel) + self._topDisplayLabel = eventLabel + + local uiLabel = ccs.UILabel:create() + uiLabel:setText("") + uiLabel:setFontName("Marker Felt") + uiLabel:setFontSize(30) + uiLabel:setColor(cc.c3b(159, 168, 176)) + uiLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - uiLabel.getRect().size.height * 1.75)) + self._uiLayer.addWidget(uiLabel) + self._bottomDisplayLabel = uiLabel +end + +function UIScene.create() + local scene = UIScene.extend(cc.Scene:create()) + scene:init() + return scene +end \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua new file mode 100644 index 0000000000..dce016a69c --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua @@ -0,0 +1,113 @@ +require "luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest" + +local LINE_SPACE = 40 +local ITEM_TAG_BASIC = 1000 + +local cocoStudioTestItemNames = +{ + { + itemTitle = "CocoStudioArmatureTest", + testScene = function () + --runArmatureTestScene() + end + }, + { + itemTitle = "CocoStudioGUITest", + testScene = function () + runCocosGUITestScene() + end + }, + { + itemTitle = "CocoStudioComponentsTest", + testScene = function () + --runComponentsTestLayer() + end + }, + { + itemTitle = "CocoStudioSceneTest", + testScene = function () + --runSceneEditorTestLayer() + end + } +} + +local CocoStudioTestScene = class("CocoStudioTestScene") +CocoStudioTestScene.__index = CocoStudioTestScene + +function CocoStudioTestScene.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, CocoStudioTestScene) + return target +end + +function CocoStudioTestScene:runThisTest() + + --armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON + --self:addChild(restartArmatureTest()) +end + +function CocoStudioTestScene.create() + local scene = CocoStudioTestScene.extend(cc.Scene:create()) + return scene +end + +local CocoStudioTestLayer = class("CocoStudioTestLayer") +CocoStudioTestLayer.__index = CocoStudioTestLayer + +function CocoStudioTestLayer.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, CocoStudioTestLayer) + return target +end + +function CocoStudioTestLayer.onMenuCallback(tag,sender) + local index = sender:getZOrder() - ITEM_TAG_BASIC + cocoStudioTestItemNames[index].testScene() +end + +function CocoStudioTestLayer:createMenu() + + local winSize = cc.Director:getInstance():getWinSize() + + local menu = cc.Menu:create() + menu:setPosition(cc.p(0,0)) + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + + for i = 1, table.getn(cocoStudioTestItemNames) do + local menuItem = cc.MenuItemFont:create(cocoStudioTestItemNames[i].itemTitle) + menuItem:setPosition(cc.p(winSize.width / 2, winSize.height - (i + 1) * LINE_SPACE)) + menuItem:registerScriptTapHandler(CocoStudioTestLayer.onMenuCallback) + menu:addChild(menuItem, ITEM_TAG_BASIC + i) + end + + self:addChild(menu) +end + +function CocoStudioTestLayer.create() + local layer = CocoStudioTestLayer.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + end + return layer +end + +------------------------------------- +--CocoStudio Test +------------------------------------- +function CocoStudioTestMain() + local newScene = CocoStudioTestScene.create() + newScene:addChild(CreateBackMenuItem()) + newScene:addChild(CocoStudioTestLayer.create()) + newScene:runThisTest() + return newScene +end diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 3abb47dc4e..8b2478ad82 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -17,6 +17,7 @@ require "luaScript/AssetsManagerTest/AssetsManagerTest" require "luaScript/BugsTest/BugsTest" require "luaScript/ClickAndMoveTest/ClickAndMoveTest" require "luaScript/CocosDenshionTest/CocosDenshionTest" +require "luaScript/CocoStudioTest/CocoStudioTest" require "luaScript/CurrentLanguageTest/CurrentLanguageTest" require "luaScript/DrawPrimitivesTest/DrawPrimitivesTest" require "luaScript/EffectsTest/EffectsTest" @@ -67,6 +68,7 @@ local _allTests = { { isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain }, { isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest }, { isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain }, + { isSupported = true, name = "CocoStudioTest" , create_func = CocoStudioTestMain }, { isSupported = false, name = "CurlTest" , create_func= CurlTestMain }, { isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain }, { isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest }, diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 8959fd0005..6272421098 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -23,11 +23,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h +headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s/cocos/gui/CocosGUI.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget Layout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer # 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 @@ -36,16 +36,18 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = .*Delegate::[*], - .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener], +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc add\w*EventListener], ArmatureDataManager::[CCArmatureDataManager ~CCArmatureDataManager], - Armature::[createBone updateBlendType getCPBody setCPBody (s|g)etBlendFunc getShapeList ^getBody$], + Armature::[createBone updateBlendType getCPBody setCPBody getShapeList ^getBody$], Skin::[(s|g)etSkinData], ArmatureAnimation::[updateHandler updateFrameData frameEvent], - Bone::[(s|g)etIgnoreMovementBoneData] + Bone::[(s|g)etIgnoreMovementBoneData], + UILayer::[getInputManager], + UILayoutParameter::[(s|g)etMargin], + UIHelper::[init] -rename_functions = ArmatureDataManager::[sharedArmatureDataManager=getInstance] +rename_functions = UIHelper::[instance=getInstance], + ArmatureDataManager::[sharedArmatureDataManager=getInstance] rename_classes = From af5ab02bc7a123292a85d78b27f2397e7cd13d04 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 7 Nov 2013 14:00:51 +0800 Subject: [PATCH 010/185] temp commit --- .../cocostudio/CCSGUIReader.cpp | 9 ++++---- cocos/gui/UIHelper.cpp | 23 +++++++++++++++++++ cocos/gui/UIHelper.h | 5 +++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index de644e6ec6..f799c26752 100755 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -236,16 +236,15 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) } float fileDesignWidth = DICTOOL->getFloatValue_json(jsonDict, "designWidth"); float fileDesignHeight = DICTOOL->getFloatValue_json(jsonDict, "designHeight"); - if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { + if (fileDesignWidth <= 0 || fileDesignHeight <= 0) + { printf("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); -// CCUIHELPER->setFileDesignWidth(winSize.width); -// CCUIHELPER->setFileDesignHeight(winSize.height); + UIHelper::setFileDesignSize(fileName, winSize); } else { -// CCUIHELPER->setFileDesignWidth(fileDesignWidth); -// CCUIHELPER->setFileDesignHeight(fileDesignHeight); + UIHelper::setFileDesignSize(fileName, cocos2d::Size(fileDesignWidth, fileDesignHeight)); } JsonDictionary* widgetTree = DICTOOL->getSubDictionary_json(jsonDict, "widgetTree"); UIWidget* widget = widgetFromJsonDictionary(widgetTree); diff --git a/cocos/gui/UIHelper.cpp b/cocos/gui/UIHelper.cpp index d896a6372c..8b43c8f890 100644 --- a/cocos/gui/UIHelper.cpp +++ b/cocos/gui/UIHelper.cpp @@ -25,6 +25,8 @@ #include "CocosGUI.h" namespace gui { + +static cocos2d::Dictionary* fileDesignSizes = NULL; UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag) { @@ -118,5 +120,26 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag) } return NULL; } + +void UIHelper::setFileDesignSize(const char *fileName, const cocos2d::Size &size) +{ + if (!fileDesignSizes) + { + fileDesignSizes = cocos2d::Dictionary::create(); + fileDesignSizes->retain(); + } + cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); + fileDesignSizes->setObject(strSize, fileName); +} + +const cocos2d::Size UIHelper::getFileDesignSize(const char* fileName) +{ + if (!fileDesignSizes) + { + return cocos2d::Size::ZERO; + } + cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)fileDesignSizes->objectForKey(fileName))->_string.c_str()); + return designSize; +} } \ No newline at end of file diff --git a/cocos/gui/UIHelper.h b/cocos/gui/UIHelper.h index 75ccba81eb..68893ceff0 100644 --- a/cocos/gui/UIHelper.h +++ b/cocos/gui/UIHelper.h @@ -71,8 +71,11 @@ public: /*temp action*/ static UIWidget* seekActionWidgetByActionTag(UIWidget* root, int tag); + + static void setFileDesignSize(const char* fileName, const cocos2d::Size &size); + + static const cocos2d::Size getFileDesignSize(const char* fileName); }; - } #endif /* defined(__CocoGUI__UISystem__) */ From c9f814c0160023bb90f44025ca733dd889c66c75 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Thu, 7 Nov 2013 16:39:41 +0800 Subject: [PATCH 011/185] fix Accelerometer Test with missing: Device::setAccelerometerEnabled(true); --- .../Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp | 1 + samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp | 2 ++ samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp | 1 + samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 1 + 4 files changed, 5 insertions(+) diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index db535fe321..8ca2430219 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -32,6 +32,7 @@ void AccelerometerTest::onEnter() { Layer::onEnter(); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(AccelerometerTest::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index e0c4ba23ed..0d52bdde86 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp @@ -20,6 +20,7 @@ bool Bug624Layer::init() label->setPosition(Point(size.width/2, size.height/2)); addChild(label); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); @@ -60,6 +61,7 @@ bool Bug624Layer2::init() label->setPosition(Point(size.width/2, size.height/2)); addChild(label); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer2::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 50d5dc7252..fbc07ca9c3 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -26,6 +26,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() touchListener->onTouchesEnded = CC_CALLBACK_2(ChipmunkTestLayer::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + Device::setAccelerometerEnabled(true); auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(ChipmunkTestLayer::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index db51829b3f..3184565698 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -210,6 +210,7 @@ void PhysicsDemoClickAdd::onEnter() touchListener->onTouchEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + Device::setAccelerometerEnabled(true); auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(PhysicsDemoClickAdd::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); From 9f2297a5a6502f26ab6df1a70db293e9e3ee989f Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 7 Nov 2013 16:46:41 +0800 Subject: [PATCH 012/185] add "retain" to listeners --- cocos/gui/UICheckBox.cpp | 6 +++++- cocos/gui/UIPageView.cpp | 5 +++++ cocos/gui/UIScrollView.cpp | 6 +++++- cocos/gui/UISlider.cpp | 6 +++++- cocos/gui/UITextField.cpp | 5 +++++ cocos/gui/UIWidget.cpp | 21 ++++++++++--------- cocos/gui/UIWidget.h | 6 ------ .../CocoStudioGUITest/UIScene.cpp | 3 +++ 8 files changed, 39 insertions(+), 19 deletions(-) diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index a826fa40ef..c577a86fe6 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -51,7 +51,9 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - + CC_SAFE_RELEASE(_selectedStateEventListener); + _selectedStateEventListener = NULL; + _selectedStateEventSelector = NULL; } UICheckBox* UICheckBox::create() @@ -300,7 +302,9 @@ void UICheckBox::unSelectedEvent() void UICheckBox::addEventListener(cocos2d::Object *target, SEL_SelectedStateEvent selector) { + CC_SAFE_RELEASE(_selectedStateEventListener); _selectedStateEventListener = target; + CC_SAFE_RETAIN(_selectedStateEventListener); _selectedStateEventSelector = selector; } diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index 8498e79d88..bb88e6cb80 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -51,6 +51,9 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); + CC_SAFE_RELEASE(_eventListener); + _eventListener = NULL; + _eventSelector = NULL; } UIPageView* UIPageView::create() @@ -571,7 +574,9 @@ void UIPageView::pageTurningEvent() void UIPageView::addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector) { + CC_SAFE_RELEASE(_eventListener); _eventListener = target; + CC_SAFE_RETAIN(_eventListener); _eventSelector = selector; } diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index 1270c78682..2654eeda53 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -76,7 +76,9 @@ _eventSelector(NULL) UIScrollView::~UIScrollView() { - + CC_SAFE_RELEASE(_eventListener); + _eventListener = NULL; + _eventSelector = NULL; } UIScrollView* UIScrollView::create() @@ -1529,7 +1531,9 @@ void UIScrollView::bounceRightEvent() void UIScrollView::addEventListener(cocos2d::Object *target, SEL_ScrollViewEvent selector) { + CC_SAFE_RELEASE(_eventListener); _eventListener = target; + CC_SAFE_RETAIN(_eventListener); _eventSelector = selector; } diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index f3c0a90b97..d5e0eac9ae 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -58,7 +58,9 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - + CC_SAFE_RELEASE(_slidPercentListener); + _slidPercentListener = NULL; + _slidPercentSelector = NULL; } UISlider* UISlider::create() @@ -412,7 +414,9 @@ float UISlider::getPercentWithBallPos(float px) void UISlider::addEventListener(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) { + CC_SAFE_RELEASE(_slidPercentListener); _slidPercentListener = target; + CC_SAFE_RETAIN(_slidPercentListener); _slidPercentSelector = selector; } diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 2eabd208b2..68f4c1c75b 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -283,6 +283,9 @@ _passwordStyleText("") UITextField::~UITextField() { + CC_SAFE_RELEASE(_eventListener); + _eventListener = NULL; + _eventSelector = NULL; } UITextField* UITextField::create() @@ -504,7 +507,9 @@ void UITextField::deleteBackwardEvent() void UITextField::addEventListener(cocos2d::Object *target, SEL_TextFieldEvent selecor) { + CC_SAFE_RELEASE(_eventListener); _eventListener = target; + CC_SAFE_RETAIN(_eventListener); _eventSelector = selecor; } diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 00ee50680c..3f93746594 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -75,7 +75,15 @@ _isRunning(false) UIWidget::~UIWidget() { - releaseResoures(); + CCLOG("widget aa"); + CC_SAFE_RELEASE(_touchEventListener); + _touchEventListener = NULL; + _touchEventSelector = NULL; + removeAllChildren(); + _children->release(); + _renderer->removeAllChildrenWithCleanup(true); + _renderer->removeFromParentAndCleanup(true); + _renderer->release(); setParent(NULL); _layoutParameterDictionary->removeAllObjects(); CC_SAFE_RELEASE(_layoutParameterDictionary); @@ -116,15 +124,6 @@ bool UIWidget::init() return true; } -void UIWidget::releaseResoures() -{ - removeAllChildren(); - _children->release(); - _renderer->removeAllChildrenWithCleanup(true); - _renderer->removeFromParentAndCleanup(true); - _renderer->release(); -} - void UIWidget::onEnter() { arrayMakeObjectsPerformSelector(_children, onEnter, UIWidget*); @@ -700,7 +699,9 @@ void UIWidget::longClickEvent() void UIWidget::addTouchEventListener(cocos2d::Object *target, SEL_TouchEvent selector) { + CC_SAFE_RELEASE(_touchEventListener); _touchEventListener = target; + CC_SAFE_RETAIN(_touchEventListener); _touchEventSelector = selector; } diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index d8f35578f4..f4f48f2a94 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -907,12 +907,6 @@ protected: void cancelUpEvent(); void longClickEvent(); void updateAnchorPoint(); - /** - * Release texture resoures of widget. - * Release renderer. - * If you override releaseResoures, you shall call its parent's one, e.g. UIWidget::releaseResoures(). - */ - virtual void releaseResoures(); void updateSizeAndPosition(); void copyProperties(UIWidget* model); virtual UIWidget* createCloneInstance(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index 38344c9490..cc95546ca1 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -74,6 +74,7 @@ void UIScene::previousCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->previousUIScene()); } } @@ -82,6 +83,7 @@ void UIScene::restartCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->currentUIScene()); } } @@ -90,6 +92,7 @@ void UIScene::nextCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->nextUIScene()); } } From b5f83c30b66b696c02725ddaa1237ad064ace846 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Thu, 7 Nov 2013 17:08:16 +0800 Subject: [PATCH 013/185] fix indention --- .../TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp | 2 +- samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp | 4 ++-- samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp | 2 +- samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index 8ca2430219..5bc3d6a7ed 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -32,7 +32,7 @@ void AccelerometerTest::onEnter() { Layer::onEnter(); - Device::setAccelerometerEnabled(true); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(AccelerometerTest::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index 0d52bdde86..b7a60bb7a8 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp @@ -20,7 +20,7 @@ bool Bug624Layer::init() label->setPosition(Point(size.width/2, size.height/2)); addChild(label); - Device::setAccelerometerEnabled(true); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); @@ -61,7 +61,7 @@ bool Bug624Layer2::init() label->setPosition(Point(size.width/2, size.height/2)); addChild(label); - Device::setAccelerometerEnabled(true); + Device::setAccelerometerEnabled(true); auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(Bug624Layer2::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index fbc07ca9c3..4a4cd5e027 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -26,7 +26,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() touchListener->onTouchesEnded = CC_CALLBACK_2(ChipmunkTestLayer::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - Device::setAccelerometerEnabled(true); + Device::setAccelerometerEnabled(true); auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(ChipmunkTestLayer::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 3184565698..2ef3f4fc4a 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -210,7 +210,7 @@ void PhysicsDemoClickAdd::onEnter() touchListener->onTouchEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - Device::setAccelerometerEnabled(true); + Device::setAccelerometerEnabled(true); auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(PhysicsDemoClickAdd::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); From e2249c8c3f4bebd788e06699f2b7584f51cecfd2 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 7 Nov 2013 17:15:52 +0800 Subject: [PATCH 014/185] Fixed crash --- cocos/gui/UIInputManager.cpp | 8 ++++---- cocos/gui/UIWidget.cpp | 1 - .../CocoStudioGUITest/CocosGUIScene.cpp | 13 +------------ .../ExtensionsTest/CocoStudioGUITest/UIScene.cpp | 1 + 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/cocos/gui/UIInputManager.cpp b/cocos/gui/UIInputManager.cpp index bb36043855..a1c6659557 100644 --- a/cocos/gui/UIInputManager.cpp +++ b/cocos/gui/UIInputManager.cpp @@ -176,10 +176,10 @@ void UIInputManager::onTouchEnd(Touch* touch) int length = selectedWidgetArray->num; for (int i=0; iarr[i]); + UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[0]); + _selectedWidgets->removeObject(hitWidget); hitWidget->onTouchEnded(_touchEndedPoint); } - _selectedWidgets->removeAllObjects(); } void UIInputManager::onTouchCancelled(Touch* touch) @@ -191,10 +191,10 @@ void UIInputManager::onTouchCancelled(Touch* touch) int length = selectedWidgetArray->num; for (int i=0; iarr[i]); + UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[0]); + _selectedWidgets->removeObject(hitWidget); hitWidget->onTouchCancelled(_touchEndedPoint); } - _selectedWidgets->removeAllObjects(); } void UIInputManager::setRootWidget(UIWidget *root) diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 3f93746594..7f2adc545a 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -75,7 +75,6 @@ _isRunning(false) UIWidget::~UIWidget() { - CCLOG("widget aa"); CC_SAFE_RELEASE(_touchEventListener); _touchEventListener = NULL; _touchEventSelector = NULL; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp index 750b562a67..43a15715c8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp @@ -25,17 +25,7 @@ void CocosGUITestScene::runThisTest() { Director::getInstance()->replaceScene(this); - - ul = UILayer::create(); - ul->scheduleUpdate(); - this->addChild(ul); - - /* - Layout* layout = static_cast(CCUIHELPER->createWidgetFromJsonFile("cocosgui/UI/UI01.json")); - ul->addWidget(layout); - */ - -// /* + Size s = CCDirector::getInstance()->getWinSize(); _itemMenu = CCMenu::create(); @@ -56,7 +46,6 @@ void CocosGUITestScene::runThisTest() } void CocosGUITestScene::MainMenuCallback(Object* pSender) { - ul->removeFromParent(); ExtensionsTestScene *pScene = new ExtensionsTestScene(); pScene->runThisTest(); pScene->release(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index cc95546ca1..a2a3ddcf42 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -64,6 +64,7 @@ void UIScene::menuCloseCallback(Object* pSender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); auto scene = new ExtensionsTestScene(); scene->runThisTest(); scene->release(); From b9b14571ac3e21f252b1483a101065ccea810d0b Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 7 Nov 2013 17:16:31 +0800 Subject: [PATCH 015/185] fix compiling erros on Android --- cocos/2d/CCUserDefaultAndroid.cpp | 4 +- .../platform/android/CCFileUtilsAndroid.cpp | 40 +++++++++---------- .../2d/platform/android/CCFileUtilsAndroid.h | 6 +-- cocos/gui/UILayoutDefine.h | 1 - 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/cocos/2d/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp index 38c09c2a90..db18dd2951 100644 --- a/cocos/2d/CCUserDefaultAndroid.cpp +++ b/cocos/2d/CCUserDefaultAndroid.cpp @@ -74,8 +74,8 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc { tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; - unsigned long nSize; - const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize); + long size; + const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index d15e4f874a..c447b5db32 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp @@ -130,21 +130,21 @@ bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const } -unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* mode, long * size) { - return doGetFileData(filename, pszMode, pSize, false); + return doGetFileData(filename, mode, size, false); } -unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, long * pSize) { return doGetFileData(filename, pszMode, pSize, true); } -unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync) +unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* mode, long * size, bool forAsync) { - unsigned char * pData = 0; + unsigned char * data = 0; - if ((! filename) || (! pszMode) || 0 == strlen(filename)) + if ((! filename) || (! mode) || 0 == strlen(filename)) { return 0; } @@ -189,14 +189,14 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* return NULL; } - off_t size = AAsset_getLength(asset); + off_t fileSize = AAsset_getLength(asset); - pData = new unsigned char[size]; + data = new unsigned char[fileSize]; - int bytesread = AAsset_read(asset, (void*)pData, size); - if (pSize) + int bytesread = AAsset_read(asset, (void*)data, fileSize); + if (size) { - *pSize = bytesread; + *size = bytesread; } AAsset_close(asset); @@ -207,32 +207,32 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* { // read rrom other path than user set it //CCLOG("GETTING FILE ABSOLUTE DATA: %s", filename); - FILE *fp = fopen(fullPath.c_str(), pszMode); + FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); - unsigned long size; + long fileSize; fseek(fp,0,SEEK_END); - size = ftell(fp); + fileSize = ftell(fp); fseek(fp,0,SEEK_SET); - pData = new unsigned char[size]; - size = fread(pData,sizeof(unsigned char), size,fp); + data = new unsigned char[fileSize]; + fileSize = fread(data,sizeof(unsigned char), fileSize,fp); fclose(fp); - if (pSize) + if (size) { - *pSize = size; + *size = fileSize; } } while (0); } - if (! pData) + if (! data) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } - return pData; + return data; } string FileUtilsAndroid::getWritablePath() const diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.h b/cocos/2d/platform/android/CCFileUtilsAndroid.h index 87a2445f48..3bee6d2e39 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.h +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.h @@ -55,7 +55,7 @@ public: /* override funtions */ bool init(); - virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); + virtual unsigned char* getFileData(const char* filename, const char* mode, long * size); virtual std::string getWritablePath() const; virtual bool isFileExist(const std::string& strFilePath) const; @@ -64,10 +64,10 @@ public: /** This function is android specific. It is used for TextureCache::addImageAsync(). Don't use it in your codes. */ - unsigned char* getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize); + unsigned char* getFileDataForAsync(const char* filename, const char* mode, long * size); private: - unsigned char* doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync); + unsigned char* doGetFileData(const char* filename, const char* mode, long * size, bool forAsync); static AAssetManager* assetmanager; }; diff --git a/cocos/gui/UILayoutDefine.h b/cocos/gui/UILayoutDefine.h index 0b772837ca..70ab70251f 100644 --- a/cocos/gui/UILayoutDefine.h +++ b/cocos/gui/UILayoutDefine.h @@ -26,7 +26,6 @@ #define __UILAYOUTDEFINE_H__ #include "cocos2d.h" -#include "ExtensionMacros.h" namespace gui { /** From 99546cef4686babdfbd208bea5fd6c441f604368 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 7 Nov 2013 18:52:36 +0800 Subject: [PATCH 016/185] issue #3025: add getTextureCache() in CCdirector() --- cocos/2d/CCDirector.cpp | 28 +++++++++++++++++++++++++++- cocos/2d/CCDirector.h | 10 ++++++++++ cocos/2d/CCTextureCache.cpp | 27 +++++++++------------------ cocos/2d/CCTextureCache.h | 4 ++++ 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 130d170d30..b55bec2446 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -145,6 +145,8 @@ bool Director::init(void) _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false); _eventDispatcher = new EventDispatcher(); + //init TextureCache + initTextureCache(); // create autorelease pool PoolManager::sharedPoolManager()->push(); @@ -359,6 +361,29 @@ void Director::setOpenGLView(EGLView *pobOpenGLView) } } +TextureCache* Director::getTextureCache() const +{ + return _textureCache; +} + +void Director::initTextureCache() +{ +#ifdef EMSCRIPTEN + _textureCache = new TextureCacheEmscripten(); +#else + _textureCache = new TextureCache(); +#endif // EMSCRIPTEN +} + +void Director::destroyTextureCache() +{ + if (_textureCache) + { + _textureCache->waitForQuit(); + CC_SAFE_RELEASE_NULL(_textureCache); + } +} + void Director::setViewport() { if (_openGLView) @@ -693,7 +718,6 @@ void Director::purgeDirector() DrawPrimitives::free(); AnimationCache::destroyInstance(); SpriteFrameCache::destroyInstance(); - TextureCache::destroyInstance(); ShaderCache::destroyInstance(); FileUtils::destroyInstance(); Configuration::destroyInstance(); @@ -704,6 +728,8 @@ void Director::purgeDirector() GL::invalidateStateCache(); + destroyTextureCache(); + CHECK_GL_ERROR_DEBUG(); // OpenGL view diff --git a/cocos/2d/CCDirector.h b/cocos/2d/CCDirector.h index b01b0fe954..0eb4b5d390 100644 --- a/cocos/2d/CCDirector.h +++ b/cocos/2d/CCDirector.h @@ -54,6 +54,7 @@ class Node; class Scheduler; class ActionManager; class EventDispatcher; +class TextureCache; /** @brief Class that creates and handles the main Window and manages how @@ -137,6 +138,8 @@ public: inline EGLView* getOpenGLView() { return _openGLView; } void setOpenGLView(EGLView *pobOpenGLView); + TextureCache* getTextureCache() const; + inline bool isNextDeltaTimeZero() { return _nextDeltaTimeZero; } void setNextDeltaTimeZero(bool nextDeltaTimeZero); @@ -381,6 +384,10 @@ protected: /** calculates delta time since last time it was called */ void calculateDeltaTime(); + //textureCache creation or release + void initTextureCache(); + void destroyTextureCache(); + protected: /** Scheduler associated with this director @since v2.0 @@ -403,6 +410,9 @@ protected: /* The EGLView, where everything is rendered */ EGLView *_openGLView; + //texture cache belongs to this director + TextureCache *_textureCache; + double _animationInterval; double _oldAnimationInterval; diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 8f3fc6fe3a..cf1e8887f9 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -55,15 +55,7 @@ TextureCache* TextureCache::_sharedTextureCache = nullptr; TextureCache * TextureCache::getInstance() { - if (!_sharedTextureCache) - { -#ifdef EMSCRIPTEN - _sharedTextureCache = new TextureCacheEmscripten(); -#else - _sharedTextureCache = new TextureCache(); -#endif // EMSCRIPTEN - } - return _sharedTextureCache; + return Director::getInstance()->getTextureCache(); } TextureCache::TextureCache() @@ -89,15 +81,6 @@ TextureCache::~TextureCache() void TextureCache::destroyInstance() { - if (_sharedTextureCache) - { - // notify sub thread to quick - _sharedTextureCache->_needQuit = true; - _sharedTextureCache->_sleepCondition.notify_one(); - if (_sharedTextureCache->_loadingThread) _sharedTextureCache->_loadingThread->join(); - - CC_SAFE_RELEASE_NULL(_sharedTextureCache); - } } const char* TextureCache::description() const @@ -443,6 +426,14 @@ void TextureCache::reloadAllTextures() #endif } +void TextureCache::waitForQuit() +{ + // notify sub thread to quick + _needQuit = true; + _sleepCondition.notify_one(); + if (_loadingThread) _loadingThread->join(); +} + void TextureCache::dumpCachedTextureInfo() const { unsigned int count = 0; diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index ec87d891d8..1dcc96eb3e 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -158,6 +158,10 @@ public: */ void dumpCachedTextureInfo() const; + //wait for texture cahe to quit befor destroy instance + //called by director, please do not called outside + void waitForQuit(); + private: void addImageAsyncCallBack(float dt); void loadImage(); From c8fe6077aad9811ea19d1154ad94a15636bd49cf Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 7 Nov 2013 19:10:14 +0800 Subject: [PATCH 017/185] issue #3025: Deprecate TextureCache::getInstance() destroyInstance() --- cocos/2d/CCTextureCache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index 1dcc96eb3e..7916696513 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -59,7 +59,7 @@ class CC_DLL TextureCache : public Object { public: /** Returns the shared instance of the cache */ - static TextureCache * getInstance(); + CC_DEPRECATED_ATTRIBUTE static TextureCache * getInstance(); /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static TextureCache * sharedTextureCache() { return TextureCache::getInstance(); } @@ -67,7 +67,7 @@ public: /** purges the cache. It releases the retained instance. @since v0.99.0 */ - static void destroyInstance(); + CC_DEPRECATED_ATTRIBUTE static void destroyInstance(); /** @deprecated Use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache() { return TextureCache::destroyInstance(); } From 99bcca0532df738b3ac1a9e33c45a42a3d9c580b Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 7 Nov 2013 19:11:09 +0800 Subject: [PATCH 018/185] issue #3025: replace TextureCache::getInstance() by Director::getInstance()->getTextureCache() in cocos folder --- cocos/2d/CCAnimation.cpp | 3 ++- cocos/2d/CCAtlasNode.cpp | 2 +- cocos/2d/CCDirector.cpp | 4 ++-- cocos/2d/CCFontFNT.cpp | 4 ++-- cocos/2d/CCLabelAtlas.cpp | 2 +- cocos/2d/CCLabelBMFont.cpp | 4 ++-- cocos/2d/CCMotionStreak.cpp | 4 ++-- cocos/2d/CCParticleBatchNode.cpp | 2 +- cocos/2d/CCParticleExamples.cpp | 4 ++-- cocos/2d/CCParticleSystem.cpp | 6 +++--- cocos/2d/CCSprite.cpp | 10 +++++----- cocos/2d/CCSpriteBatchNode.cpp | 2 +- cocos/2d/CCSpriteFrame.cpp | 2 +- cocos/2d/CCSpriteFrameCache.cpp | 5 +++-- cocos/2d/CCTMXLayer.cpp | 2 +- cocos/2d/CCTextureAtlas.cpp | 3 ++- cocos/editor-support/cocosbuilder/CCBReader.cpp | 2 +- cocos/editor-support/cocosbuilder/CCNodeLoader.cpp | 4 ++-- cocos/editor-support/spine/spine-cocos2dx.cpp | 2 +- 19 files changed, 35 insertions(+), 32 deletions(-) diff --git a/cocos/2d/CCAnimation.cpp b/cocos/2d/CCAnimation.cpp index 5fa37cd85c..ca1c949882 100644 --- a/cocos/2d/CCAnimation.cpp +++ b/cocos/2d/CCAnimation.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "CCTexture2D.h" #include "ccMacros.h" #include "CCSpriteFrame.h" +#include "CCDirector.h" NS_CC_BEGIN @@ -176,7 +177,7 @@ void Animation::addSpriteFrame(SpriteFrame *pFrame) void Animation::addSpriteFrameWithFile(const char *filename) { - Texture2D *texture = TextureCache::getInstance()->addImage(filename); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); Rect rect = Rect::ZERO; rect.size = texture->getContentSize(); SpriteFrame *pFrame = SpriteFrame::createWithTexture(texture, rect); diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 6922a8f7ca..7ced2ffc9d 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -76,7 +76,7 @@ AtlasNode * AtlasNode::create(const std::string& tile, long tileWidth, long tile bool AtlasNode::initWithTileFile(const std::string& tile, long tileWidth, long tileHeight, long itemsToRender) { CCASSERT(tile.size() > 0, "file size should not be empty"); - Texture2D *texture = TextureCache::getInstance()->addImage(tile); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(tile); return initWithTexture(texture, tileWidth, tileHeight, itemsToRender); } diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index b55bec2446..5a10d83d1e 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -462,7 +462,7 @@ void Director::purgeCachedData(void) if (s_SharedDirector->getOpenGLView()) { SpriteFrameCache::getInstance()->removeUnusedSpriteFrames(); - TextureCache::getInstance()->removeUnusedTextures(); + _textureCache->removeUnusedTextures(); } FileUtils::getInstance()->purgeCachedEntries(); } @@ -867,7 +867,7 @@ void Director::getFPSImageData(unsigned char** datapointer, long* length) void Director::createStatsLabel() { Texture2D *texture = nullptr; - TextureCache *textureCache = TextureCache::getInstance(); + TextureCache *textureCache = _textureCache; if (_FPSLabel && _SPFLabel) { diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index 1992b4f828..25709c714e 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -34,7 +34,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath) return nullptr; // add the texture - Texture2D *tempTexture = TextureCache::getInstance()->addImage(newConf->getAtlasName()); + Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(newConf->getAtlasName()); if (!tempTexture) { delete newConf; @@ -198,7 +198,7 @@ FontAtlas * FontFNT::createFontAtlas() // add the texture (only one texture for now) - Texture2D *tempTexture = TextureCache::getInstance()->addImage(_configuration->getAtlasName()); + Texture2D *tempTexture = Director::getInstance()->getTextureCache()->addImage(_configuration->getAtlasName()); if (!tempTexture) return 0; diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 56a6ff723b..119492b062 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -56,7 +56,7 @@ LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& cha bool LabelAtlas::initWithString(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap) { - Texture2D *texture = TextureCache::getInstance()->addImage(charMapFile); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(charMapFile); return initWithString(string, texture, itemWidth, itemHeight, startCharMap); } diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index e28d4d0afc..6e1a9aefda 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -486,7 +486,7 @@ bool LabelBMFont::initWithString(const std::string& theString, const std::string _fntFile = fntFile; - texture = TextureCache::getInstance()->addImage(_configuration->getAtlasName()); + texture = Director::getInstance()->getTextureCache()->addImage(_configuration->getAtlasName()); } else { @@ -1213,7 +1213,7 @@ void LabelBMFont::setFntFile(const char* fntFile) CC_SAFE_RELEASE(_configuration); _configuration = newConf; - this->setTexture(TextureCache::getInstance()->addImage(_configuration->getAtlasName())); + this->setTexture(Director::getInstance()->getTextureCache()->addImage(_configuration->getAtlasName())); this->createFontChars(); } } diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index 47cb43a207..14920662ce 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -28,7 +28,7 @@ THE SOFTWARE. #include "CCGLProgram.h" #include "CCShaderCache.h" #include "ccMacros.h" - +#include "CCDirector.h" #include "CCVertex.h" NS_CC_BEGIN @@ -93,7 +93,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co { CCASSERT(path != NULL, "Invalid filename"); - Texture2D *texture = TextureCache::getInstance()->addImage(path); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(path); return initWithFade(fade, minSeg, stroke, color, texture); } diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 788fdd221c..cd473bf097 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -111,7 +111,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity) */ bool ParticleBatchNode::initWithFile(const char* fileImage, unsigned int capacity) { - Texture2D *tex = TextureCache::getInstance()->addImage(fileImage); + Texture2D *tex = Director::getInstance()->getTextureCache()->addImage(fileImage); return initWithTexture(tex, capacity); } diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp index c7e2946172..7120c4b821 100644 --- a/cocos/2d/CCParticleExamples.cpp +++ b/cocos/2d/CCParticleExamples.cpp @@ -42,7 +42,7 @@ static Texture2D* getDefaultTexture() { bool bRet = false; const char* key = "/__firePngData"; - texture = TextureCache::getInstance()->getTextureForKey(key); + texture = Director::getInstance()->getTextureCache()->getTextureForKey(key); CC_BREAK_IF(texture != NULL); pImage = new Image(); @@ -50,7 +50,7 @@ static Texture2D* getDefaultTexture() bRet = pImage->initWithImageData(__firePngData, sizeof(__firePngData)); CC_BREAK_IF(!bRet); - texture = TextureCache::getInstance()->addImage(pImage, key); + texture = Director::getInstance()->getTextureCache()->addImage(pImage, key); } while (0); CC_SAFE_RELEASE(pImage); diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index 21c473f2f2..cb2c4326f3 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -374,7 +374,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::strin // set not pop-up message box when load image failed bool bNotify = FileUtils::getInstance()->isPopupNotify(); FileUtils::getInstance()->setPopupNotify(false); - tex = TextureCache::getInstance()->addImage(textureName.c_str()); + tex = Director::getInstance()->getTextureCache()->addImage(textureName.c_str()); // reset the value of UIImage notify FileUtils::getInstance()->setPopupNotify(bNotify); } @@ -400,13 +400,13 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::strin CCASSERT( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData"); CC_BREAK_IF(!deflated); - // For android, we should retain it in VolatileTexture::addImage which invoked in TextureCache::getInstance()->addUIImage() + // For android, we should retain it in VolatileTexture::addImage which invoked in Director::getInstance()->getTextureCache()->addUIImage() image = new Image(); bool isOK = image->initWithImageData(deflated, deflatedLen); CCASSERT(isOK, "CCParticleSystem: error init image with Data"); CC_BREAK_IF(!isOK); - setTexture(TextureCache::getInstance()->addImage(image, textureName.c_str())); + setTexture(Director::getInstance()->getTextureCache()->addImage(image, textureName.c_str())); image->release(); } diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index fa6f4878b0..98680b0ea3 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -219,7 +219,7 @@ bool Sprite::initWithFile(const std::string& filename) { CCASSERT(filename.size()>0, "Invalid filename for sprite"); - Texture2D *texture = TextureCache::getInstance()->addImage(filename); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); if (texture) { Rect rect = Rect::ZERO; @@ -237,7 +237,7 @@ bool Sprite::initWithFile(const std::string &filename, const Rect& rect) { CCASSERT(filename.size()>0, "Invalid filename"); - Texture2D *texture = TextureCache::getInstance()->addImage(filename); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); if (texture) { return initWithTexture(texture, rect); @@ -284,7 +284,7 @@ Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey) CCASSERT(pImage != NULL); // XXX: possible bug. See issue #349. New API should be added - Texture2D *texture = TextureCache::getInstance()->addCGImage(pImage, pszKey); + Texture2D *texture = Director::getInstance()->getTextureCache()->addCGImage(pImage, pszKey); const Size& size = texture->getContentSize(); Rect rect = Rect(0 ,0, size.width, size.height); @@ -1107,7 +1107,7 @@ void Sprite::setTexture(Texture2D *texture) if (NULL == texture) { // Gets the texture by key firstly. - texture = TextureCache::getInstance()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); + texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); // If texture wasn't in cache, create it from RAW data. if (NULL == texture) @@ -1116,7 +1116,7 @@ void Sprite::setTexture(Texture2D *texture) bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); - texture = TextureCache::getInstance()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); + texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); CC_SAFE_RELEASE(image); } } diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 820a999401..f13a306aa2 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -114,7 +114,7 @@ bool SpriteBatchNode::init() */ bool SpriteBatchNode::initWithFile(const char* fileImage, long capacity) { - Texture2D *texture2D = TextureCache::getInstance()->addImage(fileImage); + Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage); return initWithTexture(texture2D, capacity); } diff --git a/cocos/2d/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp index d2fd2c2495..06ca1b80c5 100644 --- a/cocos/2d/CCSpriteFrame.cpp +++ b/cocos/2d/CCSpriteFrame.cpp @@ -180,7 +180,7 @@ Texture2D* SpriteFrame::getTexture(void) } if( _textureFilename.length() > 0 ) { - return TextureCache::getInstance()->addImage(_textureFilename.c_str()); + return Director::getInstance()->getTextureCache()->addImage(_textureFilename.c_str()); } // no texture or texture filename return NULL; diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index 7ab33b85fe..f5afd18f76 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "CCString.h" #include "CCArray.h" #include "CCDictionary.h" +#include "CCDirector.h" #include using namespace std; @@ -215,7 +216,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Text void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) { CCASSERT(textureFileName.size()>0, "texture name should not be null"); - Texture2D *texture = TextureCache::getInstance()->addImage(textureFileName); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(textureFileName); if (texture) { @@ -265,7 +266,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist) CCLOG("cocos2d: SpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); } - Texture2D *texture = TextureCache::getInstance()->addImage(texturePath.c_str()); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(texturePath.c_str()); if (texture) { diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 4b801ea83e..aa48b8b2b4 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -58,7 +58,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la Texture2D *texture = NULL; if( tilesetInfo ) { - texture = TextureCache::getInstance()->addImage(tilesetInfo->_sourceImage.c_str()); + texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage.c_str()); } if (SpriteBatchNode::initWithTexture(texture, (unsigned int)capacity)) diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index 3ef2a365c4..f19a2f5f87 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCNotificationCenter.h" #include "CCEventType.h" +#include "CCDirector.h" #include "CCGL.h" // support #include "CCTexture2D.h" @@ -134,7 +135,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, long capacity bool TextureAtlas::initWithFile(const char * file, long capacity) { // retained in property - Texture2D *texture = TextureCache::getInstance()->addImage(file); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file); if (texture) { diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index 154d2b0b36..5dd2a20624 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -833,7 +833,7 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type) { spriteFile = _CCBRootPath + spriteFile; - Texture2D *texture = TextureCache::getInstance()->addImage(spriteFile.c_str()); + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = SpriteFrame::createWithTexture(texture, bounds); diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index e82764ce86..7eba8e9340 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -577,7 +577,7 @@ SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent, if (spriteSheet.length() == 0) { spriteFile = ccbReader->getCCBRootPath() + spriteFile; - Texture2D * texture = TextureCache::getInstance()->addImage(spriteFile.c_str()); + Texture2D * texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); if(texture != NULL) { Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = SpriteFrame::createWithTexture(texture, bounds); @@ -635,7 +635,7 @@ Texture2D * NodeLoader::parsePropTypeTexture(Node * pNode, Node * pParent, CCBRe if (spriteFile.length() > 0) { - return TextureCache::getInstance()->addImage(spriteFile.c_str()); + return Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); } else { diff --git a/cocos/editor-support/spine/spine-cocos2dx.cpp b/cocos/editor-support/spine/spine-cocos2dx.cpp index dbc389db51..298031aaab 100644 --- a/cocos/editor-support/spine/spine-cocos2dx.cpp +++ b/cocos/editor-support/spine/spine-cocos2dx.cpp @@ -31,7 +31,7 @@ USING_NS_CC; namespace spine { void _AtlasPage_createTexture (AtlasPage* self, const char* path) { - Texture2D* texture = TextureCache::getInstance()->addImage(path); + Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path); TextureAtlas* textureAtlas = TextureAtlas::createWithTexture(texture, 4); textureAtlas->retain(); self->rendererObject = textureAtlas; From cbb9c655d962577f5ed586bfed56b7d1d93a7edf Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 7 Nov 2013 21:10:48 +0800 Subject: [PATCH 019/185] fixed bugs --- .../UILoadingBarTest/UILoadingBarTest.cpp | 83 ++++++++++++++----- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 18b150ef6d..f031bc87e8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -67,20 +67,29 @@ void UILoadingBarTest_Left::update(float delta) void UILoadingBarTest_Left::previousCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::previousCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::previousCallback(sender, type); + } } void UILoadingBarTest_Left::restartCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::restartCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::restartCallback(sender, type); + } } void UILoadingBarTest_Left::nextCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::nextCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::nextCallback(sender, type); + } } // UILoadingBarTest_Right @@ -142,20 +151,29 @@ void UILoadingBarTest_Right::update(float delta) void UILoadingBarTest_Right::previousCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::previousCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::previousCallback(sender, type); + } } void UILoadingBarTest_Right::restartCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::restartCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::restartCallback(sender, type); + } } void UILoadingBarTest_Right::nextCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::nextCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::nextCallback(sender, type); + } } // UILoadingBarTest_Left_Scale9 @@ -219,20 +237,29 @@ void UILoadingBarTest_Left_Scale9::update(float delta) void UILoadingBarTest_Left_Scale9::previousCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::previousCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::previousCallback(sender, type); + } } void UILoadingBarTest_Left_Scale9::restartCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::restartCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::restartCallback(sender, type); + } } void UILoadingBarTest_Left_Scale9::nextCallback(Object* sender, TouchEventType type) { - unscheduleUpdate(); - UIScene::nextCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::nextCallback(sender, type); + } } // UILoadingBarTest_Right_Scale9 @@ -290,22 +317,34 @@ void UILoadingBarTest_Right_Scale9::update(float delta) { m_nCount = 0; } - + CCLOG("wocao"); UILoadingBar* loadingBar = dynamic_cast(m_pUiLayer->getWidgetByName("LoadingBar")); loadingBar->setPercent(m_nCount); } void UILoadingBarTest_Right_Scale9::previousCallback(Object* sender, TouchEventType type) { - UIScene::previousCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::previousCallback(sender, type); + } } void UILoadingBarTest_Right_Scale9::restartCallback(Object* sender, TouchEventType type) { - UIScene::restartCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::restartCallback(sender, type); + } } void UILoadingBarTest_Right_Scale9::nextCallback(Object* sender, TouchEventType type) { - UIScene::nextCallback(sender, type); + if (type == TOUCH_EVENT_ENDED) + { + unscheduleUpdate(); + UIScene::nextCallback(sender, type); + } } \ No newline at end of file From c69163559b2a0f2a829163be2fb580a47e8aca1d Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 7 Nov 2013 21:26:56 +0800 Subject: [PATCH 020/185] Move some method from helper to reader --- .../cocostudio/CCSGUIReader.cpp | 28 ++++++++++++++++--- .../editor-support/cocostudio/CCSGUIReader.h | 4 +++ cocos/gui/UIHelper.cpp | 23 --------------- cocos/gui/UIHelper.h | 4 --- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index f799c26752..3ad788b563 100755 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -40,12 +40,13 @@ CCSGUIReader::CCSGUIReader(): m_strFilePath(""), m_bOlderVersion(false) { - + _fileDesignSizes = Dictionary::create(); + CC_SAFE_RETAIN(_fileDesignSizes); } CCSGUIReader::~CCSGUIReader() { - + CC_SAFE_RELEASE(_fileDesignSizes); } CCSGUIReader* CCSGUIReader::shareReader() @@ -197,7 +198,26 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) return widget; } +void CCSGUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) +{ + if (!_fileDesignSizes) + { + _fileDesignSizes = cocos2d::Dictionary::create(); + _fileDesignSizes->retain(); + } + cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); + _fileDesignSizes->setObject(strSize, fileName); +} +const cocos2d::Size CCSGUIReader::getFileDesignSize(const char* fileName) const +{ + if (!_fileDesignSizes) + { + return cocos2d::Size::ZERO; + } + cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)_fileDesignSizes->objectForKey(fileName))->_string.c_str()); + return designSize; +} UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) { @@ -240,11 +260,11 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) { printf("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); - UIHelper::setFileDesignSize(fileName, winSize); + storeFileDesignSize(fileName, winSize); } else { - UIHelper::setFileDesignSize(fileName, cocos2d::Size(fileDesignWidth, fileDesignHeight)); + storeFileDesignSize(fileName, cocos2d::Size(fileDesignWidth, fileDesignHeight)); } JsonDictionary* widgetTree = DICTOOL->getSubDictionary_json(jsonDict, "widgetTree"); UIWidget* widget = widgetFromJsonDictionary(widgetTree); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index d39c349ee0..415b7b9e81 100755 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -65,9 +65,13 @@ public: void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); void setPropsForDragPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + void storeFileDesignSize(const char* fileName, const cocos2d::Size &size); + + const cocos2d::Size getFileDesignSize(const char* fileName) const; protected: std::string m_strFilePath; bool m_bOlderVersion; + cocos2d::Dictionary* _fileDesignSizes; }; } diff --git a/cocos/gui/UIHelper.cpp b/cocos/gui/UIHelper.cpp index 8b43c8f890..d896a6372c 100644 --- a/cocos/gui/UIHelper.cpp +++ b/cocos/gui/UIHelper.cpp @@ -25,8 +25,6 @@ #include "CocosGUI.h" namespace gui { - -static cocos2d::Dictionary* fileDesignSizes = NULL; UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag) { @@ -120,26 +118,5 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag) } return NULL; } - -void UIHelper::setFileDesignSize(const char *fileName, const cocos2d::Size &size) -{ - if (!fileDesignSizes) - { - fileDesignSizes = cocos2d::Dictionary::create(); - fileDesignSizes->retain(); - } - cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); - fileDesignSizes->setObject(strSize, fileName); -} - -const cocos2d::Size UIHelper::getFileDesignSize(const char* fileName) -{ - if (!fileDesignSizes) - { - return cocos2d::Size::ZERO; - } - cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)fileDesignSizes->objectForKey(fileName))->_string.c_str()); - return designSize; -} } \ No newline at end of file diff --git a/cocos/gui/UIHelper.h b/cocos/gui/UIHelper.h index 68893ceff0..838875adf4 100644 --- a/cocos/gui/UIHelper.h +++ b/cocos/gui/UIHelper.h @@ -71,10 +71,6 @@ public: /*temp action*/ static UIWidget* seekActionWidgetByActionTag(UIWidget* root, int tag); - - static void setFileDesignSize(const char* fileName, const cocos2d::Size &size); - - static const cocos2d::Size getFileDesignSize(const char* fileName); }; } From bd7d62aee04cb4dcebb04398a9bec4ba8abddfdf Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 7 Nov 2013 21:48:39 +0800 Subject: [PATCH 021/185] issue #3025: replace TextureCache::getInstance() by Director::getInstance()->getTextureCache() in samples folder --- .../TestCpp/Classes/Box2DTest/Box2dTest.cpp | 2 +- .../Classes/ChipmunkTest/ChipmunkTest.cpp | 2 +- .../ClippingNodeTest/ClippingNodeTest.cpp | 2 +- .../DataVisitorTest/DataVisitorTest.cpp | 2 +- .../Classes/IntervalTest/IntervalTest.cpp | 2 +- .../Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp | 4 +- .../Classes/ParticleTest/ParticleTest.cpp | 46 +++--- .../PerformanceParticleTest.cpp | 20 +-- .../PerformanceTest/PerformanceSpriteTest.cpp | 2 +- .../PerformanceTextureTest.cpp | 4 +- .../RenderTextureTest/RenderTextureTest.cpp | 4 +- .../Classes/SchedulerTest/SchedulerTest.cpp | 2 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- .../Classes/Texture2dTest/Texture2dTest.cpp | 146 +++++++++--------- .../TextureCacheTest/TextureCacheTest.cpp | 40 ++--- .../Classes/TouchesTest/TouchesTest.cpp | 4 +- 16 files changed, 142 insertions(+), 142 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index ca75a9efe3..ba9d1982fe 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -29,7 +29,7 @@ Box2DTestLayer::Box2DTestLayer() _spriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower - _spriteTexture = TextureCache::getInstance()->addImage("Images/blocks.png"); + _spriteTexture = Director::getInstance()->getTextureCache()->addImage("Images/blocks.png"); auto parent = Node::create(); #endif addChild(parent, 0, kTagParentNode); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 50d5dc7252..aad89f259d 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -46,7 +46,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() _spriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower - _spriteTexture = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas.png"); + _spriteTexture = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas.png"); auto parent = Node::create(); #endif addChild(parent, 0, kTagParentNode); diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 93e26514a2..f69ba49240 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -107,7 +107,7 @@ bool BaseClippingNodeTest::init() BaseClippingNodeTest::~BaseClippingNodeTest() { - TextureCache::getInstance()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); } std::string BaseClippingNodeTest::title() diff --git a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp index 4f8a1fb932..aeed903837 100644 --- a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp @@ -71,7 +71,7 @@ void PrettyPrinterDemo::onEnter() vistor.clear(); addSprite(); -// dict = TextureCache::getInstance()->snapshotTextures(); +// dict = Director::getInstance()->getTextureCache()->snapshotTextures(); // dict->acceptVisitor(vistor); // log("%s", vistor.getResult().c_str()); } diff --git a/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp b/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp index da9fefdca9..3771b1e2aa 100644 --- a/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp +++ b/samples/Cpp/TestCpp/Classes/IntervalTest/IntervalTest.cpp @@ -16,7 +16,7 @@ IntervalLayer::IntervalLayer() auto s = Director::getInstance()->getWinSize(); // sun auto sun = ParticleSun::create(); - sun->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + sun->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); sun->setPosition( Point(VisibleRect::rightTop().x-32,VisibleRect::rightTop().y-32) ); sun->setTotalParticles(130); diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index 82a8a6ebcb..1b2655680f 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -359,7 +359,7 @@ void StressTest1::shouldNotCrash(float dt) // if the node has timers, it crashes auto explosion = ParticleSun::create(); - explosion->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + explosion->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); // if it doesn't, it works Ok. // auto explosion = [Sprite create:@"grossinis_sister2.png"); @@ -409,7 +409,7 @@ StressTest2::StressTest2() sublayer->addChild(sp1, 1); auto fire = ParticleFire::create(); - fire->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + fire->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); fire->setPosition( Point(80, s.height/2-50) ); auto copy_seq3 = seq3->clone(); diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index d238482244..c4e3b15bad 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -22,7 +22,7 @@ void DemoFirework::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); setEmitterPosition(); } @@ -46,7 +46,7 @@ void DemoFire::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) );//.pvr"); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) );//.pvr"); auto p = _emitter->getPosition(); _emitter->setPosition( Point(p.x, 100) ); @@ -71,7 +71,7 @@ void DemoSun::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); setEmitterPosition(); } @@ -94,7 +94,7 @@ void DemoGalaxy::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); setEmitterPosition(); } @@ -116,7 +116,7 @@ void DemoFlower::onEnter() _emitter = ParticleFlower::create(); _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); setEmitterPosition(); } @@ -141,7 +141,7 @@ void DemoBigFlower::onEnter() _background->addChild(_emitter, 10); ////_emitter->release(); // win32 : use this line or remove this line and use autorelease() - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); _emitter->setDuration(-1); @@ -225,7 +225,7 @@ void DemoRotFlower::onEnter() _background->addChild(_emitter, 10); ////_emitter->release(); // win32 : Remove this line - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars2) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars2) ); // duration _emitter->setDuration(-1); @@ -308,7 +308,7 @@ void DemoMeteor::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); setEmitterPosition(); } @@ -331,7 +331,7 @@ void DemoSpiral::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); setEmitterPosition(); } @@ -354,7 +354,7 @@ void DemoExplosion::onEnter() _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); _emitter->setAutoRemoveOnFinish(true); @@ -378,7 +378,7 @@ void DemoSmoke::onEnter() _emitter = ParticleSmoke::create(); _emitter->retain(); _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); auto p = _emitter->getPosition(); _emitter->setPosition( Point( p.x, 100) ); @@ -429,7 +429,7 @@ void DemoSnow::onEnter() _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_snow) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_snow) ); setEmitterPosition(); } @@ -456,7 +456,7 @@ void DemoRain::onEnter() _emitter->setPosition( Point( p.x, p.y-100) ); _emitter->setLife(4); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); setEmitterPosition(); } @@ -540,7 +540,7 @@ void DemoModernArt::onEnter() _emitter->setEndSizeVar(8.0f); // texture - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); // additive _emitter->setBlendAdditive(false); @@ -567,7 +567,7 @@ void DemoRing::onEnter() _background->addChild(_emitter, 10); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); _emitter->setLifeVar(0); _emitter->setLife(10); _emitter->setSpeed(100); @@ -605,14 +605,14 @@ void ParallaxParticle::onEnter() _emitter = ParticleFlower::create(); _emitter->retain(); - _emitter->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); p1->addChild(_emitter, 10); _emitter->setPosition( Point(250,200) ); auto par = ParticleSun::create(); p2->addChild(par, 10); - par->setTexture( TextureCache::getInstance()->addImage(s_fire) ); + par->setTexture( Director::getInstance()->getTextureCache()->addImage(s_fire) ); auto move = MoveBy::create(4, Point(300,0)); auto move_back = move->reverse(); @@ -641,7 +641,7 @@ void RadiusMode1::onEnter() _emitter = new ParticleSystemQuad(); _emitter->initWithTotalParticles(200); addChild(_emitter, 10); - _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); + _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/stars-grayscale.png")); // duration _emitter->setDuration(ParticleSystem::DURATION_INFINITY); @@ -725,7 +725,7 @@ void RadiusMode2::onEnter() _emitter = new ParticleSystemQuad(); _emitter->initWithTotalParticles(200); addChild(_emitter, 10); - _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); + _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/stars-grayscale.png")); // duration _emitter->setDuration(ParticleSystem::DURATION_INFINITY); @@ -809,7 +809,7 @@ void Issue704::onEnter() _emitter = new ParticleSystemQuad(); _emitter->initWithTotalParticles(100); addChild(_emitter, 10); - _emitter->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); // duration _emitter->setDuration(ParticleSystem::DURATION_INFINITY); @@ -900,7 +900,7 @@ void Issue870::onEnter() auto system = new ParticleSystemQuad(); system->initWithFile("Particles/SpinningPeas.plist"); - system->setTextureWithRect(TextureCache::getInstance()->addImage("Images/particles.png"), Rect(0,0,32,32)); + system->setTextureWithRect(Director::getInstance()->getTextureCache()->addImage("Images/particles.png"), Rect(0,0,32,32)); addChild(system, 10); _emitter = system; @@ -1452,7 +1452,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - setTexture(TextureCache::getInstance()->addImage("Images/particles.png")); + setTexture(Director::getInstance()->getTextureCache()->addImage("Images/particles.png")); return true; } @@ -1504,7 +1504,7 @@ void MultipleParticleSystems::onEnter() removeChild(_background, true); _background = NULL; - TextureCache::getInstance()->addImage("Images/particles.png"); + Director::getInstance()->getTextureCache()->addImage("Images/particles.png"); for (int i = 0; i<5; i++) { auto particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index b72ad00da5..b6878a5b22 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -187,8 +187,8 @@ void ParticleMainScene::createParticleSystem() removeChildByTag(kTagParticleSystem, true); // remove the "fire.png" from the TextureCache cache. - auto texture = TextureCache::getInstance()->addImage("Images/fire.png"); - TextureCache::getInstance()->removeTexture(texture); + auto texture = Director::getInstance()->getTextureCache()->addImage("Images/fire.png"); + Director::getInstance()->getTextureCache()->removeTexture(texture); //TODO: if (subtestNumber <= 3) // { @@ -204,42 +204,42 @@ void ParticleMainScene::createParticleSystem() case 1: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 2: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 3: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; // case 4: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"]; -// particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); +// particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); // break; case 4: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 5: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 6: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); - particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); + particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; // case 8: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"]; -// particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); +// particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); // break; default: particleSystem = NULL; diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index 7e290e5e5b..ccf4ca602d 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -52,7 +52,7 @@ void SubTest::initWithSubTest(int nSubTest, Node* p) */ // purge textures - auto mgr = TextureCache::getInstance(); + auto mgr = Director::getInstance()->getTextureCache(); // [mgr removeAllTextures]; mgr->removeTexture(mgr->addImage("Images/grossinis_sister1.png")); mgr->removeTexture(mgr->addImage("Images/grossini_dance_atlas.png")); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp index bcbae20aa1..0da9efd0ec 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -84,7 +84,7 @@ void TextureTest::performTestsPNG(const char* filename) { struct timeval now; Texture2D *texture; - auto cache = TextureCache::getInstance(); + auto cache = Director::getInstance()->getTextureCache(); log("RGBA 8888"); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); @@ -131,7 +131,7 @@ void TextureTest::performTests() { // Texture2D *texture; // struct timeval now; -// auto cache = TextureCache::getInstance(); +// auto cache = Director::getInstance()->getTextureCache(); log("--------"); diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index baf174ac9b..987d8b8f05 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -156,7 +156,7 @@ void RenderTextureSave::saveImage(cocos2d::Object *sender) auto image = _target->newImage(); - auto tex = TextureCache::getInstance()->addImage(image, png); + auto tex = Director::getInstance()->getTextureCache()->addImage(image, png); CC_SAFE_DELETE(image); @@ -176,7 +176,7 @@ RenderTextureSave::~RenderTextureSave() { _brush->release(); _target->release(); - TextureCache::getInstance()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); } void RenderTextureSave::onTouchesMoved(const std::vector& touches, Event* event) diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index 96ee66292b..d225e1c8f8 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -924,7 +924,7 @@ void SchedulerTimeScale::onEnter() kathia->runAction(Speed::create(action3, 1.0f)); auto emitter = ParticleFireworks::create(); - emitter->setTexture( TextureCache::getInstance()->addImage(s_stars1) ); + emitter->setTexture( Director::getInstance()->getTextureCache()->addImage(s_stars1) ); addChild(emitter); _sliderCtl = sliderCtl(); diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 499b1b8dfe..09b2f61d9d 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -71aa9486e8535b9bd65cae247bb86de59c83f522 \ No newline at end of file +ddd085a82dc104bac66268a7ddcdf9b0c32cb4ee \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 8184bc1467..6245237ca8 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -129,18 +129,18 @@ void TextureDemo::onEnter() { BaseTest::onEnter(); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); auto col = LayerColor::create(Color4B(128,128,128,255)); addChild(col, -10); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } TextureDemo::~TextureDemo() { - TextureCache::getInstance()->removeUnusedTextures(); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } void TextureDemo::restartCallback(Object* sender) @@ -191,7 +191,7 @@ void TextureTIFF::onEnter() auto img = Sprite::create("Images/test_image.tiff"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); this->addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureTIFF::title() @@ -213,7 +213,7 @@ void TexturePNG::onEnter() auto img = Sprite::create("Images/test_image.png"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePNG::title() @@ -234,7 +234,7 @@ void TextureJPEG::onEnter() auto img = Sprite::create("Images/test_image.jpeg"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureJPEG::title() @@ -255,7 +255,7 @@ void TextureWEBP::onEnter() auto img = Sprite::create("Images/test_image.webp"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureWEBP::title() @@ -273,12 +273,12 @@ void TextureMipMap::onEnter() TextureDemo::onEnter(); auto s = Director::getInstance()->getWinSize(); - auto texture0 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas.png"); + auto texture0 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas.png"); texture0->generateMipmap(); Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; texture0->setTexParameters(texParams); - auto texture1 = TextureCache::getInstance()->addImage("Images/grossini_dance_atlas_nomipmap.png"); + auto texture1 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png"); auto img0 = Sprite::createWithTexture(texture0); img0->setTextureRect(Rect(85, 121, 85, 121)); @@ -299,7 +299,7 @@ void TextureMipMap::onEnter() img0->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL))); img1->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL))); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureMipMap::title() @@ -350,7 +350,7 @@ void TexturePVRMipMap::onEnter() imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL))); img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL))); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRMipMap::title() @@ -392,7 +392,7 @@ void TexturePVRMipMap2::onEnter() imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL))); img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL))); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRMipMap2::title() @@ -424,7 +424,7 @@ void TexturePVR2BPP::onEnter() img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVR2BPP::title() @@ -455,7 +455,7 @@ void TexturePVRTest::onEnter() { log("This test is not supported."); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } @@ -487,7 +487,7 @@ void TexturePVR4BPP::onEnter() { log("This test is not supported in cocos2d-mac"); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVR4BPP::title() @@ -510,7 +510,7 @@ void TexturePVRRGBA8888::onEnter() auto img = Sprite::create("Images/test_image_rgba8888.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGBA8888::title() @@ -540,7 +540,7 @@ void TexturePVRBGRA8888::onEnter() { log("BGRA8888 images are not supported"); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRBGRA8888::title() @@ -563,7 +563,7 @@ void TexturePVRRGBA5551::onEnter() auto img = Sprite::create("Images/test_image_rgba5551.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGBA5551::title() @@ -586,7 +586,7 @@ void TexturePVRRGBA4444::onEnter() auto img = Sprite::create("Images/test_image_rgba4444.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGBA4444::title() @@ -614,7 +614,7 @@ void TexturePVRRGBA4444GZ::onEnter() #endif img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGBA4444GZ::title() @@ -642,7 +642,7 @@ void TexturePVRRGBA4444CCZ::onEnter() auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGBA4444CCZ::title() @@ -670,7 +670,7 @@ void TexturePVRRGB565::onEnter() auto img = Sprite::create("Images/test_image_rgb565.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGB565::title() @@ -693,7 +693,7 @@ void TexturePVRRGB888::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRRGB888::title() @@ -716,7 +716,7 @@ void TexturePVRA8::onEnter() auto img = Sprite::create("Images/test_image_a8.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } @@ -740,7 +740,7 @@ void TexturePVRI8::onEnter() auto img = Sprite::create("Images/test_image_i8.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRI8::title() @@ -763,7 +763,7 @@ void TexturePVRAI88::onEnter() auto img = Sprite::create("Images/test_image_ai88.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRAI88::title() @@ -785,7 +785,7 @@ void TexturePVR2BPPv3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVR2BPPv3::title() @@ -812,7 +812,7 @@ void TexturePVRII2BPPv3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRII2BPPv3::title() @@ -843,7 +843,7 @@ void TexturePVR4BPPv3::onEnter() log("This test is not supported"); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVR4BPPv3::title() @@ -878,7 +878,7 @@ void TexturePVRII4BPPv3::onEnter() log("This test is not supported"); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRII4BPPv3::title() @@ -905,7 +905,7 @@ void TexturePVRRGBA8888v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRRGBA8888v3::title() @@ -936,7 +936,7 @@ void TexturePVRBGRA8888v3::onEnter() log("BGRA images are not supported"); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRBGRA8888v3::title() @@ -963,7 +963,7 @@ void TexturePVRRGBA5551v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRRGBA5551v3::title() @@ -990,7 +990,7 @@ void TexturePVRRGBA4444v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRRGBA4444v3::title() @@ -1017,7 +1017,7 @@ void TexturePVRRGB565v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRRGB565v3::title() @@ -1044,7 +1044,7 @@ void TexturePVRRGB888v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRRGB888v3::title() @@ -1071,7 +1071,7 @@ void TexturePVRA8v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRA8v3::title() @@ -1098,7 +1098,7 @@ void TexturePVRI8v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRI8v3::title() @@ -1125,7 +1125,7 @@ void TexturePVRAI88v3::onEnter() addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } string TexturePVRAI88v3::title() @@ -1181,7 +1181,7 @@ void TexturePVRNonSquare::onEnter() auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr"); img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRNonSquare::title() @@ -1210,7 +1210,7 @@ void TexturePVRNPOT4444::onEnter() img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRNPOT4444::title() @@ -1239,7 +1239,7 @@ void TexturePVRNPOT8888::onEnter() img->setPosition(Point( s.width/2.0f, s.height/2.0f)); addChild(img); } - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePVRNPOT8888::title() @@ -1293,7 +1293,7 @@ void TextureAlias::onEnter() sprite2->runAction(scaleforever); sprite->runAction(scaleToo); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureAlias::title() @@ -1334,7 +1334,7 @@ void TexturePixelFormat::onEnter() addChild(sprite1, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite1->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite1->getTexture()); // RGBA 4444 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); @@ -1343,7 +1343,7 @@ void TexturePixelFormat::onEnter() addChild(sprite2, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite2->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite2->getTexture()); // RGB5A1 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); @@ -1352,7 +1352,7 @@ void TexturePixelFormat::onEnter() addChild(sprite3, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite3->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite3->getTexture()); // RGB888 image Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB888); @@ -1361,7 +1361,7 @@ void TexturePixelFormat::onEnter() addChild(sprite4, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite4->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite4->getTexture()); // RGB565 image (16-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565); @@ -1370,7 +1370,7 @@ void TexturePixelFormat::onEnter() addChild(sprite5, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite5->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture()); // A8 image (8-bit) Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); @@ -1379,7 +1379,7 @@ void TexturePixelFormat::onEnter() addChild(sprite6, 0); // remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite6->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite6->getTexture()); auto fadeout = FadeOut::create(2); auto fadein = FadeIn::create(2); @@ -1398,7 +1398,7 @@ void TexturePixelFormat::onEnter() // restore default Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TexturePixelFormat::title() @@ -1486,7 +1486,7 @@ void TextureAsync::onEnter() TextureAsync::~TextureAsync() { - TextureCache::getInstance()->removeAllTextures(); + Director::getInstance()->getTextureCache()->removeAllTextures(); } void TextureAsync::loadImages(float dt) @@ -1495,15 +1495,15 @@ void TextureAsync::loadImages(float dt) for( int j=0;j < 8; j++) { char szSpriteName[100] = {0}; sprintf(szSpriteName, "Images/sprites_test/sprite-%d-%d.png", i, j); - TextureCache::getInstance()->addImageAsync(szSpriteName,this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync(szSpriteName,this, callfuncO_selector(TextureAsync::imageLoaded)); } } - TextureCache::getInstance()->addImageAsync("Images/background1.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); - TextureCache::getInstance()->addImageAsync("Images/background2.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); - TextureCache::getInstance()->addImageAsync("Images/background.png",this, callfuncO_selector(TextureAsync::imageLoaded)); - TextureCache::getInstance()->addImageAsync("Images/atlastest.png",this, callfuncO_selector(TextureAsync::imageLoaded)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_atlas.png",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background.png",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/atlastest.png",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_atlas.png",this, callfuncO_selector(TextureAsync::imageLoaded)); } @@ -1576,7 +1576,7 @@ std::string TextureGlClamp::title() TextureGlClamp::~TextureGlClamp() { - TextureCache::getInstance()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); } //------------------------------------------------------------------ @@ -1613,7 +1613,7 @@ std::string TextureGlRepeat::title() TextureGlRepeat::~TextureGlRepeat() { - TextureCache::getInstance()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); } //------------------------------------------------------------------ @@ -1684,7 +1684,7 @@ void TextureCache1::onEnter() sprite->setScale(2); addChild(sprite); - TextureCache::getInstance()->removeTexture(sprite->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture()); sprite = Sprite::create("Images/grossinis_sister1.png"); sprite->setPosition(Point(s.width/5*2, s.height/2)); @@ -1700,7 +1700,7 @@ void TextureCache1::onEnter() sprite->setScale(2); addChild(sprite); - TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister2.png"); + Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister2.png"); sprite = Sprite::create("Images/grossinis_sister2.png"); sprite->setPosition(Point(s.width/5*4, s.height/2)); @@ -1724,8 +1724,8 @@ void TextureDrawAtPoint::onEnter() { TextureDemo::onEnter(); - _tex1 = TextureCache::getInstance()->addImage("Images/grossinis_sister1.png"); - _Tex2F = TextureCache::getInstance()->addImage("Images/grossinis_sister2.png"); + _tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png"); + _Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png"); _tex1->retain(); _Tex2F->retain(); @@ -1763,8 +1763,8 @@ void TextureDrawAtPoint::draw() void TextureDrawInRect::onEnter() { TextureDemo::onEnter(); - _tex1 = TextureCache::getInstance()->addImage("Images/grossinis_sister1.png"); - _Tex2F = TextureCache::getInstance()->addImage("Images/grossinis_sister2.png"); + _tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png"); + _Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png"); _tex1->retain(); _Tex2F->retain(); @@ -1871,7 +1871,7 @@ void TextureMemoryAlloc::updateImage(cocos2d::Object *sender) _background->removeFromParentAndCleanup(true); } - TextureCache::getInstance()->removeUnusedTextures(); + Director::getInstance()->getTextureCache()->removeUnusedTextures(); int tag = ((Node*)sender)->getTag(); string file; @@ -1952,7 +1952,7 @@ TexturePVRv3Premult::TexturePVRv3Premult() // PNG Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); - TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); + Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); auto png = Sprite::create("Images/grossinis_sister1-testalpha.png"); addChild(png, 0); png->setPosition(Point(size.width/4*3, size.height/2)); @@ -2132,7 +2132,7 @@ static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path demo.addChild(sprite, 0); //remove texture from texture manager - TextureCache::getInstance()->removeTexture(sprite->getTexture()); + Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture()); } //TextureConvertRGB888 @@ -2157,7 +2157,7 @@ void TextureConvertRGB888::onEnter() // restore default Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureConvertRGB888::title() @@ -2191,7 +2191,7 @@ void TextureConvertRGBA8888::onEnter() // restore default Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureConvertRGBA8888::title() @@ -2225,7 +2225,7 @@ void TextureConvertI8::onEnter() // restore default Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureConvertI8::title() @@ -2259,7 +2259,7 @@ void TextureConvertAI88::onEnter() // restore default Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); - TextureCache::getInstance()->dumpCachedTextureInfo(); + Director::getInstance()->getTextureCache()->dumpCachedTextureInfo(); } std::string TextureConvertAI88::title() diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp index 32d9660ce4..698a2935fd 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -21,26 +21,26 @@ TextureCacheTest::TextureCacheTest() this->addChild(_labelPercent); // load textrues - TextureCache::getInstance()->addImageAsync("Images/HelloWorld.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_01.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_02.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_03.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_04.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_05.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_06.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_07.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_08.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_09.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_10.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_11.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_12.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_13.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/grossini_dance_14.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/background1.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/background2.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/background3.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - TextureCache::getInstance()->addImageAsync("Images/blocks.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/HelloWorld.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_01.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_02.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_03.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_04.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_05.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_06.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_07.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_08.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_09.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_10.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_11.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_12.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_13.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_14.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background3.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/blocks.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); } void TextureCacheTest::loadingCallBack(Object *obj) diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp index 6c57cac1b5..ef695368ff 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp @@ -39,13 +39,13 @@ PongLayer::PongLayer() { _ballStartingVelocity = Point(20.0f, -100.0f); - _ball = Ball::ballWithTexture( TextureCache::getInstance()->addImage(s_Ball) ); + _ball = Ball::ballWithTexture( Director::getInstance()->getTextureCache()->addImage(s_Ball) ); _ball->setPosition( VisibleRect::center() ); _ball->setVelocity( _ballStartingVelocity ); addChild( _ball ); _ball->retain(); - auto paddleTexture = TextureCache::getInstance()->addImage(s_Paddle); + auto paddleTexture = Director::getInstance()->getTextureCache()->addImage(s_Paddle); auto paddlesM = Array::createWithCapacity(4); From 16d572c04f15862beda5f77864c00986607f3218 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Thu, 7 Nov 2013 23:22:11 +0800 Subject: [PATCH 022/185] issue #2868:Add manual lua binding files --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/scripting/lua/bindings/CCLuaStack.cpp | 2 + .../lua/bindings/LuaScriptHandlerMgr.h | 3 + .../lua_cocos2dx_coco_studio_manual.cpp | 156 ++++++++++++++++++ .../lua_cocos2dx_coco_studio_manual.hpp | 14 ++ .../lua_cocos2dx_extension_manual.cpp | 27 ++- 6 files changed, 188 insertions(+), 16 deletions(-) create mode 100644 cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp create mode 100644 cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 1ebbc707a8..3ebc972a25 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -30ca6c02884f9bc20405b3e657b444c0153bead7 \ No newline at end of file +f23edaa553632b07289418f9ccfae1f4f5bc1a3c \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index a0269bf318..9016d111df 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.cpp +++ b/cocos/scripting/lua/bindings/CCLuaStack.cpp @@ -55,6 +55,7 @@ extern "C" { #include "lua_cocos2dx_deprecated.h" #include "lua_xml_http_request.h" #include "lua_cocos2dx_studio_auto.hpp" +#include "lua_cocos2dx_coco_studio_manual.hpp" namespace { int lua_print(lua_State * luastate) @@ -140,6 +141,7 @@ bool LuaStack::init(void) register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); register_all_cocos2dx_manual_deprecated(_state); + register_all_cocos2dx_coco_studio_manual(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h index 2f8a769cc3..de42b36e9d 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h @@ -101,6 +101,9 @@ public: ASSETSMANAGER_PROGRESS, ASSETSMANAGER_SUCCESS, ASSETSMANAGER_ERROR, + + EVENT_LISTENER, + EVENT_TOUCH_LISTENER, }; typedef int Handler; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp new file mode 100644 index 0000000000..b2ebe663b0 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -0,0 +1,156 @@ +#include "lua_cocos2dx_coco_studio_manual.hpp" + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua_fix.h" +#ifdef __cplusplus +} +#endif + +#include "cocos2d.h" +#include "LuaBasicConversions.h" +#include "LuaScriptHandlerMgr.h" +#include "CCLuaValue.h" +#include "CocosGUI.h" + +using namespace gui; + +class LuaCocoStudioEventListener:public Object +{ +public: + LuaCocoStudioEventListener(); + virtual ~LuaCocoStudioEventListener(); + + virtual void setObjToLua(Object* obj); + + static LuaCocoStudioEventListener* create(); + + virtual void eventCallbackFunc(Object* sender,int eventType) + { + if (nullptr == sender) + return; + + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + if (0 != handler) + { + //call lua funtion + } + } + + + +private: + Object* _objToLua; +}; + +LuaCocoStudioEventListener::LuaCocoStudioEventListener():_objToLua(nullptr) +{ + +} + +LuaCocoStudioEventListener::~LuaCocoStudioEventListener() +{ + if (nullptr != _objToLua) + _objToLua->release(); +} + +LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() +{ + LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); + if (nullptr == listener) + return nullptr; + + listener->autorelease(); + + return listener; +} + +void LuaCocoStudioEventListener::setObjToLua(Object* obj) +{ + if (nullptr != _objToLua) + _objToLua->release(); + + _objToLua = obj; + _objToLua->retain(); +} + +static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) +{ + if (NULL == L) + return 0; + + int argc = 0; + UICheckBox* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UICheckBox",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + listern->setObjToLua(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->addEventListener(listern, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListener' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendUICheckBox(lua_State* L) +{ + lua_pushstring(L, "UICheckBox"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_UICheckBox_addEventListener); + } +} + +int register_all_cocos2dx_coco_studio_manual(lua_State* L) +{ + if (nullptr == L) + return 0; + + extendUICheckBox(L); + + return 0; +} \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp new file mode 100644 index 0000000000..191a58438e --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp @@ -0,0 +1,14 @@ +#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H +#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L); + +#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index e74dbac377..c541fbdcc2 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -1495,7 +1495,14 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L) argc = lua_gettop(L) - 1; if (2 == argc) - { + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) || + !tolua_isnumber(L, 3, 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif LuaAssetsManagerDelegateProtocol* delegate = dynamic_cast( self->getDelegate()); if (nullptr == delegate) { @@ -1508,21 +1515,11 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L) delegate->release(); } - if (2 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) || - !tolua_isnumber(L, 3, 0, &tolua_err) ) - { - goto tolua_lerror; - } -#endif - LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0); - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); + LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0); + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType); - return 0; - } + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType); + return 0; } CCLOG("'setDelegate' function of AssetsManager has wrong number of arguments: %d, was expecting %d\n", argc, 2); From 916361af3f6cb0264201ad10834bd1c9d025710b Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Thu, 7 Nov 2013 23:40:33 +0800 Subject: [PATCH 023/185] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. --- cocos/base/CCGeometry.cpp | 9 +++++++++ cocos/base/CCGeometry.h | 19 +++++++++++++++++++ .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cocos/base/CCGeometry.cpp b/cocos/base/CCGeometry.cpp index 1d5c4896c6..b6b59f5b03 100644 --- a/cocos/base/CCGeometry.cpp +++ b/cocos/base/CCGeometry.cpp @@ -284,6 +284,15 @@ Point Point::getIntersectPoint(const Point& A, const Point& B, const Point& C, c } const Point Point::ZERO = Point(0, 0); +const Point Point::ANCHOR_MIDDLE = Point(0.5, 0.5); +const Point Point::ANCHOR_BOTTOM_LEFT = Point(0, 0); +const Point Point::ANCHOR_TOP_LEFT = Point(0, 1); +const Point Point::ANCHOR_BOTTOM_RIGHT = Point(1, 0); +const Point Point::ANCHOR_TOP_RIGHT = Point(1, 1); +const Point Point::ANCHOR_MIDDLE_RIGHT = Point(1, .5); +const Point Point::ANCHOR_MIDDLE_LEFT = Point(0, 0.5); +const Point Point::ANCHOR_MIDDLE_TOP = Point(0.5, 1); +const Point Point::ANCHOR_MIDDLE_BOTTOM = Point(0.5, 0); // implementation of Size diff --git a/cocos/base/CCGeometry.h b/cocos/base/CCGeometry.h index 847557cb35..0b3e30d208 100644 --- a/cocos/base/CCGeometry.h +++ b/cocos/base/CCGeometry.h @@ -423,7 +423,26 @@ public: */ static Point getIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D); + /** equals to Point(0,0) */ static const Point ZERO; + /** equals to Point(0.5, 0.5) */ + static const Point ANCHOR_MIDDLE; + /** equals to Point(0, 0) */ + static const Point ANCHOR_BOTTOM_LEFT; + /** equals to Point(0, 1) */ + static const Point ANCHOR_TOP_LEFT; + /** equals to Point(1, 0) */ + static const Point ANCHOR_BOTTOM_RIGHT; + /** equals to Point(1, 1) */ + static const Point ANCHOR_TOP_RIGHT; + /** equals to Point(1, 0.5) */ + static const Point ANCHOR_MIDDLE_RIGHT; + /** equals to Point(0, 0.5) */ + static const Point ANCHOR_MIDDLE_LEFT; + /** equals to Point(0.5, 1) */ + static const Point ANCHOR_MIDDLE_TOP; + /** equals to Point(0.5, 0) */ + static const Point ANCHOR_MIDDLE_BOTTOM; private: // returns true if segment A-B intersects with segment C-D. S->E is the ovderlap part diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 499b1b8dfe..c01845edff 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -71aa9486e8535b9bd65cae247bb86de59c83f522 \ No newline at end of file +dd564ef17f9cc0281964247923ec24957cad7bd0 \ No newline at end of file From 006d32f883ff2d220823d56c342b5b057b2b319c Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Thu, 7 Nov 2013 23:51:01 +0800 Subject: [PATCH 024/185] rename jsb boot file. --- template/multi-platform-js/Classes/AppDelegate.cpp | 2 +- .../multi-platform-js/Resources/{main.js => cocos2d-jsb.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename template/multi-platform-js/Resources/{main.js => cocos2d-jsb.js} (100%) diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index 4c2fea3abf..e409b974b5 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -47,7 +47,7 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptEngineProtocol *engine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(engine); - ScriptingCore::getInstance()->runScript("main.js"); + ScriptingCore::getInstance()->runScript("cocos2d-jsb.js"); return true; } diff --git a/template/multi-platform-js/Resources/main.js b/template/multi-platform-js/Resources/cocos2d-jsb.js similarity index 100% rename from template/multi-platform-js/Resources/main.js rename to template/multi-platform-js/Resources/cocos2d-jsb.js From 0160bec3ad5988cfe3adc9374fdc9bd682f3c7fc Mon Sep 17 00:00:00 2001 From: Michael Contento Date: Thu, 7 Nov 2013 18:13:33 +0100 Subject: [PATCH 025/185] Colors are now compare- and explicit convertible --- cocos/2d/ccTypes.cpp | 243 +++++++++++++++++++++++++++++++++++++------ cocos/2d/ccTypes.h | 96 ++++++++--------- 2 files changed, 253 insertions(+), 86 deletions(-) diff --git a/cocos/2d/ccTypes.cpp b/cocos/2d/ccTypes.cpp index adf9677ea2..e0ea80029e 100644 --- a/cocos/2d/ccTypes.cpp +++ b/cocos/2d/ccTypes.cpp @@ -26,42 +26,221 @@ NS_CC_BEGIN -Color4B::Color4B(const Color4F &color4F) -: r((GLubyte)(color4F.r * 255.0f)), -g((GLubyte)(color4F.g * 255.0f)), -b((GLubyte)(color4F.b * 255.0f)), -a((GLubyte)(color4F.a * 255.0f)) +/** + * Color3B + */ + +Color3B::Color3B() +: r(0) +, g(0) +, b(0) {} -const Color3B Color3B::WHITE(255,255,255); -const Color3B Color3B::YELLOW(255,255,0); -const Color3B Color3B::GREEN(0,255,0); -const Color3B Color3B::BLUE(0,0,255); -const Color3B Color3B::RED(255,0,0); -const Color3B Color3B::MAGENTA(255,0,255); -const Color3B Color3B::BLACK(0,0,0); -const Color3B Color3B::ORANGE(255,127,0); -const Color3B Color3B::GRAY(166,166,166); +Color3B::Color3B(GLubyte _r, GLubyte _g, GLubyte _b) +: r(_r) +, g(_g) +, b(_b) +{} -const Color4B Color4B::WHITE(255,255,255,255); -const Color4B Color4B::YELLOW(255,255,0,255); -const Color4B Color4B::GREEN(0,255,0,255); -const Color4B Color4B::BLUE(0,0,255,255); -const Color4B Color4B::RED(255,0,0,255); -const Color4B Color4B::MAGENTA(255,0,255,255); -const Color4B Color4B::BLACK(0,0,0,255); -const Color4B Color4B::ORANGE(255,127,0,255); -const Color4B Color4B::GRAY(166,166,166,255); +Color3B::Color3B(const Color4B& color) +: r(color.r) +, g(color.g) +, b(color.b) +{} -const Color4F Color4F::WHITE(1,1,1,1); -const Color4F Color4F::YELLOW(1,1,0,1); -const Color4F Color4F::GREEN(0,1,0,1); -const Color4F Color4F::BLUE(0,0,1,1); -const Color4F Color4F::RED(1,0,0,1); -const Color4F Color4F::MAGENTA(1,0,1,1); -const Color4F Color4F::BLACK(0,0,0,1); -const Color4F Color4F::ORANGE(1,0.5f,0,1); -const Color4F Color4F::GRAY(0.65f,0.65f,0.65f,1); +Color3B::Color3B(const Color4F& color) +: r(color.r * 255.0f) +, g(color.g * 255.0f) +, b(color.b * 255.0f) +{} + +bool Color3B::operator==(const Color3B& right) const +{ + return (r == right.r && g == right.g && b == right.b); +} + +bool Color3B::operator==(const Color4B& right) const +{ + return (r == right.r && g == right.g && b == right.b && 255 == right.a); +} + +bool Color3B::operator==(const Color4F& right) const +{ + return (right.a == 1.0f && Color4F(*this) == right); +} + +bool Color3B::operator!=(const Color3B& right) const +{ + return !(*this == right); +} + +bool Color3B::operator!=(const Color4B& right) const +{ + return !(*this == right); +} + +bool Color3B::operator!=(const Color4F& right) const +{ + return !(*this == right); +} + +/** + * Color4B + */ + +Color4B::Color4B() +: r(0) +, g(0) +, b(0) +, a(0) +{} + +Color4B::Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a) +: r(_r) +, g(_g) +, b(_b) +, a(_a) +{} + +Color4B::Color4B(const Color3B& color) +: r(color.r * 255) +, g(color.g * 255) +, b(color.b * 255) +, a(255) +{} + +Color4B::Color4B(const Color4F& color) +: r(color.r * 255) +, g(color.g * 255) +, b(color.b * 255) +, a(color.a * 255) +{} + +bool Color4B::operator==(const Color4B& right) const +{ + return (r == right.r && g == right.g && b == right.b && a == right.a); +} + +bool Color4B::operator==(const Color3B& right) const +{ + return (r == right.r && g == right.g && b == right.b && a == 255); +} + +bool Color4B::operator==(const Color4F& right) const +{ + return (*this == Color4B(right)); +} + +bool Color4B::operator!=(const Color4B& right) const +{ + return !(*this == right); +} + +bool Color4B::operator!=(const Color3B& right) const +{ + return !(*this == right); +} + +bool Color4B::operator!=(const Color4F& right) const +{ + return !(*this == right); +} + +/** + * Color4F + */ + +Color4F::Color4F() +: r(0.0f) +, g(0.0f) +, b(0.0f) +, a(0.0f) +{} + +Color4F::Color4F(float _r, float _g, float _b, float _a) +: r(_r) +, g(_g) +, b(_b) +, a(_a) +{} + +Color4F::Color4F(const Color3B& color) +: r(color.r / 255.0f) +, g(color.g / 255.0f) +, b(color.b / 255.0f) +, a(1.0f) +{} + +Color4F::Color4F(const Color4B& color) +: r(color.r / 255.0f) +, g(color.g / 255.0f) +, b(color.b / 255.0f) +, a(color.a / 255.0f) +{} + +bool Color4F::operator==(const Color4F& right) const +{ + return (r == right.r && g == right.g && b == right.b && a == right.a); +} + +bool Color4F::operator==(const Color3B& right) const +{ + return (a == 1.0f && Color3B(*this) == right); +} + +bool Color4F::operator==(const Color4B& right) const +{ + return (*this == Color4F(right)); +} + +bool Color4F::operator!=(const Color4F& right) const +{ + return !(*this == right); +} + +bool Color4F::operator!=(const Color3B& right) const +{ + return !(*this == right); +} + +bool Color4F::operator!=(const Color4B& right) const +{ + return !(*this == right); +} + +/** + * Color constants + */ + +const Color3B Color3B::WHITE (255, 255, 255); +const Color3B Color3B::YELLOW (255, 255, 0); +const Color3B Color3B::GREEN ( 0, 255, 0); +const Color3B Color3B::BLUE ( 0, 0, 255); +const Color3B Color3B::RED (255, 0, 0); +const Color3B Color3B::MAGENTA(255, 0, 255); +const Color3B Color3B::BLACK ( 0, 0, 0); +const Color3B Color3B::ORANGE (255, 127, 0); +const Color3B Color3B::GRAY (166, 166, 166); + +const Color4B Color4B::WHITE (255, 255, 255, 255); +const Color4B Color4B::YELLOW (255, 255, 0, 255); +const Color4B Color4B::GREEN ( 0, 255, 0, 255); +const Color4B Color4B::BLUE ( 0, 0, 255, 255); +const Color4B Color4B::RED (255, 0, 0, 255); +const Color4B Color4B::MAGENTA(255, 0, 255, 255); +const Color4B Color4B::BLACK ( 0, 0, 0, 255); +const Color4B Color4B::ORANGE (255, 127, 0, 255); +const Color4B Color4B::GRAY (166, 166, 166, 255); + +const Color4F Color4F::WHITE ( 1, 1, 1, 1); +const Color4F Color4F::YELLOW ( 1, 1, 0, 1); +const Color4F Color4F::GREEN ( 0, 1, 0, 1); +const Color4F Color4F::BLUE ( 0, 0, 1, 1); +const Color4F Color4F::RED ( 1, 0, 0, 1); +const Color4F Color4F::MAGENTA( 1, 0, 1, 1); +const Color4F Color4F::BLACK ( 0, 0, 0, 1); +const Color4F Color4F::ORANGE ( 1, 0.5f, 0, 1); +const Color4F Color4F::GRAY (0.65f, 0.65f, 0.65f, 1); const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO}; const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; diff --git a/cocos/2d/ccTypes.h b/cocos/2d/ccTypes.h index f7bb8d19cb..b124de71c1 100644 --- a/cocos/2d/ccTypes.h +++ b/cocos/2d/ccTypes.h @@ -31,29 +31,33 @@ THE SOFTWARE. #include "CCGeometry.h" #include "CCGL.h" - NS_CC_BEGIN +struct Color4B; +struct Color4F; + /** RGB color composed of bytes 3 bytes @since v3.0 */ struct Color3B { - Color3B(): r(0), g(0), b(0) {} - - Color3B(GLubyte _r, GLubyte _g, GLubyte _b) - : r(_r) - , g(_g) - , b(_b) - {} - - bool equals(const Color3B &other) + Color3B(); + Color3B(GLubyte _r, GLubyte _g, GLubyte _b); + explicit Color3B(const Color4B& color); + explicit Color3B(const Color4F& color); + + bool operator==(const Color3B& right) const; + bool operator==(const Color4B& right) const; + bool operator==(const Color4F& right) const; + bool operator!=(const Color3B& right) const; + bool operator!=(const Color4B& right) const; + bool operator!=(const Color4F& right) const; + + bool equals(const Color3B& other) { - return (this->r == other.r && - this->g == other.g && - this->b == other.b); + return (*this == other); } - + GLubyte r; GLubyte g; GLubyte b; @@ -69,24 +73,22 @@ struct Color3B const static Color3B GRAY; }; -struct Color4F; - /** RGBA color composed of 4 bytes @since v3.0 */ struct Color4B { - Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a) - : r(_r) - , g(_g) - , b(_b) - , a(_a) - {} - - Color4B(): r(0), g(0), b(0), a(0) {} - - // This function should use Color4F, so implement it in .cpp file. - explicit Color4B(const Color4F &color4F); + Color4B(); + Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a); + explicit Color4B(const Color3B& color); + explicit Color4B(const Color4F& color); + + bool operator==(const Color4B& right) const; + bool operator==(const Color3B& right) const; + bool operator==(const Color4F& right) const; + bool operator!=(const Color4B& right) const; + bool operator!=(const Color3B& right) const; + bool operator!=(const Color4F& right) const; GLubyte r; GLubyte g; @@ -110,35 +112,21 @@ struct Color4B */ struct Color4F { - Color4F(float _r, float _g, float _b, float _a) - : r(_r) - , g(_g) - , b(_b) - , a(_a) - {} - - explicit Color4F(const Color3B &color3B) - : r(color3B.r / 255.0f) - , g(color3B.g / 255.0f) - , b(color3B.b / 255.0f) - , a(1.f) - {} - - explicit Color4F(const Color4B &color4B) - : r(color4B.r / 255.0f) - , g(color4B.g / 255.0f) - , b(color4B.b / 255.0f) - , a(color4B.a / 255.0f) - {} - - Color4F(): r(0.f), g(0.f), b(0.f), a(0.f) {} - + Color4F(); + Color4F(float _r, float _g, float _b, float _a); + explicit Color4F(const Color3B& color); + explicit Color4F(const Color4B& color); + + bool operator==(const Color4F& right) const; + bool operator==(const Color3B& right) const; + bool operator==(const Color4B& right) const; + bool operator!=(const Color4F& right) const; + bool operator!=(const Color3B& right) const; + bool operator!=(const Color4B& right) const; + bool equals(const Color4F &other) { - return (this->r == other.r && - this->g == other.g && - this->b == other.b && - this->a == other.a); + return (*this == other); } GLfloat r; From e4662b371ae04de9394b4df75d81f99c62e23642 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 7 Nov 2013 11:58:48 -0800 Subject: [PATCH 026/185] TextField uses std::string& in the public API and uses std::string instead of std::string* internally --- cocos/2d/CCTextFieldTTF.cpp | 118 ++++++++++++++++-------------------- cocos/2d/CCTextFieldTTF.h | 28 ++++----- cocos/gui/UITextField.cpp | 4 +- 3 files changed, 68 insertions(+), 82 deletions(-) diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 934b88a091..01179ba523 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -53,8 +53,8 @@ static int _calcCharCount(const char * pszText) TextFieldTTF::TextFieldTTF() : _delegate(0) , _charCount(0) -, _inputText(new std::string) -, _placeHolder(new std::string) // prevent LabelTTF initWithString assertion +, _inputText("") +, _placeHolder("") // prevent LabelTTF initWithString assertion , _secureTextEntry(false) { _colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127; @@ -62,43 +62,41 @@ TextFieldTTF::TextFieldTTF() TextFieldTTF::~TextFieldTTF() { - CC_SAFE_DELETE(_inputText); - CC_SAFE_DELETE(_placeHolder); } ////////////////////////////////////////////////////////////////////////// // static constructor ////////////////////////////////////////////////////////////////////////// -TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextHAlignment alignment, const char *fontName, float fontSize) +TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize) { - TextFieldTTF *pRet = new TextFieldTTF(); - if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) + TextFieldTTF *ret = new TextFieldTTF(); + if(ret && ret->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) { - pRet->autorelease(); - if (placeholder) + ret->autorelease(); + if (placeholder.size()>0) { - pRet->setPlaceHolder(placeholder); + ret->setPlaceHolder(placeholder); } - return pRet; + return ret; } - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); return NULL; } -TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize) +TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) { - TextFieldTTF *pRet = new TextFieldTTF(); - if(pRet && pRet->initWithString("", fontName, fontSize)) + TextFieldTTF *ret = new TextFieldTTF(); + if(ret && ret->initWithString("", fontName, fontSize)) { - pRet->autorelease(); - if (placeholder) + ret->autorelease(); + if (placeholder.size()>0) { - pRet->setPlaceHolder(placeholder); + ret->setPlaceHolder(placeholder); } - return pRet; + return ret; } - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); return NULL; } @@ -106,23 +104,15 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, c // initialize ////////////////////////////////////////////////////////////////////////// -bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextHAlignment alignment, const char *fontName, float fontSize) +bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize) { - if (placeholder) - { - CC_SAFE_DELETE(_placeHolder); - _placeHolder = new std::string(placeholder); - } - return LabelTTF::initWithString(_placeHolder->c_str(), fontName, fontSize, dimensions, alignment); + _placeHolder = placeholder; + return LabelTTF::initWithString(_placeHolder, fontName, fontSize, dimensions, alignment); } -bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize) +bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize) { - if (placeholder) - { - CC_SAFE_DELETE(_placeHolder); - _placeHolder = new std::string(placeholder); - } - return LabelTTF::initWithString(_placeHolder->c_str(), fontName, fontSize); + _placeHolder = std::string(placeholder); + return LabelTTF::initWithString(_placeHolder, fontName, fontSize); } ////////////////////////////////////////////////////////////////////////// @@ -190,9 +180,9 @@ void TextFieldTTF::insertText(const char * text, int len) } _charCount += _calcCharCount(sInsert.c_str()); - std::string sText(*_inputText); + std::string sText(_inputText); sText.append(sInsert); - setString(sText.c_str()); + setString(sText); } if ((int)sInsert.npos == nPos) { @@ -211,7 +201,7 @@ void TextFieldTTF::insertText(const char * text, int len) void TextFieldTTF::deleteBackward() { - int nStrLen = _inputText->length(); + int nStrLen = _inputText.length(); if (! nStrLen) { // there is no string @@ -221,12 +211,12 @@ void TextFieldTTF::deleteBackward() // get the delete byte number int nDeleteLen = 1; // default, erase 1 byte - while(0x80 == (0xC0 & _inputText->at(nStrLen - nDeleteLen))) + while(0x80 == (0xC0 & _inputText.at(nStrLen - nDeleteLen))) { ++nDeleteLen; } - if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText->c_str() + nStrLen - nDeleteLen, nDeleteLen)) + if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + nStrLen - nDeleteLen, nDeleteLen)) { // delegate doesn't wan't to delete backwards return; @@ -235,21 +225,20 @@ void TextFieldTTF::deleteBackward() // if all text deleted, show placeholder string if (nStrLen <= nDeleteLen) { - CC_SAFE_DELETE(_inputText); - _inputText = new std::string; + _inputText = ""; _charCount = 0; - LabelTTF::setString(_placeHolder->c_str()); + LabelTTF::setString(_placeHolder); return; } // set new input text - std::string sText(_inputText->c_str(), nStrLen - nDeleteLen); - setString(sText.c_str()); + std::string sText(_inputText.c_str(), nStrLen - nDeleteLen); + setString(sText); } const char * TextFieldTTF::getContentText() { - return _inputText->c_str(); + return _inputText.c_str(); } void TextFieldTTF::draw() @@ -258,7 +247,7 @@ void TextFieldTTF::draw() { return; } - if (_inputText->length()) + if (_inputText.length()) { LabelTTF::draw(); return; @@ -286,22 +275,20 @@ void TextFieldTTF::setColorSpaceHolder(const Color3B& color) ////////////////////////////////////////////////////////////////////////// // input text property -void TextFieldTTF::setString(const char *text) +void TextFieldTTF::setString(const std::string &text) { static char bulletString[] = {(char)0xe2, (char)0x80, (char)0xa2, (char)0x00}; std::string displayText; int length; - CC_SAFE_DELETE(_inputText); - - if (text) + if (text.length()>0) { - _inputText = new std::string(text); - displayText = *_inputText; + _inputText = text; + displayText = _inputText; if (_secureTextEntry) { displayText = ""; - length = _inputText->length(); + length = _inputText.length(); while (length) { displayText.append(bulletString); @@ -311,40 +298,39 @@ void TextFieldTTF::setString(const char *text) } else { - _inputText = new std::string; + _inputText = ""; } // if there is no input text, display placeholder instead - if (! _inputText->length()) + if (! _inputText.length()) { - LabelTTF::setString(_placeHolder->c_str()); + LabelTTF::setString(_placeHolder); } else { - LabelTTF::setString(displayText.c_str()); + LabelTTF::setString(displayText); } - _charCount = _calcCharCount(_inputText->c_str()); + _charCount = _calcCharCount(_inputText.c_str()); } const char* TextFieldTTF::getString(void) const { - return _inputText->c_str(); + return _inputText.c_str(); } // place holder text property -void TextFieldTTF::setPlaceHolder(const char * text) +void TextFieldTTF::setPlaceHolder(const std::string& text) { - CC_SAFE_DELETE(_placeHolder); - _placeHolder = (text) ? new std::string(text) : new std::string; - if (! _inputText->length()) + _placeHolder = text; + if (! _inputText.length()) { - LabelTTF::setString(_placeHolder->c_str()); + LabelTTF::setString(_placeHolder); } } -const char * TextFieldTTF::getPlaceHolder(void) +const std::string& TextFieldTTF::getPlaceHolder() const { - return _placeHolder->c_str(); + return _placeHolder; } // secureTextEntry diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 79feb55d7c..28c74a7a9c 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -109,13 +109,13 @@ public: //char * description(); /** creates a TextFieldTTF from a fontname, alignment, dimension and font size */ - static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextHAlignment alignment, const char *fontName, float fontSize); + static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); /** creates a LabelTTF from a fontname and font size */ - static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); + static TextFieldTTF * textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize); /** initializes the TextFieldTTF with a font name, alignment, dimension and font size */ - bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextHAlignment alignment, const char *fontName, float fontSize); + bool initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize); /** initializes the TextFieldTTF with a font name and font size */ - bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); + bool initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize); /** @brief Open keyboard and receive input text. @@ -147,21 +147,21 @@ public: // input text property public: - virtual void setString(const char *text); + virtual void setString(const std::string& text) override; virtual const char* getString(void) const; protected: TextFieldDelegate * _delegate; int _charCount; - std::string * _inputText; + std::string _inputText; // place holder text property // place holder text displayed when there is no text in the text field. public: - virtual void setPlaceHolder(const char * text); - virtual const char * getPlaceHolder(void); + virtual void setPlaceHolder(const std::string& text); + virtual const std::string& getPlaceHolder(void) const; protected: - std::string * _placeHolder; + std::string _placeHolder; Color3B _colorSpaceHolder; public: virtual void setSecureTextEntry(bool value); @@ -176,11 +176,11 @@ protected: // IMEDelegate interface ////////////////////////////////////////////////////////////////////////// - virtual bool canAttachWithIME(); - virtual bool canDetachWithIME(); - virtual void insertText(const char * text, int len); - virtual void deleteBackward(); - virtual const char * getContentText(); + virtual bool canAttachWithIME() override; + virtual bool canDetachWithIME() override; + virtual void insertText(const char * text, int len) override; + virtual void deleteBackward() override; + virtual const char * getContentText() override; private: class LengthStack; LengthStack * _lens; diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 7eb30518cd..da79a1590b 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -139,7 +139,7 @@ void UICCTextField::insertText(const char * text, int len) { if (cocos2d::TextFieldTTF::getCharCount() > 0) { - setPasswordText(_inputText->c_str()); + setPasswordText(_inputText.c_str()); } } } @@ -153,7 +153,7 @@ void UICCTextField::deleteBackward() // password if (_passwordEnabled) { - setPasswordText(_inputText->c_str()); + setPasswordText(_inputText.c_str()); } } } From ffd434254800645a6d0fe44f0bffa7da90940cb4 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 7 Nov 2013 12:42:16 -0800 Subject: [PATCH 027/185] Adds more strings and more `override` and fixes some indetentation issues --- cocos/2d/CCLabel.h | 46 +++++++++++----------- cocos/2d/CCLabelAtlas.cpp | 4 +- cocos/2d/CCLabelAtlas.h | 7 ++-- cocos/2d/CCLabelBMFont.cpp | 4 +- cocos/2d/CCLabelBMFont.h | 4 +- cocos/2d/CCLabelTTF.cpp | 4 +- cocos/2d/CCLabelTTF.h | 4 +- cocos/2d/CCProtocols.h | 2 +- cocos/2d/CCTextFieldTTF.cpp | 4 +- cocos/2d/CCTextFieldTTF.h | 2 +- cocos/gui/UIButton.cpp | 4 +- cocos/gui/UIButton.h | 4 +- cocos/gui/UILabel.cpp | 17 ++++---- cocos/gui/UILabel.h | 6 +-- cocos/gui/UILabelAtlas.cpp | 12 +++--- cocos/gui/UILabelAtlas.h | 10 ++--- cocos/gui/UITextField.cpp | 18 ++++----- cocos/gui/UITextField.h | 8 ++-- samples/Cpp/TestCpp/Classes/controller.cpp | 7 +++- 19 files changed, 84 insertions(+), 83 deletions(-) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index a4c9a127e2..d781196777 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -83,38 +83,38 @@ public: // CCLabelTextFormat protocol implementation virtual std::vector *getLettersInfo() override { return &_lettersInfo; }; - virtual bool recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) override; - virtual bool recordPlaceholderInfo(int spriteIndex) override; - virtual float getLetterPosXLeft( int index ) const override; - virtual float getLetterPosXRight( int index ) const override; + virtual bool recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) override; + virtual bool recordPlaceholderInfo(int spriteIndex) override; + virtual float getLetterPosXLeft( int index ) const override; + virtual float getLetterPosXRight( int index ) const override; - virtual Sprite * getLetter(int ID) override; + virtual Sprite * getLetter(int ID) override; // font related stuff - virtual int getCommonLineHeight() const override; - virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const override; - virtual int getXOffsetForChar(unsigned short c) const override; - virtual int getYOffsetForChar(unsigned short c) const override; - virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const override; - virtual Rect getRectForChar(unsigned short c) const override; + virtual int getCommonLineHeight() const override; + virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const override; + virtual int getXOffsetForChar(unsigned short c) const override; + virtual int getYOffsetForChar(unsigned short c) const override; + virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const override; + virtual Rect getRectForChar(unsigned short c) const override; // string related stuff - virtual int getStringNumLines() const override; - virtual int getStringLenght() const override; - virtual unsigned short getCharAtStringPosition(int position) const override; - virtual unsigned short * getUTF8String() const override; - virtual void assignNewUTF8String(unsigned short *newString) override; - virtual TextHAlignment getTextAlignment() const override; + virtual int getStringNumLines() const override; + virtual int getStringLenght() const override; + virtual unsigned short getCharAtStringPosition(int position) const override; + virtual unsigned short * getUTF8String() const override; + virtual void assignNewUTF8String(unsigned short *newString) override; + virtual TextHAlignment getTextAlignment() const override; // label related stuff - virtual float getMaxLineWidth() const override; - virtual bool breakLineWithoutSpace() const override; - virtual Size getLabelContentSize() const override; - virtual void setLabelContentSize(const Size &newSize) override; + virtual float getMaxLineWidth() const override; + virtual bool breakLineWithoutSpace() const override; + virtual Size getLabelContentSize() const override; + virtual void setLabelContentSize(const Size &newSize) override; // carloX - const char * getString() const { return "not implemented"; } - void addChild(Node * child, int zOrder=0, int tag=0); + virtual const std::string& getString() const override { static std::string _ret("not implemented"); return _ret; } + void addChild(Node * child, int zOrder=0, int tag=0) override; private: /** diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 56a6ff723b..262c5f2dd9 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -203,9 +203,9 @@ void LabelAtlas::setString(const std::string &label) _quadsToDraw = len; } -const char* LabelAtlas::getString(void) const +const std::string& LabelAtlas::getString(void) const { - return _string.c_str(); + return _string; } //CCLabelAtlas - draw diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index eb8d06f4be..8fd81b9bda 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -87,11 +87,12 @@ public: // super methods virtual void updateAtlasValues(); - virtual void setString(const std::string &label); - virtual const char* getString(void) const; + + virtual void setString(const std::string &label) override; + virtual const std::string& getString(void) const override; #if CC_LABELATLAS_DEBUG_DRAW - virtual void draw(); + virtual void draw() override; #endif protected: diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index e28d4d0afc..fe6026abfe 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -767,9 +767,9 @@ void LabelBMFont::setString(unsigned short *newString, bool needUpdateLabel) } } -const char* LabelBMFont::getString(void) const +const std::string& LabelBMFont::getString() const { - return _initialStringUTF8.c_str(); + return _initialStringUTF8; } void LabelBMFont::setCString(const char *label) diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index cc49dd0806..a825d28ed6 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -228,10 +228,10 @@ public: /** updates the font chars based on the string to render */ void createFontChars(); // super method - virtual void setString(const std::string& newString); + virtual void setString(const std::string& newString) override; virtual void setString(const std::string& newString, bool needUpdateLabel); - virtual const char* getString() const; + virtual const std::string& getString() const override; virtual void setCString(const char *label); virtual void setAnchorPoint(const Point& var); virtual void updateLabel(); diff --git a/cocos/2d/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp index 3eec437d09..179f079e50 100644 --- a/cocos/2d/CCLabelTTF.cpp +++ b/cocos/2d/CCLabelTTF.cpp @@ -180,9 +180,9 @@ void LabelTTF::setString(const std::string &string) } } -const char* LabelTTF::getString(void) const +const std::string& LabelTTF::getString() const { - return _string.c_str(); + return _string; } const char* LabelTTF::description() const diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index 029a125def..8c5689e3d0 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -144,8 +144,8 @@ public: /** changes the string to render * @warning Changing the string is as expensive as creating a new LabelTTF. To obtain better performance use LabelAtlas */ - virtual void setString(const std::string &label); - virtual const char* getString(void) const; + virtual void setString(const std::string &label) override; + virtual const std::string& getString(void) const override; TextHAlignment getHorizontalAlignment() const; void setHorizontalAlignment(TextHAlignment alignment); diff --git a/cocos/2d/CCProtocols.h b/cocos/2d/CCProtocols.h index 17249816c0..993d1fa161 100644 --- a/cocos/2d/CCProtocols.h +++ b/cocos/2d/CCProtocols.h @@ -238,7 +238,7 @@ public: * @js NA * @lua NA */ - virtual const char* getString() const = 0; + virtual const std::string& getString() const = 0; }; /** diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 01179ba523..895aab58de 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -313,9 +313,9 @@ void TextFieldTTF::setString(const std::string &text) _charCount = _calcCharCount(_inputText.c_str()); } -const char* TextFieldTTF::getString(void) const +const std::string& TextFieldTTF::getString() const { - return _inputText.c_str(); + return _inputText; } // place holder text property diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 28c74a7a9c..a6ae42dc8e 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -148,7 +148,7 @@ public: // input text property public: virtual void setString(const std::string& text) override; - virtual const char* getString(void) const; + virtual const std::string& getString() const override; protected: TextFieldDelegate * _delegate; int _charCount; diff --git a/cocos/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index 43d6b27ecf..d18627be1e 100644 --- a/cocos/gui/UIButton.cpp +++ b/cocos/gui/UIButton.cpp @@ -565,12 +565,12 @@ void UIButton::setPressedActionEnabled(bool enabled) _pressedActionEnabled = enabled; } -void UIButton::setTitleText(const char* text) +void UIButton::setTitleText(const std::string& text) { _titleRenderer->setString(text); } -const char* UIButton::getTitleText() const +const std::string& UIButton::getTitleText() const { return _titleRenderer->getString(); } diff --git a/cocos/gui/UIButton.h b/cocos/gui/UIButton.h index bc6958c3e4..b069cbf5e0 100644 --- a/cocos/gui/UIButton.h +++ b/cocos/gui/UIButton.h @@ -171,8 +171,8 @@ public: */ virtual const char* getDescription() const; - void setTitleText(const char* text); - const char* getTitleText() const; + void setTitleText(const std::string& text); + const std::string& getTitleText() const; void setTitleColor(const cocos2d::Color3B& color); const cocos2d::Color3B& getTitleColor() const; void setTitleFontSize(float size); diff --git a/cocos/gui/UILabel.cpp b/cocos/gui/UILabel.cpp index 4c8779c9eb..cdf32c49c1 100644 --- a/cocos/gui/UILabel.cpp +++ b/cocos/gui/UILabel.cpp @@ -70,26 +70,23 @@ void UILabel::initRenderer() _renderer->addChild(_labelRenderer); } -void UILabel::setText(const char* text) +void UILabel::setText(const std::string& text) { - if (!text) - { + if (text.size()==0) return; - } - std::string strText(text); - _labelRenderer->setString(strText.c_str()); + + _labelRenderer->setString(text); labelScaleChangedWithSize(); } -const char* UILabel::getStringValue() +const std::string& UILabel::getStringValue() { return _labelRenderer->getString(); } int UILabel::getStringLength() { - const char* str = _labelRenderer->getString(); - return strlen(str); + return _labelRenderer->getString().size(); } void UILabel::setFontSize(int size) @@ -99,7 +96,7 @@ void UILabel::setFontSize(int size) labelScaleChangedWithSize(); } -void UILabel::setFontName(const char* name) +void UILabel::setFontName(const std::string& name) { _fontName = name; _labelRenderer->setFontName(name); diff --git a/cocos/gui/UILabel.h b/cocos/gui/UILabel.h index 5c6a4a105b..c38945bb9a 100644 --- a/cocos/gui/UILabel.h +++ b/cocos/gui/UILabel.h @@ -57,14 +57,14 @@ public: * * @param text string value. */ - void setText(const char* text); + void setText(const std::string& text); /** * Gets the string value of label. * * @return text string value. */ - const char* getStringValue(); + const std::string& getStringValue(); /** * Gets the string length of label. @@ -85,7 +85,7 @@ public: * * @param font name. */ - void setFontName(const char* name); + void setFontName(const std::string& name); /** * Sets the touch scale enabled of label. diff --git a/cocos/gui/UILabelAtlas.cpp b/cocos/gui/UILabelAtlas.cpp index 8e8db6c422..17963f595f 100644 --- a/cocos/gui/UILabelAtlas.cpp +++ b/cocos/gui/UILabelAtlas.cpp @@ -50,12 +50,12 @@ UICCLabelAtlas* UICCLabelAtlas::create() return NULL; } -void UICCLabelAtlas::setProperty(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) +void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) { initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap); } -void UICCLabelAtlas::setProperty(const char *string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) +void UICCLabelAtlas::setProperty(const std::string& string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) { initWithString(string, texture, itemWidth, itemHeight, startCharMap); } @@ -113,7 +113,7 @@ void UILabelAtlas::initRenderer() _renderer->addChild(_laberAtlasRenderer); } -void UILabelAtlas::setProperty(const char *stringValue, const char *charMapFile, int itemWidth, int itemHeight, const char *startCharMap) +void UILabelAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) { _stringValue = stringValue; _charMapFileName = charMapFile; @@ -125,14 +125,14 @@ void UILabelAtlas::setProperty(const char *stringValue, const char *charMapFile, labelAtlasScaleChangedWithSize(); } -void UILabelAtlas::setStringValue(const char *value) +void UILabelAtlas::setStringValue(const std::string& value) { _stringValue = value; _laberAtlasRenderer->setString(value); labelAtlasScaleChangedWithSize(); } -const char* UILabelAtlas::getStringValue() +const std::string& UILabelAtlas::getStringValue() const { return _laberAtlasRenderer->getString(); } @@ -195,7 +195,7 @@ void UILabelAtlas::copySpecialProperties(UIWidget *widget) UILabelAtlas* labelAtlas = dynamic_cast(widget); if (labelAtlas) { - setProperty(labelAtlas->_stringValue.c_str(), labelAtlas->_charMapFileName.c_str(), labelAtlas->_itemWidth, labelAtlas->_itemHeight, labelAtlas->_startCharMap.c_str()); + setProperty(labelAtlas->_stringValue, labelAtlas->_charMapFileName, labelAtlas->_itemWidth, labelAtlas->_itemHeight, labelAtlas->_startCharMap); } } diff --git a/cocos/gui/UILabelAtlas.h b/cocos/gui/UILabelAtlas.h index 73b902633f..a33872ef0c 100644 --- a/cocos/gui/UILabelAtlas.h +++ b/cocos/gui/UILabelAtlas.h @@ -50,8 +50,8 @@ public: * Allocates and initializes. */ static UICCLabelAtlas* create(); - void setProperty(const char *string, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - void setProperty(const char *string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + void setProperty(const std::string& string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); virtual void updateDisplayedOpacity(GLubyte opacity); virtual void draw(void); }; @@ -78,13 +78,13 @@ public: static UILabelAtlas* create(); /** initializes the UILabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - void setProperty(const char* stringValue,const char* charMapFile, int itemWidth, int itemHeight, const char* startCharMap); + void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap); //set string value for labelatlas. - void setStringValue(const char* value); + void setStringValue(const std::string& value); //get string value for labelatlas. - const char* getStringValue(); + const std::string& getStringValue() const; //override "setAnchorPoint" method of widget. virtual void setAnchorPoint(const cocos2d::Point &pt); diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index da79a1590b..311c0adfaa 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -105,7 +105,7 @@ bool UICCTextField::onTextFieldDetachWithIME(cocos2d::TextFieldTTF *pSender) void UICCTextField::insertText(const char * text, int len) { std::string str_text = text; - int str_len = strlen(cocos2d::TextFieldTTF::getString()); + int str_len = cocos2d::TextFieldTTF::getString().size(); if (strcmp(text, "\n") != 0) { @@ -321,18 +321,16 @@ void UITextField::setTouchSize(const cocos2d::Size &size) _touchHeight = size.height; } -void UITextField::setText(const char* text) +void UITextField::setText(const std::string& text) { - if (!text) - { + if (text.size()==0) return; - } - std::string strText(text); - _textFieldRenderer->setString(strText.c_str()); + + _textFieldRenderer->setString(text); textfieldRendererScaleChangedWithSize(); } -void UITextField::setPlaceHolder(const char *value) +void UITextField::setPlaceHolder(const std::string& value) { _textFieldRenderer->setPlaceHolder(value); textfieldRendererScaleChangedWithSize(); @@ -344,7 +342,7 @@ void UITextField::setFontSize(int size) textfieldRendererScaleChangedWithSize(); } -void UITextField::setFontName(const char *name) +void UITextField::setFontName(const std::string& name) { _textFieldRenderer->setFontName(name); textfieldRendererScaleChangedWithSize(); @@ -355,7 +353,7 @@ void UITextField::didNotSelectSelf() _textFieldRenderer->detachWithIME(); } -const char* UITextField::getStringValue() +const std::string& UITextField::getStringValue() { return _textFieldRenderer->getString(); } diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index ac5641114f..fc90ea9466 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -109,12 +109,12 @@ public: virtual bool init(); virtual void initRenderer(); void setTouchSize(const cocos2d::Size &size); - void setText(const char* text); - void setPlaceHolder(const char* value); + void setText(const std::string& text); + void setPlaceHolder(const std::string& value); void setFontSize(int size); - void setFontName(const char* name); + void setFontName(const std::string& name); virtual void didNotSelectSelf(); - const char* getStringValue(); + const std::string& getStringValue(); virtual bool onTouchBegan(const cocos2d::Point &touchPoint); void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index fa87e4c9e5..1f18b31118 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -14,6 +14,11 @@ struct { const char *test_name; std::function callback; } g_aTestNames[] = { + + // + // TESTS MUST BE ORDERED ALPHABETICALLY + // violators will be prosecuted + // { "Accelerometer", []() { return new AccelerometerTestScene(); } }, { "ActionManagerTest", [](){return new ActionManagerTestScene(); } }, { "ActionsEaseTest", [](){return new ActionsEaseTestScene();} }, @@ -50,7 +55,6 @@ struct { { "FontTest", []() { return new FontTestScene(); } }, { "IntervalTest", [](){return new IntervalTestScene(); } }, { "KeyboardTest", []() { return new KeyboardTestScene(); } }, - { "MouseTest", []() { return new MouseTestScene(); } }, #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) { "KeypadTest", []() { return new KeypadTestScene(); } }, #endif @@ -59,6 +63,7 @@ struct { { "LayerTest", [](){return new LayerTestScene();} }, { "MenuTest", [](){return new MenuTestScene();} }, { "MotionStreakTest", [](){return new MotionStreakTestScene();} }, + { "MouseTest", []() { return new MouseTestScene(); } }, { "MutiTouchTest", []() { return new MutiTouchTestScene(); } }, { "NodeTest", [](){return new CocosNodeTestScene();} }, { "ParallaxTest", [](){return new ParallaxTestScene(); } }, From 0fb85f88fbd058bd95f2b59a7d61713e6c485972 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 7 Nov 2013 15:08:49 -0800 Subject: [PATCH 028/185] updates coding style. Everything is in MarkDown format. Much easier to read than in redmine --- docs/CODING_STYLE.md | 131 ---------------------------- docs/CODING_STYLE.md.REMOVED.git-id | 1 + 2 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 docs/CODING_STYLE.md create mode 100644 docs/CODING_STYLE.md.REMOVED.git-id diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md deleted file mode 100644 index 4b7bf2a7c8..0000000000 --- a/docs/CODING_STYLE.md +++ /dev/null @@ -1,131 +0,0 @@ -# cocos2d-x C++ coding sytle - - -## Detailed information - -Please, refer to this document for a detailed version of the cocos2d-x C++ coding sytle: - -* [cocos2d-x c++ coding style](http://www.cocos2d-x.org/wiki/Cocos2d_c++_coding_style) - - -## Quick Sample - -Use this sample as a quick reference. But DO READ the detailed doc for more info. - -Header file: - -```c++ -/** - * We use Doxygen strings for documentation. - * All public classes, methods, structs should be documented using Doxygen Strings - */ -class CC_DLL Sprite : public NodeRGBA, public TextureProtocol -{ /* class braces start in a new line */ - -/* no indentation here for public, protected or private */ -/* First add all the "public" stuff, then all the "protected" stuff, and finally all the "private" stuff -public: - - /* we don't use tabs, we use spaces, and we use a 4 space identation */ - /* 1st add all static const */ - static const int INDEX_NOT_INITIALIZED = -1; - - /* then add all the creators and other relevant static methods */ - static Sprite* create(); - static Sprite* create(const char *filename); - static Sprite* create(const char *filename, const Rect& rect); - - /* if applicable, then add the consturctors / destructors */ - Sprite(); - virtual ~Sprite(void); - - /* then add all the initialization methods */ - /* notice that they are in the same order as the creators */ - virtual bool init(void); - virtual bool initWithTexture(Texture2D *texture); - virtual bool initWithTexture(Texture2D *texture, const Rect& rect); - - - - /* then add the regular instace methods */ - virtual void updateTransform(void); - virtual SpriteBatchNode* getBatchNode(void); - virtual void setBatchNode(SpriteBatchNode *spriteBatchNode); - - - /* then add all the overriden methods */ - /* notice that all overriden methods must use the 'override' keyword */ - /* overriden methods are not forced to have doxygen strings UNLESS they change the behavior in a non obvios way */ - virtual void setPosition(const Point& pos) override; - virtual void setRotation(float rotation) override; - virtual void setRotationX(float rotationX) override; - - - /* once you finish with the 'public' methods, start with the 'protected' ones */ -protected: - - /* protected methods are not forced to have Doxygen strings, but if they have it, better */ - void updateColor(void); - virtual void setTextureCoords(Rect rect); - - /* After adding all the methods, add the ivars */ - /* all ivars must start with _ */ - /* Do not use Hungarian notation */ - TextureAtlas* _textureAtlas; - int _atlasIndex; - SpriteBatchNode* _batchNode; -}; - -``` - -Implementation file: - -```c++ -/* Do not use doxygen comments on the implementation file */ - -/* The methos MUST be in the same order as where declared in the header file */ - -Sprite* Sprite::create(const char *filename) -{ - /* Don't use tabs. Use spaces. Use 4-space indentation */ - Sprite *sprite = new Sprite(); - - /* put curly braces in the same line as in the 'if'*/ - /* leave a space between the 'if' and the '(' */ - /* don't leave spaces between '()' */ - if (sprite && sprite->initWithFile(filename)) { - sprite->autorelease(); - return sprite; - } - CC_SAFE_DELETE(sprite); - return NULL; -} - -/* Initialization list can be indented to 0 spaces, or to 4 spaces. If in doubt, be consistent with the indentation already used in the file */ -/* Only use the Initialization lists for types that can't fail when initialized */ -Sprite::Sprite() -: _shouldBeHidden(false) -, _texture(nullptr) -, _physicsBody(nullptr) -{ -} - -/* use the 'initXXX' methods to initialize types that might fail */ -bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) -{ - /* it ok not use use curly braces */ - if (something) - do_something(); - else - something_else(); - - /* but if you use curly branches in one branch, all the branches should use curly branches */ - if (something) { - do_something1(); - do_something2(); - } else { - so_something_else(); - } -} - -``` diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id new file mode 100644 index 0000000000..19a3855c35 --- /dev/null +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -0,0 +1 @@ +bf158b68747963e7f0b734954a407e63a30a69c3 \ No newline at end of file From 3300e46d0fa12edeb936c63d93a6016c7d690d00 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 7 Nov 2013 15:37:41 -0800 Subject: [PATCH 029/185] More fixes to the C++ guide --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 19a3855c35..2238cbadfc 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -bf158b68747963e7f0b734954a407e63a30a69c3 \ No newline at end of file +1ab69691a01c1fe6e8d479756b556149e9726e35 \ No newline at end of file From 6d0be761eb7fbe65ec76449655f8df7a5cff3666 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Nov 2013 10:47:12 +0800 Subject: [PATCH 030/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 93e703edb1..f3dca88228 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. + [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From 21f8050a4d271a0b8fa74c6972554aa8e8858e52 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Nov 2013 10:50:28 +0800 Subject: [PATCH 031/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index f3dca88228..3df3b9aa44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] sys.localStorage.getItem() does not support non-ascii string. [FIX] cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. [FIX] CCBReader can't play sequence automatically in JSB. + [NEW] main.js -> cocos2d-jsb.js [Lua Binding] [NEW] Added Armature lua binding and added test samples. From 61970934a241b32ca0d45cd68ea3527f23c69dba Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Nov 2013 10:55:49 +0800 Subject: [PATCH 032/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 3df3b9aa44..4582eee2eb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. + [NEW] Sprite: Override setScale(float scaleX, float scaleY) [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From d936622070f4cef6791589014bd8b773c528255a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 7 Nov 2013 19:00:31 -0800 Subject: [PATCH 033/185] Adds TOC to coding style --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 2238cbadfc..51a1dc866d 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -1ab69691a01c1fe6e8d479756b556149e9726e35 \ No newline at end of file +55fe4bd3605531a58a565c46eec20dee0f81ff97 \ No newline at end of file From d4f890a6ee32d57413757eaf431a2e3bc821005b Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Nov 2013 11:01:16 +0800 Subject: [PATCH 034/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 4582eee2eb..743d94f96f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. [NEW] Sprite: Override setScale(float scaleX, float scaleY) + [NEW] External: added | operator for Control::EventType [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From 240fc2ade10226a2a57adaeeda2853a7fc8fc500 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 8 Nov 2013 03:10:36 +0000 Subject: [PATCH 035/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 52e968dfe0..32fcdc004b 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 52e968dfe02f077f56d4df6cc04e38c8b76e22b9 +Subproject commit 32fcdc004b3023c32b1ddc1fce6bcb86bbba9c41 From 2c76d8c1507b047eb033fae5f6b637403227718a Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Fri, 8 Nov 2013 11:23:06 +0800 Subject: [PATCH 036/185] There are not directory entry in some case.So we need to test whether the file directory exists when uncompressing file entry, if does not exist then create directory --- extensions/assets-manager/AssetsManager.cpp | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index 31795c4f39..0910e36213 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -308,6 +308,47 @@ bool AssetsManager::uncompress() } else { + //There are not directory entry in some case. + //So we need to test whether the file directory exists when uncompressing file entry + //, if does not exist then create directory + string fileNameStr(fileName); + + size_t startIndex=0; + + size_t index=fileNameStr.find("/",startIndex); + + while(index!=-1) + { + string dir=_storagePath+fileNameStr.substr(0,index); + + FILE *out = fopen(dir.c_str(), "r"); + + if(!out) + { + if (!createDirectory(dir.c_str())) + { + CCLOG("can not create directory %s", dir.c_str()); + unzClose(zipfile); + return false; + } + else + { + CCLOG("create directory %s",dir.c_str()); + } + } + else + { + fclose(out); + } + + startIndex=index+1; + + index=fileNameStr.find("/",startIndex); + + } + + + // Entry is a file, so extract it. // Open current file. From 935d472979e2900dab5537c040821ef874ad454a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 8 Nov 2013 11:36:27 +0800 Subject: [PATCH 037/185] issue #3025: remove TextureCache::_sharedTextureCache --- cocos/2d/CCTextureCache.cpp | 4 ---- cocos/2d/CCTextureCache.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index cf1e8887f9..840a110a77 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -51,8 +51,6 @@ NS_CC_BEGIN // implementation TextureCache -TextureCache* TextureCache::_sharedTextureCache = nullptr; - TextureCache * TextureCache::getInstance() { return Director::getInstance()->getTextureCache(); @@ -65,7 +63,6 @@ TextureCache::TextureCache() , _needQuit(false) , _asyncRefCount(0) { - CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton."); } TextureCache::~TextureCache() @@ -76,7 +73,6 @@ TextureCache::~TextureCache() (it->second)->release(); CC_SAFE_DELETE(_loadingThread); - _sharedTextureCache = nullptr; } void TextureCache::destroyInstance() diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index 7916696513..eaa4567e90 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -200,8 +200,6 @@ protected: int _asyncRefCount; std::unordered_map _textures; - - static TextureCache *_sharedTextureCache; }; #if CC_ENABLE_CACHE_TEXTURE_DATA From fd37d3e9734306fcf076673e80da40d6ada5c35e Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 8 Nov 2013 04:17:15 +0000 Subject: [PATCH 038/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 32fcdc004b..7199547f2f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 32fcdc004b3023c32b1ddc1fce6bcb86bbba9c41 +Subproject commit 7199547f2f9ffbac4fdeac20e4bb50328c6d9352 From 314f2ac62ed7da993b2571295ce0a3e21591562a Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 8 Nov 2013 14:13:39 +0800 Subject: [PATCH 039/185] use float instead for create point object --- cocos/base/CCGeometry.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos/base/CCGeometry.cpp b/cocos/base/CCGeometry.cpp index 5f681914b0..fe5086cba9 100644 --- a/cocos/base/CCGeometry.cpp +++ b/cocos/base/CCGeometry.cpp @@ -293,16 +293,16 @@ Point Point::getIntersectPoint(const Point& A, const Point& B, const Point& C, c return Point::ZERO; } -const Point Point::ZERO = Point(0, 0); -const Point Point::ANCHOR_MIDDLE = Point(0.5, 0.5); -const Point Point::ANCHOR_BOTTOM_LEFT = Point(0, 0); -const Point Point::ANCHOR_TOP_LEFT = Point(0, 1); -const Point Point::ANCHOR_BOTTOM_RIGHT = Point(1, 0); -const Point Point::ANCHOR_TOP_RIGHT = Point(1, 1); -const Point Point::ANCHOR_MIDDLE_RIGHT = Point(1, .5); -const Point Point::ANCHOR_MIDDLE_LEFT = Point(0, 0.5); -const Point Point::ANCHOR_MIDDLE_TOP = Point(0.5, 1); -const Point Point::ANCHOR_MIDDLE_BOTTOM = Point(0.5, 0); +const Point Point::ZERO = Point(0.0f, 0.0f); +const Point Point::ANCHOR_MIDDLE = Point(0.5f, 0.5f); +const Point Point::ANCHOR_BOTTOM_LEFT = Point(0.0f, 0.0f); +const Point Point::ANCHOR_TOP_LEFT = Point(0.0f, 1.0f); +const Point Point::ANCHOR_BOTTOM_RIGHT = Point(1.0f, 0.0f); +const Point Point::ANCHOR_TOP_RIGHT = Point(1.0f, 1.0f); +const Point Point::ANCHOR_MIDDLE_RIGHT = Point(1.0f, 0.5f); +const Point Point::ANCHOR_MIDDLE_LEFT = Point(0.0f, 0.5f); +const Point Point::ANCHOR_MIDDLE_TOP = Point(0.5f, 1.0f); +const Point Point::ANCHOR_MIDDLE_BOTTOM = Point(0.5f, 0.0f); // implementation of Size From 2aaa21255fa1e8cca906cbc2155513a730209925 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 8 Nov 2013 14:34:24 +0800 Subject: [PATCH 040/185] fixed cocostudio action can not looping --- cocos/2d/platform/win32/CCFileUtilsWin32.cpp | 2 +- cocos/2d/platform/win32/CCFileUtilsWin32.h | 2 +- .../cocostudio/CCActionNode.cpp | 42 ++++++++++--------- .../editor-support/cocostudio/CCActionNode.h | 11 +++-- .../cocostudio/CCActionObject.cpp | 40 +++++++++++++++++- .../cocostudio/CCActionObject.h | 5 ++- cocos/gui/UILayout.cpp | 4 +- cocos/gui/proj.win32/libGUI.vcxproj | 10 ++--- cocos/gui/proj.win32/libGUI.vcxproj.filters | 30 ++++++------- 9 files changed, 93 insertions(+), 53 deletions(-) diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index a5c94dac90..216797bd9e 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -121,7 +121,7 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const return false; } -unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, unsigned long* size) +unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, long* size) { unsigned char * pBuffer = NULL; CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.h b/cocos/2d/platform/win32/CCFileUtilsWin32.h index 4f01adabeb..5c88d97cf9 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.h +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.h @@ -58,7 +58,7 @@ protected: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size) override; + virtual unsigned char* getFileData(const char* filename, const char* mode, long * size) override; /** * Gets full path for filename, resolution directory and search path. diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index ed7eae3aed..64a91744d0 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -33,16 +33,16 @@ using namespace gui; namespace cocostudio { - ActionNode::ActionNode() - : _currentFrameIndex(0) - , _destFrameIndex(0) - , _fUnitTime(0.1f) - , _actionTag(0) - , _actionSpawn(NULL) - , _action(NULL) - , _object(NULL) - , _frameArray(NULL) - , _frameArrayNum(0) +ActionNode::ActionNode() +: _currentFrameIndex(0) +, _destFrameIndex(0) +, _fUnitTime(0.1f) +, _actionTag(0) +, _actionSpawn(NULL) +, _action(NULL) +, _object(NULL) +, _frameArray(NULL) +, _frameArrayNum(0) { _frameArray = Array::create(); _frameArray->retain(); @@ -322,7 +322,7 @@ Spawn * ActionNode::refreshActionProperty() return _actionSpawn; } -void ActionNode::playAction(bool bloop) +void ActionNode::playAction() { if ( _object == NULL || _actionSpawn == NULL) { @@ -333,14 +333,8 @@ void ActionNode::playAction(bool bloop) { _action->release(); } - if (bloop) - { - _action = RepeatForever::create(_actionSpawn); - } - else - { - _action = Sequence::create(_actionSpawn, NULL); - } + + _action = Sequence::create(_actionSpawn, NULL); _action->retain(); this->runAction(); @@ -480,4 +474,14 @@ void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* destF cAction->update(delayTime); } + +bool ActionNode::isActionDoneOnce() +{ + if (_action == nullptr) + { + return true; + } + return _action->isDone(); +} + } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/CCActionNode.h b/cocos/editor-support/cocostudio/CCActionNode.h index 6f38a1a647..fc081cfb8f 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.h +++ b/cocos/editor-support/cocostudio/CCActionNode.h @@ -136,10 +136,8 @@ public: /** * Play the action. - * - * @param bloop true the */ - virtual void playAction(bool bloop); + virtual void playAction(); /** * Stop the action. @@ -148,6 +146,13 @@ public: /*init properties with a json dictionary*/ virtual void initWithDictionary(JsonDictionary* dic,cocos2d::Object* root); + + /** + * Gets if the action is done once time. + * + * @return that if the action is done once time + */ + virtual bool isActionDoneOnce(); protected: int _currentFrameIndex; int _destFrameIndex; diff --git a/cocos/editor-support/cocostudio/CCActionObject.cpp b/cocos/editor-support/cocostudio/CCActionObject.cpp index 2dd60c66f2..ba12778510 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.cpp +++ b/cocos/editor-support/cocostudio/CCActionObject.cpp @@ -25,7 +25,7 @@ #include "cocostudio/CCActionObject.h" #include "cocostudio/DictionaryHelper.h" - using namespace cocos2d; +using namespace cocos2d; namespace cocostudio { @@ -37,15 +37,19 @@ ActionObject::ActionObject() , _bPlaying(false) , _fUnitTime(0.1f) , _currentTime(0.0f) +, _pScheduler(NULL) { _actionNodeList = Array::create(); _actionNodeList->retain(); + _pScheduler = new Scheduler(); + Director::sharedDirector()->getScheduler()->scheduleUpdateForTarget(_pScheduler, 0, false); } ActionObject::~ActionObject() { _actionNodeList->removeAllObjects(); _actionNodeList->release(); + CC_SAFE_DELETE(_pScheduler); } void ActionObject::setName(const char* name) @@ -134,11 +138,16 @@ void ActionObject::removeActionNode(ActionNode* node) void ActionObject::play() { stop(); + this->updateToFrameByTime(0.0f); int frameNum = _actionNodeList->count(); for ( int i = 0; i < frameNum; i++ ) { ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i); - actionNode->playAction( getLoop()); + actionNode->playAction(); + } + if (_loop) + { + _pScheduler->scheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this, 0.0f , kRepeatForever, 0.0f, false); } } @@ -157,6 +166,7 @@ void ActionObject::stop() actionNode->stopAction(); } + _pScheduler->unscheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this); _bPause = false; } @@ -174,4 +184,30 @@ void ActionObject::updateToFrameByTime(float fTime) } } +void ActionObject::simulationActionUpdate(float dt) +{ + if (_loop) + { + bool isEnd = true; + int nodeNum = _actionNodeList->count(); + + for ( int i = 0; i < nodeNum; i++ ) + { + ActionNode* actionNode = (ActionNode*)_actionNodeList->objectAtIndex(i); + + if (actionNode->isActionDoneOnce() == false) + { + isEnd = false; + break; + } + } + + if (isEnd) + { + this->play(); + } + + CCLOG("ActionObject Update"); + } +} } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/CCActionObject.h b/cocos/editor-support/cocostudio/CCActionObject.h index cc748eaaa8..8118fc5cf7 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.h +++ b/cocos/editor-support/cocostudio/CCActionObject.h @@ -142,7 +142,9 @@ public: /*init properties with a json dictionary*/ void initWithDictionary(JsonDictionary* dic,cocos2d::Object* root); - + + /*scheduler update function*/ + void simulationActionUpdate(float dt); protected: cocos2d::Array* _actionNodeList;/*actionnode*/ std::string _name; @@ -151,6 +153,7 @@ protected: bool _bPlaying; float _fUnitTime; float _currentTime; + cocos2d::Scheduler *_pScheduler; }; } diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..130ee7ae13 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -953,7 +953,7 @@ bool UIRectClippingNode::init() rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green = cocos2d::Color4F(0, 1, 0, 1); _innerStencil->drawPolygon(rect, 4, green, 0, green); if (cocos2d::ClippingNode::init(_innerStencil)) { @@ -971,7 +971,7 @@ void UIRectClippingNode::setClippingSize(const cocos2d::Size &size) rect[1] = cocos2d::Point(_clippingSize.width, 0); rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green = cocos2d::Color4F(0, 1, 0, 1); _innerStencil->clear(); _innerStencil->drawPolygon(rect, 4, green, 0, green); } diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj index b225eaa127..2712ae3900 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -12,11 +12,8 @@ - - - @@ -24,7 +21,9 @@ + + @@ -37,11 +36,8 @@ - - - @@ -49,7 +45,9 @@ + + diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters index 12f0d385ab..092f28f7e0 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -24,9 +24,6 @@ UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -72,12 +69,6 @@ System - - Layouts - - - Layouts - Layouts @@ -87,14 +78,17 @@ BaseClasses + + Layouts + + + Layouts + UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -140,12 +134,6 @@ System - - Layouts - - - Layouts - Layouts @@ -155,5 +143,11 @@ BaseClasses + + Layouts + + + Layouts + \ No newline at end of file From da27169d4566ced6972c8561a9be1573bf91744b Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 14:58:20 +0800 Subject: [PATCH 041/185] add "setUserObject" method --- cocos/gui/UICheckBox.cpp | 3 --- cocos/gui/UIPageView.cpp | 3 --- cocos/gui/UIScrollView.cpp | 3 --- cocos/gui/UISlider.cpp | 3 --- cocos/gui/UITextField.cpp | 3 --- cocos/gui/UIWidget.cpp | 14 ++++++++++---- cocos/gui/UIWidget.h | 20 ++++++++++++++++++++ 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index c577a86fe6..e79be3d5f0 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -51,7 +51,6 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - CC_SAFE_RELEASE(_selectedStateEventListener); _selectedStateEventListener = NULL; _selectedStateEventSelector = NULL; } @@ -302,9 +301,7 @@ void UICheckBox::unSelectedEvent() void UICheckBox::addEventListener(cocos2d::Object *target, SEL_SelectedStateEvent selector) { - CC_SAFE_RELEASE(_selectedStateEventListener); _selectedStateEventListener = target; - CC_SAFE_RETAIN(_selectedStateEventListener); _selectedStateEventSelector = selector; } diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index bb88e6cb80..54b0713b7a 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -51,7 +51,6 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); - CC_SAFE_RELEASE(_eventListener); _eventListener = NULL; _eventSelector = NULL; } @@ -574,9 +573,7 @@ void UIPageView::pageTurningEvent() void UIPageView::addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector) { - CC_SAFE_RELEASE(_eventListener); _eventListener = target; - CC_SAFE_RETAIN(_eventListener); _eventSelector = selector; } diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index 2654eeda53..ebf32514da 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -76,7 +76,6 @@ _eventSelector(NULL) UIScrollView::~UIScrollView() { - CC_SAFE_RELEASE(_eventListener); _eventListener = NULL; _eventSelector = NULL; } @@ -1531,9 +1530,7 @@ void UIScrollView::bounceRightEvent() void UIScrollView::addEventListener(cocos2d::Object *target, SEL_ScrollViewEvent selector) { - CC_SAFE_RELEASE(_eventListener); _eventListener = target; - CC_SAFE_RETAIN(_eventListener); _eventSelector = selector; } diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index d5e0eac9ae..b5c90ccfb8 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -58,7 +58,6 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - CC_SAFE_RELEASE(_slidPercentListener); _slidPercentListener = NULL; _slidPercentSelector = NULL; } @@ -414,9 +413,7 @@ float UISlider::getPercentWithBallPos(float px) void UISlider::addEventListener(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) { - CC_SAFE_RELEASE(_slidPercentListener); _slidPercentListener = target; - CC_SAFE_RETAIN(_slidPercentListener); _slidPercentSelector = selector; } diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 963d807ef1..6a95ac8605 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -283,7 +283,6 @@ _passwordStyleText("") UITextField::~UITextField() { - CC_SAFE_RELEASE(_eventListener); _eventListener = NULL; _eventSelector = NULL; } @@ -505,9 +504,7 @@ void UITextField::deleteBackwardEvent() void UITextField::addEventListener(cocos2d::Object *target, SEL_TextFieldEvent selecor) { - CC_SAFE_RELEASE(_eventListener); _eventListener = target; - CC_SAFE_RETAIN(_eventListener); _eventSelector = selecor; } diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 7f2adc545a..ad63b28451 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -68,14 +68,14 @@ _sizeType(SIZE_ABSOLUTE), _sizePercent(cocos2d::Point::ZERO), _positionType(POSITION_ABSOLUTE), _positionPercent(cocos2d::Point::ZERO), -_isRunning(false) +_isRunning(false), +_userObject(NULL) { } UIWidget::~UIWidget() { - CC_SAFE_RELEASE(_touchEventListener); _touchEventListener = NULL; _touchEventSelector = NULL; removeAllChildren(); @@ -87,6 +87,7 @@ UIWidget::~UIWidget() _layoutParameterDictionary->removeAllObjects(); CC_SAFE_RELEASE(_layoutParameterDictionary); CC_SAFE_RELEASE(_scheduler); + CC_SAFE_RELEASE(_userObject); } UIWidget* UIWidget::create() @@ -135,6 +136,13 @@ void UIWidget::onExit() _isRunning = false; arrayMakeObjectsPerformSelector(_children, onExit, UIWidget*); } + +void UIWidget::setUserObject(cocos2d::Object *pUserObject) +{ + CC_SAFE_RETAIN(pUserObject); + CC_SAFE_RELEASE(_userObject); + _userObject = pUserObject; +} bool UIWidget::addChild(UIWidget *child) { @@ -698,9 +706,7 @@ void UIWidget::longClickEvent() void UIWidget::addTouchEventListener(cocos2d::Object *target, SEL_TouchEvent selector) { - CC_SAFE_RELEASE(_touchEventListener); _touchEventListener = target; - CC_SAFE_RETAIN(_touchEventListener); _touchEventSelector = selector; } diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index f4f48f2a94..02db42e731 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -880,6 +880,25 @@ public: virtual void onEnter(); virtual void onExit(); + + virtual Object* getUserObject() { return _userObject; } + /** + * @js NA + * @lua NA + */ + virtual const Object* getUserObject() const { return _userObject; } + + /** + * Returns a user assigned Object + * + * Similar to UserData, but instead of holding a void* it holds an object. + * The UserObject will be retained once in this method, + * and the previous UserObject (if existed) will be relese. + * The UserObject will be released in Node's destructure. + * + * @param userObject A user assigned Object + */ + virtual void setUserObject(Object *userObject); /*temp action*/ void setActionTag(int tag); int getActionTag(); @@ -952,6 +971,7 @@ protected: PositionType _positionType; cocos2d::Point _positionPercent; bool _isRunning; + cocos2d::Object* _userObject; }; /** * @js NA From b726c6fd2c1f07dd7fac51fe8eb43b421c00def8 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 8 Nov 2013 16:47:33 +0800 Subject: [PATCH 042/185] issue #3025: move VolatileTexture static function to VolatileTextureMgr --- cocos/2d/CCRenderTexture.cpp | 4 +-- cocos/2d/CCTexture2D.cpp | 10 ++++---- cocos/2d/CCTextureCache.cpp | 48 ++++++++++++++++++------------------ cocos/2d/CCTextureCache.h | 41 ++++++++++++++++-------------- 4 files changed, 53 insertions(+), 50 deletions(-) diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 17697c9de5..8fa56c282d 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -102,11 +102,11 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj) if (_UITextureImage) { const Size& s = _texture->getContentSizeInPixels(); - VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); + VolatileTextureMgr::addDataTexture(_texture, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); if ( _textureCopy ) { - VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); + VolatileTextureMgr::addDataTexture(_textureCopy, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s); } } else diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 397bdbf68a..2f0665afb4 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -434,7 +434,7 @@ Texture2D::Texture2D() Texture2D::~Texture2D() { #if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTexture::removeTexture(this); + VolatileTextureMgr::removeTexture(this); #endif CCLOGINFO("deallocing Texture2D: %p - id=%u", this, _name); @@ -1041,7 +1041,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data - VolatileTexture::addStringTexture(this, text, textDefinition); + VolatileTextureMgr::addStringTexture(this, text, textDefinition); #endif bool bRet = false; @@ -1267,7 +1267,7 @@ void Texture2D::setTexParameters(const TexParams &texParams) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texParams.wrapT ); #if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTexture::setTexParameters(this, texParams); + VolatileTextureMgr::setTexParameters(this, texParams); #endif } @@ -1287,7 +1287,7 @@ void Texture2D::setAliasTexParameters() glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); #if CC_ENABLE_CACHE_TEXTURE_DATA TexParams texParams = {(GLuint)(_hasMipmaps?GL_NEAREST_MIPMAP_NEAREST:GL_NEAREST),GL_NEAREST,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, texParams); + VolatileTextureMgr::setTexParameters(this, texParams); #endif } @@ -1307,7 +1307,7 @@ void Texture2D::setAntiAliasTexParameters() glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); #if CC_ENABLE_CACHE_TEXTURE_DATA TexParams texParams = {(GLuint)(_hasMipmaps?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR),GL_LINEAR,GL_NONE,GL_NONE}; - VolatileTexture::setTexParameters(this, texParams); + VolatileTextureMgr::setTexParameters(this, texParams); #endif } diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 840a110a77..7a5e835653 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -239,7 +239,7 @@ void TextureCache::addImageAsyncCallBack(float dt) #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name - VolatileTexture::addImageTexture(texture, filename); + VolatileTextureMgr::addImageTexture(texture, filename); #endif // cache the texture. retain it, since it is added in the map _textures.insert( std::make_pair(filename, texture) ); @@ -299,7 +299,7 @@ Texture2D * TextureCache::addImage(const std::string &path) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name - VolatileTexture::addImageTexture(texture, fullpath.c_str()); + VolatileTextureMgr::addImageTexture(texture, fullpath.c_str()); #endif // texture already retained, no need to re-retain it _textures.insert( std::make_pair(fullpath, texture) ); @@ -349,7 +349,7 @@ Texture2D* TextureCache::addImage(Image *image, const std::string &key) } while (0); #if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTexture::addImage(texture, image); + VolatileTextureMgr::addImage(texture, image); #endif return texture; @@ -418,7 +418,7 @@ Texture2D* TextureCache::getTextureForKey(const std::string &key) const void TextureCache::reloadAllTextures() { #if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTexture::reloadAllTextures(); + VolatileTextureMgr::reloadAllTextures(); #endif } @@ -458,8 +458,8 @@ void TextureCache::dumpCachedTextureInfo() const #if CC_ENABLE_CACHE_TEXTURE_DATA -std::list VolatileTexture::_textures; -bool VolatileTexture::_isReloading = false; +std::list VolatileTextureMgr::_textures; +bool VolatileTextureMgr::_isReloading = false; VolatileTexture::VolatileTexture(Texture2D *t) : _texture(t) @@ -474,16 +474,14 @@ VolatileTexture::VolatileTexture(Texture2D *t) _texParams.magFilter = GL_LINEAR; _texParams.wrapS = GL_CLAMP_TO_EDGE; _texParams.wrapT = GL_CLAMP_TO_EDGE; - _textures.push_back(this); } VolatileTexture::~VolatileTexture() { - _textures.remove(this); CC_SAFE_RELEASE(_uiImage); } -void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName) +void VolatileTextureMgr::addImageTexture(Texture2D *tt, const char* imageFileName) { if (_isReloading) { @@ -492,20 +490,20 @@ void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName) VolatileTexture *vt = findVolotileTexture(tt); - vt->_cashedImageType = kImageFile; + vt->_cashedImageType = VolatileTexture::kImageFile; vt->_fileName = imageFileName; vt->_pixelFormat = tt->getPixelFormat(); } -void VolatileTexture::addImage(Texture2D *tt, Image *image) +void VolatileTextureMgr::addImage(Texture2D *tt, Image *image) { VolatileTexture *vt = findVolotileTexture(tt); image->retain(); vt->_uiImage = image; - vt->_cashedImageType = kImage; + vt->_cashedImageType = VolatileTexture::kImage; } -VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt) +VolatileTexture* VolatileTextureMgr::findVolotileTexture(Texture2D *tt) { VolatileTexture *vt = 0; auto i = _textures.begin(); @@ -522,12 +520,13 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt) if (! vt) { vt = new VolatileTexture(tt); + _textures.push_back(vt); } return vt; } -void VolatileTexture::addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize) +void VolatileTextureMgr::addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize) { if (_isReloading) { @@ -536,14 +535,14 @@ void VolatileTexture::addDataTexture(Texture2D *tt, void* data, int dataLen, Tex VolatileTexture *vt = findVolotileTexture(tt); - vt->_cashedImageType = kImageData; + vt->_cashedImageType = VolatileTexture::kImageData; vt->_textureData = data; vt->_dataLen = dataLen; vt->_pixelFormat = pixelFormat; vt->_textureSize = contentSize; } -void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition) +void VolatileTextureMgr::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition) { if (_isReloading) { @@ -552,12 +551,12 @@ void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Fo VolatileTexture *vt = findVolotileTexture(tt); - vt->_cashedImageType = kString; + vt->_cashedImageType = VolatileTexture::kString; vt->_text = text; vt->_fontDefinition = fontDefinition; } -void VolatileTexture::setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams) +void VolatileTextureMgr::setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams) { VolatileTexture *vt = findVolotileTexture(t); @@ -571,7 +570,7 @@ void VolatileTexture::setTexParameters(Texture2D *t, const Texture2D::TexParams vt->_texParams.wrapT = texParams.wrapT; } -void VolatileTexture::removeTexture(Texture2D *t) +void VolatileTextureMgr::removeTexture(Texture2D *t) { auto i = _textures.begin(); while (i != _textures.end()) @@ -579,13 +578,14 @@ void VolatileTexture::removeTexture(Texture2D *t) VolatileTexture *vt = *i++; if (vt->_texture == t) { + _textures.remove(vt); delete vt; break; } } } -void VolatileTexture::reloadAllTextures() +void VolatileTextureMgr::reloadAllTextures() { _isReloading = true; @@ -598,7 +598,7 @@ void VolatileTexture::reloadAllTextures() switch (vt->_cashedImageType) { - case kImageFile: + case VolatileTexture::kImageFile: { Image* image = new Image(); long size = 0; @@ -616,7 +616,7 @@ void VolatileTexture::reloadAllTextures() CC_SAFE_RELEASE(image); } break; - case kImageData: + case VolatileTexture::kImageData: { vt->_texture->initWithData(vt->_textureData, vt->_dataLen, @@ -626,12 +626,12 @@ void VolatileTexture::reloadAllTextures() vt->_textureSize); } break; - case kString: + case VolatileTexture::kString: { vt->_texture->initWithString(vt->_text.c_str(), vt->_fontDefinition); } break; - case kImage: + case VolatileTexture::kImage: { vt->_texture->initWithImage(vt->_uiImage); } diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index eaa4567e90..8c988ff4c3 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -214,7 +214,7 @@ class VolatileTexture kImage, }ccCachedImageType; -public: +private: VolatileTexture(Texture2D *t); /** * @js NA @@ -222,25 +222,8 @@ public: */ ~VolatileTexture(); - static void addImageTexture(Texture2D *tt, const char* imageFileName); - static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); - static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize); - static void addImage(Texture2D *tt, Image *image); - - static void setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams); - static void removeTexture(Texture2D *t); - static void reloadAllTextures(); - -public: - static std::list _textures; - static bool _isReloading; - -private: - // find VolatileTexture by Texture2D* - // if not found, create a new one - static VolatileTexture* findVolotileTexture(Texture2D *tt); - protected: + friend class VolatileTextureMgr; Texture2D *_texture; Image *_uiImage; @@ -259,6 +242,26 @@ protected: FontDefinition _fontDefinition; }; +class VolatileTextureMgr +{ +public: + static void addImageTexture(Texture2D *tt, const char* imageFileName); + static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); + static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize); + static void addImage(Texture2D *tt, Image *image); + + static void setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams); + static void removeTexture(Texture2D *t); + static void reloadAllTextures(); +public: + static std::list _textures; + static bool _isReloading; +private: + // find VolatileTexture by Texture2D* + // if not found, create a new one + static VolatileTexture* findVolotileTexture(Texture2D *tt); +}; + #endif // end of textures group From eeedab78b2485c9b317fb8beabf8c9b24896a6e2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Nov 2013 18:13:24 +0800 Subject: [PATCH 043/185] [LINUX] Adding template CMake files for linux. --- template/multi-platform-cpp/CMakeLists.txt | 143 ++++++++++++++++++++ template/multi-platform-lua/CMakeLists.txt | 149 +++++++++++++++++++++ tools/travis-scripts/run-script.sh | 7 + 3 files changed, 299 insertions(+) create mode 100644 template/multi-platform-cpp/CMakeLists.txt create mode 100644 template/multi-platform-lua/CMakeLists.txt diff --git a/template/multi-platform-cpp/CMakeLists.txt b/template/multi-platform-cpp/CMakeLists.txt new file mode 100644 index 0000000000..88299d0d83 --- /dev/null +++ b/template/multi-platform-cpp/CMakeLists.txt @@ -0,0 +1,143 @@ +cmake_minimum_required(VERSION 2.6) + +set(APP_NAME HelloCpp) +project (${APP_NAME}) + +include(../../build/BuildHelpers.CMakeLists.txt) + +option(USE_CHIPMUNK "Use chipmunk for physics library" ON) +option(USE_BOX2D "Use box2d for physics library" OFF) +option(DEBUG_MODE "Debug or release?" ON) + +if(DEBUG_MODE) + set(CMAKE_BUILD_TYPE DEBUG) +else(DEBUG_MODE) + set(CMAKE_BUILD_TYPE RELEASE) +endif(DEBUG_MODE) + +set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") +set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") + +if(USE_CHIPMUNK) + message("Using chipmunk ...") + add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) +elseif(USE_BOX2D) + message("Using box2d ...") + add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1) +else(USE_CHIPMUNK) + message(FATAL_ERROR "Must choose a physics library.") +endif(USE_CHIPMUNK) + +# architecture +if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +set(ARCH_DIR "64-bit") +else() +set(ARCH_DIR "32-bit") +endif() + + +set(GAME_SRC + proj.linux/main.cpp + Classes/AppDelegate.cpp + Classes/HelloWorldScene.cpp +) + +set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/../..) + +include_directories( + ${COCOS2D_ROOT} + ${COCOS2D_ROOT}/cocos + ${COCOS2D_ROOT}/cocos/audio/include + ${COCOS2D_ROOT}/cocos/2d + ${COCOS2D_ROOT}/cocos/2d/platform + ${COCOS2D_ROOT}/cocos/2d/platform/linux + ${COCOS2D_ROOT}/cocos/base + ${COCOS2D_ROOT}/cocos/physics + ${COCOS2D_ROOT}/cocos/editor-support + ${COCOS2D_ROOT}/cocos/math/kazmath/include + ${COCOS2D_ROOT}/extensions + ${COCOS2D_ROOT}/external + ${COCOS2D_ROOT}/external/jpeg/include/linux + ${COCOS2D_ROOT}/external/tiff/include/linux + ${COCOS2D_ROOT}/external/webp/include/linux + ${COCOS2D_ROOT}/external/glfw3/include/linux + ${COCOS2D_ROOT}/external/curl/include/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/tinyxml2 + ${COCOS2D_ROOT}/external/unzip + ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk + ${COCOS2D_ROOT}/external/freetype2/include/linux + ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR} +) + +link_directories( + /usr/local/lib + ${COCOS2D_ROOT}/lib + ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/curl/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} +) + +# add the executable +add_executable(${APP_NAME} + ${GAME_SRC} +) + +if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +set(FMOD_LIB "fmodex64") +else() +set(FMOD_LIB "fmodex") +endif() + +target_link_libraries(${APP_NAME} + gui + network + curl + ldap + lber + idn + rtmp + spine + cocostudio + jsoncpp + cocosbuilder + extensions + box2d + audio + ${FMOD_LIB} + cocos2d + cocosbase + chipmunk + tinyxml2 + kazmath + unzip + jpeg + webp + tiff + freetype + fontconfig + png + pthread + glfw + GLEW + GL + X11 + rt + z + ) + +set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin") + +set_target_properties(${APP_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") + +pre_build(${APP_NAME} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + ) + diff --git a/template/multi-platform-lua/CMakeLists.txt b/template/multi-platform-lua/CMakeLists.txt new file mode 100644 index 0000000000..a3cf368403 --- /dev/null +++ b/template/multi-platform-lua/CMakeLists.txt @@ -0,0 +1,149 @@ +cmake_minimum_required(VERSION 2.6) + +set(APP_NAME HelloLua) +project (${APP_NAME}) + +include(../../build/BuildHelpers.CMakeLists.txt) + +option(USE_CHIPMUNK "Use chipmunk for physics library" ON) +option(USE_BOX2D "Use box2d for physics library" OFF) +option(DEBUG_MODE "Debug or release?" ON) + +if(DEBUG_MODE) + set(CMAKE_BUILD_TYPE DEBUG) +else(DEBUG_MODE) + set(CMAKE_BUILD_TYPE RELEASE) +endif(DEBUG_MODE) + +set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") +set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") + +if(USE_CHIPMUNK) + message("Using chipmunk ...") + add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) +elseif(USE_BOX2D) + message("Using box2d ...") + add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1) +else(USE_CHIPMUNK) + message(FATAL_ERROR "Must choose a physics library.") +endif(USE_CHIPMUNK) + +# architecture +if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +set(ARCH_DIR "64-bit") +else() +set(ARCH_DIR "32-bit") +endif() + + +set(GAME_SRC + proj.linux/main.cpp + Classes/AppDelegate.cpp +) + +set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/../..) + +include_directories( + Classes + ${COCOS2D_ROOT}/cocos/scripting/lua/bindings + ${COCOS2D_ROOT}/external/lua/lua + ${COCOS2D_ROOT}/external/lua/tolua + ${COCOS2D_ROOT} + ${COCOS2D_ROOT}/cocos + ${COCOS2D_ROOT}/cocos/audio/include + ${COCOS2D_ROOT}/cocos/2d + ${COCOS2D_ROOT}/cocos/2d/platform + ${COCOS2D_ROOT}/cocos/2d/platform/linux + ${COCOS2D_ROOT}/cocos/base + ${COCOS2D_ROOT}/cocos/physics + ${COCOS2D_ROOT}/cocos/editor-support + ${COCOS2D_ROOT}/cocos/math/kazmath/include + ${COCOS2D_ROOT}/extensions + ${COCOS2D_ROOT}/external + ${COCOS2D_ROOT}/external/jpeg/include/linux + ${COCOS2D_ROOT}/external/tiff/include/linux + ${COCOS2D_ROOT}/external/webp/include/linux + ${COCOS2D_ROOT}/external/glfw3/include/linux + ${COCOS2D_ROOT}/external/curl/include/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/tinyxml2 + ${COCOS2D_ROOT}/external/unzip + ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk + ${COCOS2D_ROOT}/external/freetype2/include/linux + ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR} +) + +link_directories( + /usr/local/lib + ${COCOS2D_ROOT}/lib + ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/curl/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} +) + +# add the executable +add_executable(${APP_NAME} + ${GAME_SRC} +) + +if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +set(FMOD_LIB "fmodex64") +else() +set(FMOD_LIB "fmodex") +endif() + +target_link_libraries(${APP_NAME} + luabinding + tolua + lua + gui + network + curl + ldap + lber + idn + rtmp + spine + cocostudio + jsoncpp + cocosbuilder + extensions + box2d + audio + ${FMOD_LIB} + cocos2d + cocosbase + chipmunk + tinyxml2 + kazmath + unzip + jpeg + webp + tiff + freetype + fontconfig + png + pthread + glfw + GLEW + GL + X11 + rt + z + ) + +set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin") + +set_target_properties(${APP_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") + +pre_build(${APP_NAME} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + ) + diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index e8d45a1415..4852ab01f9 100755 --- a/tools/travis-scripts/run-script.sh +++ b/tools/travis-scripts/run-script.sh @@ -76,6 +76,13 @@ elif [ "$PLATFORM"x = "linux"x ]; then cd linux-build cmake ../.. make -j10 + cd ../../multi-platform-cpp + cmake . + make -j10 + cd ../multi-platform-lua + cmake . + make -j10 + elif [ "$PLATFORM"x = "emscripten"x ]; then # Generate binding glue codes echo "Generating bindings glue codes ..." From 74497e18ec6ca5f439b1c1ead052e13a8d426341 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Nov 2013 18:25:58 +0800 Subject: [PATCH 044/185] [CMake template] Fix compilation errors. --- tools/travis-scripts/run-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index 4852ab01f9..b609c7cc43 100755 --- a/tools/travis-scripts/run-script.sh +++ b/tools/travis-scripts/run-script.sh @@ -76,7 +76,7 @@ elif [ "$PLATFORM"x = "linux"x ]; then cd linux-build cmake ../.. make -j10 - cd ../../multi-platform-cpp + cd ../../template/multi-platform-cpp cmake . make -j10 cd ../multi-platform-lua From 1f389d377960111f967788f5a4aafa126dadcb38 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 18:43:06 +0800 Subject: [PATCH 045/185] Rename event interface --- cocos/gui/UICheckBox.cpp | 22 ++++---- cocos/gui/UICheckBox.h | 6 +-- cocos/gui/UIPageView.cpp | 18 +++---- cocos/gui/UIPageView.h | 6 +-- cocos/gui/UIScrollView.cpp | 50 +++++++++---------- cocos/gui/UIScrollView.h | 6 +-- cocos/gui/UISlider.cpp | 18 +++---- cocos/gui/UISlider.h | 6 +-- cocos/gui/UITextField.cpp | 30 +++++------ cocos/gui/UITextField.h | 6 +-- .../UICheckBoxTest/UICheckBoxTest.cpp | 2 +- .../UIPageViewTest/UIPageViewTest.cpp | 2 +- .../UISliderTest/UISliderTest.cpp | 4 +- .../UITextFieldTest/UITextFieldTest.cpp | 6 +-- 14 files changed, 91 insertions(+), 91 deletions(-) diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index e79be3d5f0..511d03a7ea 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -34,8 +34,8 @@ _frontCrossRenderer(NULL), _backGroundBoxDisabledRenderer(NULL), _frontCrossDisabledRenderer(NULL), _isSelected(true), -_selectedStateEventListener(NULL), -_selectedStateEventSelector(NULL), +_checkBoxEventListener(NULL), +_checkBoxEventSelector(NULL), _backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL), @@ -51,8 +51,8 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - _selectedStateEventListener = NULL; - _selectedStateEventSelector = NULL; + _checkBoxEventListener = NULL; + _checkBoxEventSelector = NULL; } UICheckBox* UICheckBox::create() @@ -285,24 +285,24 @@ bool UICheckBox::getSelectedState() void UICheckBox::selectedEvent() { - if (_selectedStateEventListener && _selectedStateEventSelector) + if (_checkBoxEventListener && _checkBoxEventSelector) { - (_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); + (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); } } void UICheckBox::unSelectedEvent() { - if (_selectedStateEventListener && _selectedStateEventSelector) + if (_checkBoxEventListener && _checkBoxEventSelector) { - (_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); + (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); } } -void UICheckBox::addEventListener(cocos2d::Object *target, SEL_SelectedStateEvent selector) +void UICheckBox::addEventListenerCheckBox(cocos2d::Object *target, SEL_SelectedStateEvent selector) { - _selectedStateEventListener = target; - _selectedStateEventSelector = selector; + _checkBoxEventListener = target; + _checkBoxEventSelector = selector; } void UICheckBox::setFlipX(bool flipX) diff --git a/cocos/gui/UICheckBox.h b/cocos/gui/UICheckBox.h index 5e9c836617..26562d2b8f 100644 --- a/cocos/gui/UICheckBox.h +++ b/cocos/gui/UICheckBox.h @@ -138,7 +138,7 @@ public: virtual void setAnchorPoint(const cocos2d::Point &pt); //add a call back function would called when checkbox is selected or unselected. - void addEventListener(cocos2d::Object* target,SEL_SelectedStateEvent selector); + void addEventListenerCheckBox(cocos2d::Object* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX); @@ -190,8 +190,8 @@ protected: cocos2d::Sprite* _frontCrossDisabledRenderer; bool _isSelected; - cocos2d::Object* _selectedStateEventListener; - SEL_SelectedStateEvent _selectedStateEventSelector; + cocos2d::Object* _checkBoxEventListener; + SEL_SelectedStateEvent _checkBoxEventSelector; TextureResType _backGroundTexType; TextureResType _backGroundSelectedTexType; diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index 54b0713b7a..2183091b6d 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -42,8 +42,8 @@ _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDir(0), _childFocusCancelOffset(5.0f), -_eventListener(NULL), -_eventSelector(NULL) +_pageViewEventListener(NULL), +_pageViewEventSelector(NULL) { } @@ -51,8 +51,8 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); - _eventListener = NULL; - _eventSelector = NULL; + _pageViewEventListener = NULL; + _pageViewEventSelector = NULL; } UIPageView* UIPageView::create() @@ -565,16 +565,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const co void UIPageView::pageTurningEvent() { - if (_eventListener && _eventSelector) + if (_pageViewEventListener && _pageViewEventSelector) { - (_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING); + (_pageViewEventListener->*_pageViewEventSelector)(this, PAGEVIEW_EVENT_TURNING); } } -void UIPageView::addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector) +void UIPageView::addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector) { - _eventListener = target; - _eventSelector = selector; + _pageViewEventListener = target; + _pageViewEventSelector = selector; } int UIPageView::getCurPageIndex() const diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index ec78df8bbd..ef11056e9b 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -118,7 +118,7 @@ public: cocos2d::Array* getPages(); // event - void addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector); + void addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector); //override "removeChild" method of widget. @@ -186,8 +186,8 @@ protected: float _autoScrollSpeed; int _autoScrollDir; float _childFocusCancelOffset; - cocos2d::Object* _eventListener; - SEL_PageViewEvent _eventSelector; + cocos2d::Object* _pageViewEventListener; + SEL_PageViewEvent _pageViewEventSelector; }; diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index ebf32514da..e80bd3873c 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -69,15 +69,15 @@ _bouncing(false), _bounceDir(cocos2d::Point::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), -_eventListener(NULL), -_eventSelector(NULL) +_scrollViewEventListener(NULL), +_scrollViewEventSelector(NULL) { } UIScrollView::~UIScrollView() { - _eventListener = NULL; - _eventSelector = NULL; + _scrollViewEventListener = NULL; + _scrollViewEventSelector = NULL; } UIScrollView* UIScrollView::create() @@ -1458,80 +1458,80 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const cocos2d void UIScrollView::scrollToTopEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); } } void UIScrollView::scrollToBottomEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); } } void UIScrollView::scrollToLeftEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); } } void UIScrollView::scrollToRightEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); } } void UIScrollView::scrollingEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); } } void UIScrollView::bounceTopEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); } } void UIScrollView::bounceBottomEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); } } void UIScrollView::bounceLeftEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); } } void UIScrollView::bounceRightEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); } } -void UIScrollView::addEventListener(cocos2d::Object *target, SEL_ScrollViewEvent selector) +void UIScrollView::addEventListenerScrollView(cocos2d::Object *target, SEL_ScrollViewEvent selector) { - _eventListener = target; - _eventSelector = selector; + _scrollViewEventListener = target; + _scrollViewEventSelector = selector; } void UIScrollView::setDirection(SCROLLVIEW_DIR dir) diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 4d762930f8..94a6874376 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -231,7 +231,7 @@ public: /** * Add call back function called scrollview event triggered */ - void addEventListener(cocos2d::Object* target, SEL_ScrollViewEvent selector); + void addEventListenerScrollView(cocos2d::Object* target, SEL_ScrollViewEvent selector); //override "addChild" method of widget. virtual bool addChild(UIWidget* widget); @@ -382,8 +382,8 @@ protected: - cocos2d::Object* _eventListener; - SEL_ScrollViewEvent _eventSelector; + cocos2d::Object* _scrollViewEventListener; + SEL_ScrollViewEvent _scrollViewEventSelector; }; } diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index b5c90ccfb8..d8f2f95e86 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -46,8 +46,8 @@ _slidBallPressedTextureFile(""), _slidBallDisabledTextureFile(""), _capInsetsBarRenderer(cocos2d::Rect::ZERO), _capInsetsProgressBarRenderer(cocos2d::Rect::ZERO), -_slidPercentListener(NULL), -_slidPercentSelector(NULL), +_sliderEventListener(NULL), +_sliderEventSelector(NULL), _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), @@ -58,8 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - _slidPercentListener = NULL; - _slidPercentSelector = NULL; + _sliderEventListener = NULL; + _sliderEventSelector = NULL; } UISlider* UISlider::create() @@ -411,17 +411,17 @@ float UISlider::getPercentWithBallPos(float px) return (((px-(-_barLength/2.0f))/_barLength)*100.0f); } -void UISlider::addEventListener(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) +void UISlider::addEventListenerSlider(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) { - _slidPercentListener = target; - _slidPercentSelector = selector; + _sliderEventListener = target; + _sliderEventSelector = selector; } void UISlider::percentChangedEvent() { - if (_slidPercentListener && _slidPercentSelector) + if (_sliderEventListener && _sliderEventSelector) { - (_slidPercentListener->*_slidPercentSelector)(this,SLIDER_PERCENTCHANGED); + (_sliderEventListener->*_sliderEventSelector)(this,SLIDER_PERCENTCHANGED); } } diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index 186af44d45..ff08ba1524 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -162,7 +162,7 @@ public: /** * Add call back function called when slider's percent has changed to slider. */ - void addEventListener(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); + void addEventListenerSlider(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); //override "onTouchBegan" method of widget. virtual bool onTouchBegan(const cocos2d::Point &touchPoint); @@ -226,8 +226,8 @@ protected: cocos2d::Rect _capInsetsBarRenderer; cocos2d::Rect _capInsetsProgressBarRenderer; - cocos2d::Object* _slidPercentListener; - SEL_SlidPercentChangedEvent _slidPercentSelector; + cocos2d::Object* _sliderEventListener; + SEL_SlidPercentChangedEvent _sliderEventSelector; TextureResType _barTexType; TextureResType _progressBarTexType; TextureResType _ballNTexType; diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 6a95ac8605..75010d0261 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -275,16 +275,16 @@ _textFieldRenderer(NULL), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), -_eventListener(NULL), -_eventSelector(NULL), +_textFieldEventListener(NULL), +_textFieldEventSelector(NULL), _passwordStyleText("") { } UITextField::~UITextField() { - _eventListener = NULL; - _eventSelector = NULL; + _textFieldEventListener = NULL; + _textFieldEventSelector = NULL; } UITextField* UITextField::create() @@ -472,40 +472,40 @@ void UITextField::setDeleteBackward(bool deleteBackward) void UITextField::attachWithIMEEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); } } void UITextField::detachWithIMEEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); } } void UITextField::insertTextEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); } } void UITextField::deleteBackwardEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); } } -void UITextField::addEventListener(cocos2d::Object *target, SEL_TextFieldEvent selecor) +void UITextField::addEventListenerTextField(cocos2d::Object *target, SEL_TextFieldEvent selecor) { - _eventListener = target; - _eventSelector = selecor; + _textFieldEventListener = target; + _textFieldEventSelector = selecor; } void UITextField::setAnchorPoint(const cocos2d::Point &pt) diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index fc90ea9466..6a61faed08 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -132,7 +132,7 @@ public: void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); - void addEventListener(cocos2d::Object* target, SEL_TextFieldEvent selecor); + void addEventListenerTextField(cocos2d::Object* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const cocos2d::Point &pt); virtual void setColor(const cocos2d::Color3B &color); @@ -163,8 +163,8 @@ protected: float _touchHeight; bool _useTouchArea; - cocos2d::Object* _eventListener; - SEL_TextFieldEvent _eventSelector; + cocos2d::Object* _textFieldEventListener; + SEL_TextFieldEvent _textFieldEventSelector; std::string _passwordStyleText; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 66b0c64a96..d28264ab46 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -54,7 +54,7 @@ bool UICheckBoxTest::init() "cocosgui/check_box_active_disable.png"); checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); + checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); // checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent)); m_pUiLayer->addWidget(checkBox); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index ce5028ae35..309e9c2264 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -79,7 +79,7 @@ bool UIPageViewTest::init() pageView->addPage(layout); } - pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); + pageView->addEventListenerPageView(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); m_pUiLayer->addWidget(pageView); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 2749e061ab..cae91130ea 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -52,7 +52,7 @@ bool UISliderTest::init() slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosgui/sliderProgress.png"); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); + slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; @@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init() slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setSize(Size(250, 10)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); + slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index c486c5be3a..34534d008a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -51,7 +51,7 @@ bool UITextFieldTest::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -139,7 +139,7 @@ bool UITextFieldTest_MaxLength::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -233,7 +233,7 @@ bool UITextFieldTest_Password::init() textField->setFontSize(30); textField->setPlaceHolder("input password here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; From 8a5084effa20f70f5199514e680f7907356cde05 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 20:29:49 +0800 Subject: [PATCH 046/185] add list view event --- cocos/gui/UIListView.cpp | 45 +++++++++++++++++++++++++++++++++++++++- cocos/gui/UIListView.h | 17 +++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 81baaad41d..3017d1e929 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -32,7 +32,10 @@ UIListView::UIListView(): _model(NULL), _items(NULL), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), -_itemsMargin(0.0f) +_itemsMargin(0.0f), +_listViewEventListener(NULL), +_listViewEventSelector(NULL), +_curSelectedIndex(0) { } @@ -41,6 +44,8 @@ UIListView::~UIListView() { _items->removeAllObjects(); CC_SAFE_RELEASE(_items); + _listViewEventListener = NULL; + _listViewEventSelector = NULL; } UIListView* UIListView::create() @@ -378,6 +383,44 @@ void UIListView::refreshView() updateInnerContainerSize(); doLayout(); } + +void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector) +{ + _listViewEventListener = target; + _listViewEventSelector = selector; +} + +void UIListView::selectedItemEvent() +{ + if (_listViewEventListener && _listViewEventSelector) + { + (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECEDTITEM); + } +} + +void UIListView::interceptTouchEvent(int handleState, gui::UIWidget *sender, const cocos2d::Point &touchPoint) +{ + UIScrollView::interceptTouchEvent(handleState, sender, touchPoint); + if (handleState != 1) + { + UIWidget* parent = sender; + while (parent) + { + if (parent && parent->getParent() == _innerContainer) + { + _curSelectedIndex = getIndex(parent); + break; + } + parent = parent->getParent(); + } + selectedItemEvent(); + } +} + +int UIListView::getCurSelectedIndex() const +{ + return _curSelectedIndex; +} void UIListView::onSizeChanged() { diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index c78d06ace2..42fd7f15be 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -40,6 +40,14 @@ typedef enum LISTVIEW_GRAVITY_BOTTOM, LISTVIEW_GRAVITY_CENTER_VERTICAL, }ListViewGravity; + +typedef enum +{ + LISTVIEW_ONSELECEDTITEM +}ListViewEventType; + +typedef void (cocos2d::Object::*SEL_ListViewEvent)(cocos2d::Object*,ListViewEventType); +#define listvieweventselector(_SELECTOR) (SEL_ListViewEvent)(&_SELECTOR) class UIListView : public UIScrollView { @@ -145,6 +153,10 @@ public: */ void refreshView(); + int getCurSelectedIndex() const; + + void addEventListenerListView(cocos2d::Object* target, SEL_ListViewEvent selector); + /** * Changes scroll direction of scrollview. * @@ -164,12 +176,17 @@ protected: virtual UIWidget* createCloneInstance(); virtual void copySpecialProperties(UIWidget* model); virtual void copyClonedWidgetChildren(UIWidget* model); + void selectedItemEvent(); + virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint); protected: UIWidget* _model; cocos2d::Array* _items; ListViewGravity _gravity; float _itemsMargin; + cocos2d::Object* _listViewEventListener; + SEL_ListViewEvent _listViewEventSelector; + int _curSelectedIndex; }; } From a0f794b7df92d3b17ad0bda3f572afb590882213 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 23:26:44 +0800 Subject: [PATCH 047/185] optimize layout --- cocos/gui/UILayout.cpp | 12 +++++++++++- cocos/gui/UIListView.cpp | 1 - cocos/gui/UIWidget.h | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..84c65232d7 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -129,7 +129,17 @@ void UILayout::setClippingEnabled(bool able) void UILayout::onSizeChanged() { DYNAMIC_CAST_CLIPPINGLAYER->setClippingSize(_size); - doLayout(); + if (strcmp(getDescription(), "Layout") == 0) + { + cocos2d::ccArray* arrayChildren = _children->data; + int length = arrayChildren->num; + for (int i=0; iarr[i]; + child->updateSizeAndPosition(); + } + doLayout(); + } if (_backGroundImage) { _backGroundImage->setPosition(cocos2d::Point(_size.width/2.0f, _size.height/2.0f)); diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 3017d1e929..c6e076821d 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -381,7 +381,6 @@ void UIListView::refreshView() remedyLayoutParameter(item); } updateInnerContainerSize(); - doLayout(); } void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector) diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 02db42e731..741d580fee 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -881,6 +881,8 @@ public: virtual void onEnter(); virtual void onExit(); + void updateSizeAndPosition(); + virtual Object* getUserObject() { return _userObject; } /** * @js NA @@ -926,7 +928,6 @@ protected: void cancelUpEvent(); void longClickEvent(); void updateAnchorPoint(); - void updateSizeAndPosition(); void copyProperties(UIWidget* model); virtual UIWidget* createCloneInstance(); virtual void copySpecialProperties(UIWidget* model); From 5faae4a51ea262b911e40320c481feb69c505c0a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 11:30:50 -0800 Subject: [PATCH 049/185] removes exe bit from text files --- .../android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java | 0 .../android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java | 0 .../platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java | 0 cocos/2d/platform/ios/EAGLView.h | 0 cocos/2d/platform/ios/OpenGL_Internal.h | 0 cocos/2d/platform/mac/EAGLView.h | 0 cocos/audio/mac/CDXMacOSXSupport.h | 0 cocos/audio/mac/CDXMacOSXSupport.mm | 0 cocos/audio/proj.linux/.cproject | 0 cocos/audio/proj.linux/.project | 0 cocos/editor-support/cocostudio/CCSGUIReader.cpp | 0 cocos/editor-support/cocostudio/CCSGUIReader.h | 0 cocos/scripting/lua/script/json.lua | 0 13 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java mode change 100755 => 100644 cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java mode change 100755 => 100644 cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java mode change 100755 => 100644 cocos/2d/platform/ios/EAGLView.h mode change 100755 => 100644 cocos/2d/platform/ios/OpenGL_Internal.h mode change 100755 => 100644 cocos/2d/platform/mac/EAGLView.h mode change 100755 => 100644 cocos/audio/mac/CDXMacOSXSupport.h mode change 100755 => 100644 cocos/audio/mac/CDXMacOSXSupport.mm mode change 100755 => 100644 cocos/audio/proj.linux/.cproject mode change 100755 => 100644 cocos/audio/proj.linux/.project mode change 100755 => 100644 cocos/editor-support/cocostudio/CCSGUIReader.cpp mode change 100755 => 100644 cocos/editor-support/cocostudio/CCSGUIReader.h mode change 100755 => 100644 cocos/scripting/lua/script/json.lua diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/ios/EAGLView.h b/cocos/2d/platform/ios/EAGLView.h old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/ios/OpenGL_Internal.h b/cocos/2d/platform/ios/OpenGL_Internal.h old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/mac/EAGLView.h b/cocos/2d/platform/mac/EAGLView.h old mode 100755 new mode 100644 diff --git a/cocos/audio/mac/CDXMacOSXSupport.h b/cocos/audio/mac/CDXMacOSXSupport.h old mode 100755 new mode 100644 diff --git a/cocos/audio/mac/CDXMacOSXSupport.mm b/cocos/audio/mac/CDXMacOSXSupport.mm old mode 100755 new mode 100644 diff --git a/cocos/audio/proj.linux/.cproject b/cocos/audio/proj.linux/.cproject old mode 100755 new mode 100644 diff --git a/cocos/audio/proj.linux/.project b/cocos/audio/proj.linux/.project old mode 100755 new mode 100644 diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp old mode 100755 new mode 100644 diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h old mode 100755 new mode 100644 diff --git a/cocos/scripting/lua/script/json.lua b/cocos/scripting/lua/script/json.lua old mode 100755 new mode 100644 From f7bae6e6cb3f43391db5b54f2b6f3304d80844f6 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 19:09:21 -0800 Subject: [PATCH 050/185] coding style migrated to version 3.274 --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 51a1dc866d..57c2f6e178 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -55fe4bd3605531a58a565c46eec20dee0f81ff97 \ No newline at end of file +b8582573e1c08366c74eb53e1b9d47abb7b87f31 \ No newline at end of file From 614c6469ff930e68a242791a252c29fe7ab54531 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 19:10:38 -0800 Subject: [PATCH 051/185] Adds TOC --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 57c2f6e178..65198295ec 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -b8582573e1c08366c74eb53e1b9d47abb7b87f31 \ No newline at end of file +8944142222e4befc64d10add9f9efae2f8172191 \ No newline at end of file From 173b5f634932d94e9f7b300574d3d915985b907a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 19:13:50 -0800 Subject: [PATCH 052/185] fixes markdown --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 65198295ec..d995f1bb82 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -8944142222e4befc64d10add9f9efae2f8172191 \ No newline at end of file +53b75602e396f08d8700d154b7954d678c2d5894 \ No newline at end of file From 94ad801f3dfd9329423535a778d3a9d57dc993d2 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 20:53:34 -0800 Subject: [PATCH 053/185] Update CODING_STYLE.md --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index d995f1bb82..c8730de5d9 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -53b75602e396f08d8700d154b7954d678c2d5894 \ No newline at end of file +c563be83fa634d5f28d62f647ec099ece413b17a \ No newline at end of file From 9f16bfadd152e14ea60e24695fd7e3655753b46a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 8 Nov 2013 20:59:27 -0800 Subject: [PATCH 054/185] updated TOC --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index c8730de5d9..2a00974e4b 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -c563be83fa634d5f28d62f647ec099ece413b17a \ No newline at end of file +f86eb12e6d4835f93bd6f59d860970bcd2f74128 \ No newline at end of file From f3a5245bfa9a0a36471b0248cc68b4b58ddfb103 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 9 Nov 2013 18:11:57 +0800 Subject: [PATCH 055/185] Triggers an assert only onTouchBegan is nullptr for EventListenerTouchOneByOne. Fixes comments for checkAvailable. --- cocos/2d/CCEventListenerTouch.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCEventListenerTouch.cpp b/cocos/2d/CCEventListenerTouch.cpp index 1367645452..20e620910a 100644 --- a/cocos/2d/CCEventListenerTouch.cpp +++ b/cocos/2d/CCEventListenerTouch.cpp @@ -75,10 +75,9 @@ EventListenerTouchOneByOne* EventListenerTouchOneByOne::create() bool EventListenerTouchOneByOne::checkAvailable() { - if (onTouchBegan == nullptr && onTouchMoved == nullptr - && onTouchEnded == nullptr && onTouchCancelled == nullptr) + if (onTouchBegan == nullptr) { - CCASSERT(false, "Invalid TouchEventListener."); + CCASSERT(false, "Invalid EventListenerTouchOneByOne!"); return false; } @@ -150,7 +149,7 @@ bool EventListenerTouchAllAtOnce::checkAvailable() if (onTouchesBegan == nullptr && onTouchesMoved == nullptr && onTouchesEnded == nullptr && onTouchesCancelled == nullptr) { - CCASSERT(false, "Invalid TouchEventListener."); + CCASSERT(false, "Invalid EventListenerTouchAllAtOnce!"); return false; } From 4fba832fb1f9200923777a0f66a3f54e3d58d37b Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 9 Nov 2013 21:05:17 +0800 Subject: [PATCH 056/185] Return non-zero if ndk build fails. --- build/android-build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build/android-build.py b/build/android-build.py index d1a272c2db..c630010ef8 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -95,7 +95,8 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param): command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path) else: command = '%s -C %s %s %s' % (ndk_path, app_android_root, ndk_build_param, ndk_module_path) - os.system(command) + if os.system(command) != 0: + raise Exception("Build project [ " + app_android_root + " ] fails!") def copy_files(src, dst): @@ -205,4 +206,8 @@ if __name__ == '__main__': if len(args) == 0: usage() else: - build_samples(args, opts.ndk_build_param) + try: + build_samples(args, opts.ndk_build_param) + except Exception as e: + print e + sys.exit(1) From c4e70387f7395f7161a3f7b3293f4218787b809a Mon Sep 17 00:00:00 2001 From: psi Date: Sat, 9 Nov 2013 23:02:45 +0900 Subject: [PATCH 057/185] Close display --- cocos/2d/platform/linux/CCDevice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/platform/linux/CCDevice.cpp b/cocos/2d/platform/linux/CCDevice.cpp index 8c4d97ecd2..3b3c962413 100644 --- a/cocos/2d/platform/linux/CCDevice.cpp +++ b/cocos/2d/platform/linux/CCDevice.cpp @@ -24,6 +24,7 @@ int Device::getDPI() ((double) DisplayWidthMM(dpy,scr))); dpi = (int) (xres + 0.5); //printf("dpi = %d\n", dpi); + XCloseDisplay (dpy); } return dpi; } From 5e36021d54ecd0d08aaae6c8d1919246e1db72e6 Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:44:15 +0900 Subject: [PATCH 058/185] [Win32] fix argument type. - argument of interface is a long type. --- cocos/2d/platform/win32/CCFileUtilsWin32.cpp | 2 +- cocos/2d/platform/win32/CCFileUtilsWin32.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index a5c94dac90..216797bd9e 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -121,7 +121,7 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const return false; } -unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, unsigned long* size) +unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, long* size) { unsigned char * pBuffer = NULL; CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.h b/cocos/2d/platform/win32/CCFileUtilsWin32.h index 4f01adabeb..5c88d97cf9 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.h +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.h @@ -58,7 +58,7 @@ protected: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size) override; + virtual unsigned char* getFileData(const char* filename, const char* mode, long * size) override; /** * Gets full path for filename, resolution directory and search path. From 3d23ca328ee0629cd95aff366134ede33e62f92f Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:56:24 +0900 Subject: [PATCH 059/185] [Win32] fix compile error. - fix C2552 error in VS2012. --- cocos/gui/UILayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..a7af98c1b8 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -953,7 +953,7 @@ bool UIRectClippingNode::init() rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green(0, 1, 0, 1); _innerStencil->drawPolygon(rect, 4, green, 0, green); if (cocos2d::ClippingNode::init(_innerStencil)) { @@ -971,7 +971,7 @@ void UIRectClippingNode::setClippingSize(const cocos2d::Size &size) rect[1] = cocos2d::Point(_clippingSize.width, 0); rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green(0, 1, 0, 1); _innerStencil->clear(); _innerStencil->drawPolygon(rect, 4, green, 0, green); } From e132142689e84e3caba7122902cdf426f0730e8e Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:57:18 +0900 Subject: [PATCH 060/185] [Win32] Update libGUI project - Update files list. --- cocos/gui/proj.win32/libGUI.vcxproj | 10 +++---- cocos/gui/proj.win32/libGUI.vcxproj.filters | 30 +++++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj index b225eaa127..2712ae3900 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -12,11 +12,8 @@ - - - @@ -24,7 +21,9 @@ + + @@ -37,11 +36,8 @@ - - - @@ -49,7 +45,9 @@ + + diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters index 12f0d385ab..092f28f7e0 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -24,9 +24,6 @@ UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -72,12 +69,6 @@ System - - Layouts - - - Layouts - Layouts @@ -87,14 +78,17 @@ BaseClasses + + Layouts + + + Layouts + UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -140,12 +134,6 @@ System - - Layouts - - - Layouts - Layouts @@ -155,5 +143,11 @@ BaseClasses + + Layouts + + + Layouts + \ No newline at end of file From 286393d28eb936b1a42a7afa00fc2c19ffb6a51e Mon Sep 17 00:00:00 2001 From: samuele3 Date: Sat, 9 Nov 2013 22:58:40 +0800 Subject: [PATCH 061/185] issue #2868:Add more manual lua binding functions --- cocos/2d/CCScriptSupport.h | 2 + cocos/scripting/lua/bindings/CCLuaEngine.cpp | 91 ++ cocos/scripting/lua/bindings/CCLuaEngine.h | 2 + .../lua/bindings/LuaScriptHandlerMgr.h | 2 +- .../lua_cocos2dx_coco_studio_manual.cpp | 846 +++++++++++++++++- .../lua_cocos2dx_coco_studio_manual.hpp | 52 ++ tools/tolua/cocos2dx_studio.ini | 2 +- 7 files changed, 967 insertions(+), 30 deletions(-) diff --git a/cocos/2d/CCScriptSupport.h b/cocos/2d/CCScriptSupport.h index f5803f4cb7..60dda84147 100644 --- a/cocos/2d/CCScriptSupport.h +++ b/cocos/2d/CCScriptSupport.h @@ -212,6 +212,8 @@ enum ScriptEventType kCommonEvent, kTableViewEvent,//Now it's only used in LuaBinding kAssetsManagerEvent,//Now it's only used in Lua Binding + kCocoStudioEventListener,//Now it's only used in Lua Binding + kArmatureWrapper,//Now it's only used in Lua Binding }; struct BasicScriptData diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index dfbf607e84..efb181178b 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.cpp +++ b/cocos/scripting/lua/bindings/CCLuaEngine.cpp @@ -30,6 +30,7 @@ #include "extensions/GUI/CCControlExtension/CCControl.h" #include "LuaOpengl.h" #include "lua_cocos2dx_extension_manual.h" +#include "lua_cocos2dx_coco_studio_manual.hpp" NS_CC_BEGIN @@ -257,6 +258,16 @@ int LuaEngine::sendEvent(ScriptEvent* evt) return handleAssetsManagerEvent(evt->data); } break; + case kCocoStudioEventListener: + { + return handleCocoStudioEventListener(evt->data); + } + break; + case kArmatureWrapper: + { + return handleArmatureWrapper(evt->data); + } + break; default: break; } @@ -818,4 +829,84 @@ int LuaEngine::handleAssetsManagerEvent(void* data) return ret; } +int LuaEngine::handleCocoStudioEventListener(void* data) +{ + + if (nullptr == data) + return 0; + + BasicScriptData* eventData = static_cast(data); + if (nullptr == eventData->nativeObject || nullptr == eventData->value) + return 0; + + LuaCocoStudioEventListenerData* listenerData = static_cast(eventData->value); + + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + if (0 == handler) + return 0; + + _stack->pushObject(listenerData->objTarget, "Object"); + _stack->pushInt(listenerData->eventType); + + _stack->executeFunctionByHandler(handler, 2); + _stack->clean(); + + return 0; +} + +int LuaEngine::handleArmatureWrapper(void* data) +{ + if (nullptr == data) + return 0; + + BasicScriptData* eventData = static_cast(data); + if (nullptr == eventData->nativeObject || nullptr == eventData->value) + return 0; + + LuaArmatureWrapperEventData* wrapperData = static_cast(eventData->value); + + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 == handler) + return 0; + + switch (wrapperData->eventType) + { + case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT: + { + LuaArmatureMovementEventData* movementData = static_cast(wrapperData->eventData); + + _stack->pushObject(movementData->objTarget, "Object"); + _stack->pushInt(movementData->movementType); + _stack->pushString(movementData->movementID.c_str()); + _stack->executeFunctionByHandler(handler, 3); + } + break; + case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT: + { + LuaArmatureFrameEventData* frameData = static_cast(wrapperData->eventData); + + _stack->pushObject(frameData->objTarget, "Object"); + _stack->pushString(frameData->frameEventName.c_str()); + _stack->pushInt(frameData->originFrameIndex); + _stack->pushInt(frameData->currentFrameIndex); + _stack->executeFunctionByHandler(handler, 4); + } + break; + case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC: + { + _stack->pushFloat(*(float*)wrapperData->eventData); + _stack->executeFunctionByHandler(handler, 0); + } + break; + default: + break; + } + + _stack->clean(); + + return 0; +} + NS_CC_END diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.h b/cocos/scripting/lua/bindings/CCLuaEngine.h index e739103080..59177d65a5 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.h +++ b/cocos/scripting/lua/bindings/CCLuaEngine.h @@ -142,6 +142,8 @@ private: int handleTableViewEvent(void* data); int handleTableViewEventReturnArray(void* data,int numResults,Array& resultArray); int handleAssetsManagerEvent(void* data); + int handleCocoStudioEventListener(void* data); + int handleArmatureWrapper(void* data); void extendWebsocket(lua_State* lua_S); void extendGLNode(lua_State* lua_S); private: diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h index de42b36e9d..3d0acfc87e 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h @@ -103,7 +103,7 @@ public: ASSETSMANAGER_ERROR, EVENT_LISTENER, - EVENT_TOUCH_LISTENER, + ARMATURE_EVENT, }; typedef int Handler; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index b2ebe663b0..708c6e80a7 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -13,8 +13,10 @@ extern "C" { #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" #include "CocosGUI.h" +#include "CocoStudio.h" using namespace gui; +using namespace cocostudio; class LuaCocoStudioEventListener:public Object { @@ -22,38 +24,23 @@ public: LuaCocoStudioEventListener(); virtual ~LuaCocoStudioEventListener(); - virtual void setObjToLua(Object* obj); + virtual void setObjTarget(Object* objTarget); static LuaCocoStudioEventListener* create(); - virtual void eventCallbackFunc(Object* sender,int eventType) - { - if (nullptr == sender) - return; - - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - - if (0 != handler) - { - //call lua funtion - } - } - - - + virtual void eventCallbackFunc(Object* sender,int eventType); private: - Object* _objToLua; + Object* _objTarget; }; -LuaCocoStudioEventListener::LuaCocoStudioEventListener():_objToLua(nullptr) +LuaCocoStudioEventListener::LuaCocoStudioEventListener():_objTarget(nullptr) { } LuaCocoStudioEventListener::~LuaCocoStudioEventListener() { - if (nullptr != _objToLua) - _objToLua->release(); + } LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() @@ -67,18 +54,96 @@ LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() return listener; } -void LuaCocoStudioEventListener::setObjToLua(Object* obj) +void LuaCocoStudioEventListener::setObjTarget(Object* objTarget) { - if (nullptr != _objToLua) - _objToLua->release(); + _objTarget = objTarget; +} + +void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - _objToLua = obj; - _objToLua->retain(); + if (0 != handler) + { + LuaCocoStudioEventListenerData eventData(_objTarget,eventType); + BasicScriptData data(this,(void*)&eventData); + ScriptEvent scriptEvent(kCocoStudioEventListener,(void*)&data); + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); + } +} + +static int lua_cocos2dx_UIWidget_addTouchEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UIWidget* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UIWidget",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIWidget_addTouchEventListener'\n", NULL); + return 0; + } +#endif + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + listern->setObjTarget(obj); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->addTouchEventListener(listern, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addTouchEventListener' function of UIWidget has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendUIWidget(lua_State* L) +{ + lua_pushstring(L, "UIWidget"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addTouchEventListener", lua_cocos2dx_UIWidget_addTouchEventListener); + } } static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) { - if (NULL == L) + if (nullptr == L) return 0; int argc = 0; @@ -117,7 +182,7 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); - listern->setObjToLua(obj); + listern->setObjTarget(obj); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->addEventListener(listern, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); @@ -135,6 +200,7 @@ tolua_lerror: #endif } + static void extendUICheckBox(lua_State* L) { lua_pushstring(L, "UICheckBox"); @@ -145,12 +211,736 @@ static void extendUICheckBox(lua_State* L) } } -int register_all_cocos2dx_coco_studio_manual(lua_State* L) +static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) { if (nullptr == L) return 0; + int argc = 0; + UISlider* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UISlider",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + listern->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->addEventListener(listern, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListener' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 2); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendUISlider(lua_State* L) +{ + lua_pushstring(L, "UISlider"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_UISlider_addEventListener); + } +} + +static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UITextField* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UITextField",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + listern->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->addEventListener(listern, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListener' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 2); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendUITextField(lua_State* L) +{ + lua_pushstring(L, "UITextField"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_UITextField_addEventListener); + } +} + +static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UIPageView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UIPageView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListener'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + listern->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->addEventListener(listern, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListener' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 2); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendUIPageView(lua_State* L) +{ + lua_pushstring(L, "UIPageView"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListener", lua_cocos2dx_UIPageView_addEventListener); + } +} + +//static int lua_cocos2dx_UIListView_addEventListener(lua_State* L) +//{ +// if (nullptr == L) +// return 0; +// +// int argc = 0; +// UIListView* self = nullptr; +// +//#if COCOS2D_DEBUG >= 1 +// tolua_Error tolua_err; +// if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror; +//#endif +// +// self = static_cast(tolua_tousertype(L,1,0)); +// +//#if COCOS2D_DEBUG >= 1 +// if (nullptr == self) { +// tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListener'\n", NULL); +// return 0; +// } +//#endif +// argc = lua_gettop(L) - 1; +// if (2 == argc) +// { +//#if COCOS2D_DEBUG >= 1 +// if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || +// !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) +// { +// goto tolua_lerror; +// } +//#endif +// LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); +// if (nullptr == listern) +// { +// tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); +// return 0; +// } +// +// LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); +// Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); +// +// listern->setObjToLua(obj); +// ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); +// +// self->addEventListener(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); +// +// return 0; +// } +// +// CCLOG("'addEventListener' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 2); +// +// return 0; +// +//#if COCOS2D_DEBUG >= 1 +//tolua_lerror: +// tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); +// return 0; +//#endif +//} +// +//static void extendUIListView(lua_State* L) +//{ +// lua_pushstring(L, "UIListView"); +// lua_rawget(L, LUA_REGISTRYINDEX); +// if (lua_istable(L,-1)) +// { +// tolua_function(L, "addEventListener", lua_cocos2dx_UIListView_addEventListener); +// } +//} + +static int lua_cocos2dx_UILayoutParameter_setMargin(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UILayoutParameter* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UILayoutParameter",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UILayoutParameter_setMargin'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + { + goto tolua_lerror; + } +#endif + + UIMargin margin; + lua_pushstring(L, "left"); + lua_gettable(L,2); + margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "top"); + lua_gettable(L,2); + margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "right"); + lua_gettable(L,2); + margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "bottom"); + lua_gettable(L,2); + margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + self->setMargin(margin); + return 0; + } + + CCLOG("'setMargin' function of UILayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2dx_UILayoutParameter_getMargin(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UILayoutParameter* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (0 == argc) + { + UIMargin margin = self->getMargin(); + + lua_newtable(L); + + lua_pushstring(L, "left"); + lua_pushnumber(L, (lua_Number) margin.left); + lua_rawset(L, -3); + + lua_pushstring(L, "top"); + lua_pushnumber(L, (lua_Number) margin.top); + lua_rawset(L, -3); + + lua_pushstring(L, "right"); + lua_pushnumber(L, (lua_Number) margin.right); + lua_rawset(L, -3); + + lua_pushstring(L, "bottom"); + lua_pushnumber(L, (lua_Number) margin.bottom); + lua_rawset(L, -3); + + return 1; + } + + CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err); + return 0; +#endif +} + +static void extendLayoutParameter(lua_State* L) +{ + lua_pushstring(L, "LayoutParameter"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "setMargin", lua_cocos2dx_UILayoutParameter_setMargin); + tolua_function(L, "getMargin", lua_cocos2dx_UILayoutParameter_getMargin); + } +} + +class LuaArmatureWrapper:public Object +{ +public: + LuaArmatureWrapper(); + virtual ~LuaArmatureWrapper(); + + virtual void setObjTarget(Object* objTarget); + virtual void movementEventCallback(Armature* armature, MovementEventType type,const char* movementID); + virtual void frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex); + virtual void addArmatureFileInfoAsyncCallback(float percent); +private: + Object* _objTarget; +}; + +LuaArmatureWrapper::LuaArmatureWrapper():_objTarget(nullptr) +{ + +} + +LuaArmatureWrapper::~LuaArmatureWrapper() +{ + +} + +void LuaArmatureWrapper::setObjTarget(Object* objTarget) +{ + _objTarget = objTarget; +} + +void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strMovementID = movementID; + LuaArmatureMovementEventData movementData(armature,(int)type, strMovementID); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); + + BasicScriptData data(this,(void*)&wrapperData); + + ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data); + + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); + } +} + +void LuaArmatureWrapper::frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strFrameEventName(frameEventName); + + LuaArmatureFrameEventData frameData(bone,strFrameEventName,orginFrameIndex,currentFrameIndex); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); + + BasicScriptData data(this,(void*)&wrapperData); + + ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data); + + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); + } +} + +void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC , (void*)&percent); + + BasicScriptData data(this,(void*)&wrapperData); + + ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data); + + ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); + } +} + +static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + ArmatureAnimation* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + wrapper->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback)); + + return 0; + } + + CCLOG("'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 0); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setMovementEventCallFunc'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + ArmatureAnimation* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + wrapper->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback)); + + return 0; + } +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err); + return 0; +#endif +} + +static void extendArmatureAnimation(lua_State* L) +{ + lua_pushstring(L, "ArmatureAnimation"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "setMovementEventCallFunc", lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc); + tolua_function(L, "setFrameEventCallFunc", lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc); + } +} + +static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua_State* L) +{ + if (nullptr == L) + return 0 ; + + int argc = 0; + ArmatureDataManager* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (3 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(L, 2, 0, &tolua_err) || + !tolua_isusertype(L, 3, "Object", 0, &tolua_err) || + !toluafix_isfunction(L,4,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + const char* configFilePath = tolua_tostring(L, 2, ""); + Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + LUA_FUNCTION handler = ( toluafix_ref_function(L,4,0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + wrapper->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->addArmatureFileInfoAsync(configFilePath, wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); + + return 0; + } + else if (5 == argc) + { +#if COCOS2D_DEBUG >= 1 + if ( !tolua_isstring(L, 2, 0, &tolua_err) || + !tolua_isstring(L, 3, 0, &tolua_err) || + !tolua_isstring(L, 4, 0, &tolua_err) || + !tolua_isusertype(L, 5, "Object", 0, &tolua_err) || + !toluafix_isfunction(L,6,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + const char* imagePath = tolua_tostring(L, 2, ""); + const char* plistPath = tolua_tostring(L, 3, ""); + const char* configFilePath = tolua_tostring(L, 4, ""); + + Object* obj = static_cast(tolua_tousertype(L, 5, nullptr)); + LUA_FUNCTION handler = ( toluafix_ref_function(L,6,0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + wrapper->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->addArmatureFileInfoAsync(imagePath, plistPath,configFilePath,wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); + + return 0; + } +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addArmatureFileInfoAsync'.",&tolua_err); + return 0; +#endif +} + +static void extendArmatureDataManager(lua_State* L) +{ + lua_pushstring(L, "ArmatureDataManager"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addArmatureFileInfoAsync", lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc); + } +} + +int register_all_cocos2dx_coco_studio_manual(lua_State* L) +{ + if (nullptr == L) + return 0; + extendUIWidget(L); extendUICheckBox(L); + extendUISlider(L); + extendUISlider(L); + extendUIPageView(L); +// extendUIListView(L); + extendLayoutParameter(L); + extendArmatureAnimation(L); + extendArmatureDataManager(L); return 0; } \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp index 191a58438e..179f2a115b 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp @@ -9,6 +9,58 @@ extern "C" { } #endif +#include "CCObject.h" + TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L); +struct LuaCocoStudioEventListenerData +{ + cocos2d::Object* objTarget; + int eventType; + + LuaCocoStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) + { + } +}; + +struct LuaArmatureWrapperEventData +{ + enum class LuaArmatureWrapperEventType + { + MOVEMENT_EVENT, + FRAME_EVENT, + FILE_ASYNC, + }; + + LuaArmatureWrapperEventType eventType; + void* eventData; + + LuaArmatureWrapperEventData(LuaArmatureWrapperEventType _eventType, void* _eventData):eventType(_eventType),eventData(_eventData) + { + } +}; + +struct LuaArmatureMovementEventData +{ + cocos2d::Object* objTarget; + int movementType; + std::string movementID; + + LuaArmatureMovementEventData(cocos2d::Object* _objTarget, int _movementType,const std::string& _movementID):objTarget(_objTarget),movementType(_movementType),movementID(_movementID) + { + } +}; + +struct LuaArmatureFrameEventData +{ + cocos2d::Object* objTarget; + std::string frameEventName; + int originFrameIndex; + int currentFrameIndex; + + LuaArmatureFrameEventData( cocos2d::Object* _objTarget, const std::string& _frameEventName, int _originFrameIndex, int _currentFrameIndex):objTarget(_objTarget), frameEventName(_frameEventName),originFrameIndex(_originFrameIndex), currentFrameIndex(_currentFrameIndex) + { + } +}; + #endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 6272421098..0f4ea3ffbf 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -38,7 +38,7 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWi skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc add\w*EventListener], ArmatureDataManager::[CCArmatureDataManager ~CCArmatureDataManager], - Armature::[createBone updateBlendType getCPBody setCPBody getShapeList ^getBody$], + Armature::[createBone updateBlendType setBody getShapeList ^getBody$], Skin::[(s|g)etSkinData], ArmatureAnimation::[updateHandler updateFrameData frameEvent], Bone::[(s|g)etIgnoreMovementBoneData], From d4dbc7a4424992d5bb308ea4ae08691e635a5ad1 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Sun, 10 Nov 2013 09:21:33 +0800 Subject: [PATCH 062/185] Add conversion config for long type --- .../lua/bindings/LuaBasicConversions.cpp | 24 +++++++++++++++++++ .../lua/bindings/LuaBasicConversions.h | 1 + tools/bindings-generator | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 1914d3a930..4c91daa42b 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -283,6 +283,30 @@ bool luaval_to_point(lua_State* L,int lo,Point* outValue) return ok; } +bool luaval_to_long(lua_State* L,int lo, long* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; + + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + if (ok) + { + *outValue = (long)tolua_tonumber(L, lo, 0); + } + + return ok; +} + bool luaval_to_size(lua_State* L,int lo,Size* outValue) { if (NULL == L || NULL == outValue) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 20167170df..2e2e525993 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -30,6 +30,7 @@ extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue); extern bool luaval_to_number(lua_State* L,int lo,double* outValue); extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue); extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue); +extern bool luaval_to_long(lua_State* L,int lo, long* outValue); extern bool luaval_to_point(lua_State* L,int lo,Point* outValue); extern bool luaval_to_size(lua_State* L,int lo,Size* outValue); diff --git a/tools/bindings-generator b/tools/bindings-generator index d41959ab0b..bf34fb73c4 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit d41959ab0b15c20aa0802ab5c9ef92be7b742bd4 +Subproject commit bf34fb73c4adece7b0c8194aa8ab57c5ce60fc58 From fa1a5c3735b122b145d08e3563e234257421c741 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Sun, 10 Nov 2013 11:03:27 +0800 Subject: [PATCH 063/185] Add conversion config for long type --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index bf34fb73c4..7ccbabbaa6 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit bf34fb73c4adece7b0c8194aa8ab57c5ce60fc58 +Subproject commit 7ccbabbaa677607048c511b33cb6d83b2081220e From 6e6c63e1112df6a7e2187f8114a0db1a86786f5a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sun, 10 Nov 2013 03:29:03 +0000 Subject: [PATCH 064/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 7199547f2f..c46cc8ed45 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 7199547f2f9ffbac4fdeac20e4bb50328c6d9352 +Subproject commit c46cc8ed45556e377715dcca2da91ae037dbc7e4 From c75c20de043a30c9383d25384cf75623c7baa1a0 Mon Sep 17 00:00:00 2001 From: dualface Date: Sun, 10 Nov 2013 11:49:52 +0800 Subject: [PATCH 065/185] fix Lua 5.2 compatibility --- cocos/scripting/lua/bindings/tolua_fix.c | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/cocos/scripting/lua/bindings/tolua_fix.c b/cocos/scripting/lua/bindings/tolua_fix.c index 259a05242e..f03dd59b5f 100644 --- a/cocos/scripting/lua/bindings/tolua_fix.c +++ b/cocos/scripting/lua/bindings/tolua_fix.c @@ -9,7 +9,7 @@ TOLUA_API void toluafix_open(lua_State* L) lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); - + lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_newtable(L); lua_rawset(L, LUA_REGISTRYINDEX); @@ -30,29 +30,29 @@ TOLUA_API int toluafix_pushusertype_ccobject(lua_State* L, lua_pushnil(L); return -1; } - + if (*p_refid == 0) { *p_refid = refid; - + lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */ lua_pushinteger(L, refid); /* stack: refid_ptr refid */ lua_pushlightuserdata(L, ptr); /* stack: refid_ptr refid ptr */ - + lua_rawset(L, -3); /* refid_ptr[refid] = ptr, stack: refid_ptr */ lua_pop(L, 1); /* stack: - */ - + lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */ lua_pushinteger(L, refid); /* stack: refid_type refid */ lua_pushstring(L, type); /* stack: refid_type refid type */ lua_rawset(L, -3); /* refid_type[refid] = type, stack: refid_type */ lua_pop(L, 1); /* stack: - */ - + //printf("[LUA] push CCObject OK - refid: %d, ptr: %x, type: %s\n", *p_refid, (int)ptr, type); } - + tolua_pushusertype(L, ptr, type); return 0; } @@ -63,7 +63,7 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) const char* type = NULL; void** ud = NULL; if (refid == 0) return -1; - + // get ptr from tolua_refid_ptr_mapping lua_pushstring(L, TOLUA_REFID_PTR_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_ptr */ @@ -78,14 +78,14 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) // printf("[LUA ERROR] remove CCObject with NULL ptr, refid: %d\n", refid); return -2; } - + // remove ptr from tolua_refid_ptr_mapping lua_pushinteger(L, refid); /* stack: refid_ptr refid */ lua_pushnil(L); /* stack: refid_ptr refid nil */ lua_rawset(L, -3); /* delete refid_ptr[refid], stack: refid_ptr */ lua_pop(L, 1); /* stack: - */ - - + + // get type from tolua_refid_type_mapping lua_pushstring(L, TOLUA_REFID_TYPE_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: refid_type */ @@ -97,16 +97,16 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) printf("[LUA ERROR] remove CCObject with NULL type, refid: %d, ptr: %p\n", refid, ptr); return -1; } - + type = lua_tostring(L, -1); lua_pop(L, 1); /* stack: refid_type */ - + // remove type from tolua_refid_type_mapping lua_pushinteger(L, refid); /* stack: refid_type refid */ lua_pushnil(L); /* stack: refid_type refid nil */ lua_rawset(L, -3); /* delete refid_type[refid], stack: refid_type */ lua_pop(L, 1); /* stack: - */ - + // get ubox luaL_getmetatable(L, type); /* stack: mt */ lua_pushstring(L, "tolua_ubox"); /* stack: mt key */ @@ -118,7 +118,7 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) lua_pushstring(L, "tolua_ubox"); /* stack: mt key */ lua_rawget(L, LUA_REGISTRYINDEX); /* stack: mt ubox */ }; - + lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */ lua_rawget(L,-2); /* stack: mt ubox ud */ if (lua_isnil(L, -1)) @@ -130,7 +130,7 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) } // cleanup peertable - lua_pushvalue(L, TOLUA_NOPEER); + lua_pushvalue(L, LUA_REGISTRYINDEX); lua_setfenv(L, -2); ud = (void**)lua_touserdata(L, -1); @@ -141,14 +141,14 @@ TOLUA_API int toluafix_remove_ccobject_by_refid(lua_State* L, int refid) lua_pop(L, 2); return -1; } - + // clean userdata *ud = NULL; - + lua_pushlightuserdata(L, ptr); /* stack: mt ubox ptr */ lua_pushnil(L); /* stack: mt ubox ptr nil */ lua_rawset(L, -3); /* ubox[ptr] = nil, stack: mt ubox */ - + lua_pop(L, 2); //printf("[LUA] remove CCObject, refid: %d, ptr: %x, type: %s\n", refid, (int)ptr, type); return 0; @@ -158,19 +158,19 @@ TOLUA_API int toluafix_ref_function(lua_State* L, int lo, int def) { // function at lo if (!lua_isfunction(L, lo)) return 0; - + s_function_ref_id++; - + lua_pushstring(L, TOLUA_REFID_FUNCTION_MAPPING); lua_rawget(L, LUA_REGISTRYINDEX); /* stack: fun ... refid_fun */ lua_pushinteger(L, s_function_ref_id); /* stack: fun ... refid_fun refid */ lua_pushvalue(L, lo); /* stack: fun ... refid_fun refid fun */ - + lua_rawset(L, -3); /* refid_fun[refid] = fun, stack: fun ... refid_ptr */ lua_pop(L, 1); /* stack: fun ... */ - + return s_function_ref_id; - + // lua_pushvalue(L, lo); /* stack: ... func */ // return luaL_ref(L, LUA_REGISTRYINDEX); } From 90df6fc763c3a29f0e90b94a46ffb71394ef6ffa Mon Sep 17 00:00:00 2001 From: Luis Parravicini Date: Sun, 10 Nov 2013 08:25:01 -0300 Subject: [PATCH 066/185] fixed typos --- tools/project-creator/create_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.py index be6e38babc..640fa4e038 100755 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.py @@ -30,7 +30,7 @@ def checkParams(): metavar="PROGRAMMING_NAME", type="choice", choices=["cpp", "lua", "javascript"], - help="Major programing language you want to used, should be [cpp | lua | javascript]") + help="Major programming language you want to use, should be [cpp | lua | javascript]") #parse the params (opts, args) = parser.parse_args() From 1f742b66756dabaf8e66f421741cb2a76259a0ad Mon Sep 17 00:00:00 2001 From: James Chen Date: Sun, 10 Nov 2013 20:56:40 +0800 Subject: [PATCH 067/185] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 37e302de05..71b6680d05 100644 --- a/AUTHORS +++ b/AUTHORS @@ -643,6 +643,9 @@ Developers: Fixed a bug that EventListeners can't be removed sometimes. Fixed a bug that the data size has to be specified when parsing XML using TinyXML. + Luis Parravicini (luisparravicini) + Fixed typos in create_project.py. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From ef92efcd79ec1823f5264ec36486af346cf49c78 Mon Sep 17 00:00:00 2001 From: bopohaa Date: Mon, 11 Nov 2013 02:28:27 +0300 Subject: [PATCH 068/185] Update CCImageCommon_cpp.h webp don't work for me --- cocos/2d/platform/CCImageCommon_cpp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index f2fc7a9a08..bf1f856e39 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -1737,12 +1737,12 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen) _width = config.input.width; _height = config.input.height; - int bufferSize = _width * _height * 4; - _data = new unsigned char[bufferSize]; + _dataLen = _width * _height * 4; + _data = new unsigned char[_dataLen]; config.output.u.RGBA.rgba = static_cast(_data); config.output.u.RGBA.stride = _width * 4; - config.output.u.RGBA.size = bufferSize; + config.output.u.RGBA.size = _dataLen; config.output.is_external_memory = 1; if (WebPDecode(static_cast(data), dataLen, &config) != VP8_STATUS_OK) From a6c85a3906b22a5ae38436cd08557e30d3a105d3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 10:23:05 +0800 Subject: [PATCH 069/185] issue #3137: Disabling Accelerometer when layer is destroyed. --- cocos/editor-support/cocostudio/CCInputDelegate.cpp | 3 +++ .../Classes/AccelerometerTest/AccelerometerTest.cpp | 1 + samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp | 10 ++++++++++ samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.h | 2 ++ .../Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp | 2 ++ .../Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 5 +++++ samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h | 1 + 7 files changed, 24 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.cpp b/cocos/editor-support/cocostudio/CCInputDelegate.cpp index a134e3cdfe..03ac5030a7 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.cpp +++ b/cocos/editor-support/cocostudio/CCInputDelegate.cpp @@ -47,6 +47,7 @@ InputDelegate::~InputDelegate(void) dispatcher->removeEventListener(_touchListener); dispatcher->removeEventListener(_keyboardListener); dispatcher->removeEventListener(_accelerometerListener); + Device::setAccelerometerEnabled(false); } bool InputDelegate::onTouchBegan(Touch *pTouch, Event *pEvent) @@ -196,6 +197,8 @@ void InputDelegate::setAccelerometerEnabled(bool enabled) dispatcher->removeEventListener(_accelerometerListener); _accelerometerListener = nullptr; + Device::setAccelerometerEnabled(enabled); + if (enabled) { auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(InputDelegate::onAcceleration, this)); diff --git a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index 5bc3d6a7ed..b1a8dcfcf9 100644 --- a/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp @@ -21,6 +21,7 @@ AccelerometerTest::AccelerometerTest(void) AccelerometerTest::~AccelerometerTest(void) { _ball->release(); + Device::setAccelerometerEnabled(false); } std::string AccelerometerTest::title() diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index b7a60bb7a8..7fa35c81d1 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp @@ -10,6 +10,11 @@ // Bug624Layer // //////////////////////////////////////////////////////// +Bug624Layer::~Bug624Layer() +{ + Device::setAccelerometerEnabled(false); +} + bool Bug624Layer::init() { if(BugsTestBaseLayer::init()) @@ -51,6 +56,11 @@ void Bug624Layer::onAcceleration(Acceleration* acc, Event* event) // Bug624Layer2 // //////////////////////////////////////////////////////// +Bug624Layer2::~Bug624Layer2() +{ + Device::setAccelerometerEnabled(false); +} + bool Bug624Layer2::init() { if(BugsTestBaseLayer::init()) diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.h b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.h index b5db348e67..6542ad95ba 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.h +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.h @@ -6,6 +6,7 @@ class Bug624Layer : public BugsTestBaseLayer { public: + virtual ~Bug624Layer(); virtual bool init(); void switchLayer(float dt); virtual void onAcceleration(Acceleration* acc, Event* event); @@ -16,6 +17,7 @@ public: class Bug624Layer2 : public BugsTestBaseLayer { public: + virtual ~Bug624Layer2(); virtual bool init(); void switchLayer(float dt); virtual void onAcceleration(Acceleration* acc, Event* event); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 4a4cd5e027..99c01dec70 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -91,6 +91,8 @@ ChipmunkTestLayer::~ChipmunkTestLayer() } cpSpaceFree( _space ); + + Device::setAccelerometerEnabled(false); } diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index cdc909b306..29f4b68e6d 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -199,6 +199,11 @@ void PhysicsDemo::toggleDebugCallback(Object* sender) #endif } +PhysicsDemoClickAdd::~PhysicsDemoClickAdd() +{ + Device::setAccelerometerEnabled(false); +} + void PhysicsDemoClickAdd::onEnter() { PhysicsDemo::onEnter(); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index 4ca37bd77b..a3ccc76e57 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -56,6 +56,7 @@ protected: class PhysicsDemoClickAdd : public PhysicsDemo { public: + virtual ~PhysicsDemoClickAdd(); void onEnter() override; std::string subtitle() override; From 0c4b6e7a3700853a1637310b38b87963a7926e78 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 10:40:51 +0800 Subject: [PATCH 070/185] Removing JSB Version since JSB source codes will be updated with cocos2d-x. Also, remove some unused codes. --- cocos/scripting/javascript/bindings/ScriptingCore.cpp | 2 +- .../javascript/bindings/js_bindings_core.cpp | 11 ----------- .../scripting/javascript/bindings/js_bindings_core.h | 5 ----- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 580a3b845e..263e2c0fae 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -246,7 +246,7 @@ JSBool JSBCore_version(JSContext *cx, uint32_t argc, jsval *vp) } char version[256]; - snprintf(version, sizeof(version)-1, "%s - %s", cocos2dVersion(), JSB_version); + snprintf(version, sizeof(version)-1, "%s", cocos2dVersion()); JSString * js_version = JS_InternString(cx, version); jsval ret = STRING_TO_JSVAL(js_version); diff --git a/cocos/scripting/javascript/bindings/js_bindings_core.cpp b/cocos/scripting/javascript/bindings/js_bindings_core.cpp index fbb6e808fb..645f9fa94b 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_core.cpp +++ b/cocos/scripting/javascript/bindings/js_bindings_core.cpp @@ -43,17 +43,6 @@ typedef struct _hashJSObject static tHashJSObject *hash = NULL; static tHashJSObject *reverse_hash = NULL; -// Globals -char* JSB_association_proxy_key = NULL; - -const char* JSB_version = "0.3-beta"; - - -static void its_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("Finalizing global class"); -} - //#pragma mark JSBCore - Helper free functions static void reportError(JSContext *cx, const char *message, JSErrorReport *report) { diff --git a/cocos/scripting/javascript/bindings/js_bindings_core.h b/cocos/scripting/javascript/bindings/js_bindings_core.h index 958b969b2a..33553a9287 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_core.h +++ b/cocos/scripting/javascript/bindings/js_bindings_core.h @@ -30,10 +30,6 @@ #include "chipmunk.h" #include "SimpleAudioEngine.h" -// Globals -// one shared key for associations -extern char * JSB_association_proxy_key; - #ifdef __cplusplus extern "C" { #endif @@ -77,7 +73,6 @@ extern "C" { // needed for callbacks. It does nothing. JSBool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp); - extern const char* JSB_version; #ifdef __cplusplus } #endif From 27b82f8f67c4a0c82523a2d4f3a113ec10f118e4 Mon Sep 17 00:00:00 2001 From: Marc Lepage Date: Sun, 10 Nov 2013 22:00:50 -0500 Subject: [PATCH 071/185] Fix typos and other trivial cleanup --- cocos/2d/CCSprite.h | 162 ++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 0c0b652972..317effad84 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -24,8 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __SPITE_NODE_CCSPRITE_H__ -#define __SPITE_NODE_CCSPRITE_H__ +#ifndef __SPRITE_NODE_CCSPRITE_H__ +#define __SPRITE_NODE_CCSPRITE_H__ #include "CCNode.h" #include "CCProtocols.h" @@ -54,7 +54,7 @@ struct transformValues_; * @{ */ -/** +/** * Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) ) * * Sprite can be created with an image, or with a sub-rectangle of an image. @@ -88,14 +88,14 @@ public: /// @{ /// @name Creators - + /** * Creates an empty sprite without texture. You can call setTexture method subsequently. * * @return An empty sprite object that is marked as autoreleased. */ static Sprite* create(); - + /** * Creates a sprite with an image filename. * @@ -106,7 +106,7 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* create(const std::string& filename); - + /** * Creates a sprite with an image filename and a rect. * @@ -115,7 +115,7 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* create(const std::string& filename, const Rect& rect); - + /** * Creates a sprite with an exsiting texture contained in a Texture2D object * After creation, the rect will be the size of the texture, and the offset will be (0,0). @@ -124,7 +124,7 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithTexture(Texture2D *texture); - + /** * Creates a sprite with a texture and a rect. * @@ -136,7 +136,7 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithTexture(Texture2D *texture, const Rect& rect); - + /** * Creates a sprite with an sprite frame. * @@ -144,7 +144,7 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithSpriteFrame(SpriteFrame *pSpriteFrame); - + /** * Creates a sprite with an sprite frame name. * @@ -155,31 +155,31 @@ public: * @return A valid sprite object that is marked as autoreleased. */ static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName); - + /// @} end of creators group - - + + /// @{ /// @name Initializers - + /** * Default constructor * @js ctor */ Sprite(void); - + /** * Default destructor * @js NA * @lua NA */ virtual ~Sprite(void); - + /** * Initializes an empty sprite with nothing init. */ virtual bool init(void); - + /** * Initializes a sprite with a texture. * @@ -190,7 +190,7 @@ public: * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture); - + /** * Initializes a sprite with a texture and a rect. * @@ -202,7 +202,7 @@ public: * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture, const Rect& rect); - + /** * Initializes a sprite with a texture and a rect in points, optionally rotated. * @@ -215,7 +215,7 @@ public: * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture, const Rect& rect, bool rotated); - + /** * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite * @@ -223,7 +223,7 @@ public: * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithSpriteFrame(SpriteFrame *pSpriteFrame); - + /** * Initializes a sprite with an sprite frame name. * @@ -234,7 +234,7 @@ public: * @return true if the sprite is initialized properly, false otherwise. */ virtual bool initWithSpriteFrameName(const std::string& spriteFrameName); - + /** * Initializes a sprite with an image filename. * @@ -248,7 +248,7 @@ public: * @lua init */ virtual bool initWithFile(const std::string& filename); - + /** * Initializes a sprite with an image filename, and a rect. * @@ -263,17 +263,17 @@ public: * @lua init */ virtual bool initWithFile(const std::string& filename, const Rect& rect); - + /// @} end of initializers /// @{ /// @name BatchNode methods - + /** - * Updates the quad according the rotation, position, scale values. + * Updates the quad according the rotation, position, scale values. */ virtual void updateTransform(void); - + /** * Returns the batch node object if this sprite is rendered by SpriteBatchNode * @@ -292,26 +292,26 @@ public: * @endcode */ virtual void setBatchNode(SpriteBatchNode *spriteBatchNode); - + /// @} end of BatchNode methods - - - + + + /// @{ /// @name Texture methods - + /** * Updates the texture rect of the Sprite in points. * It will call setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize) with \p rotated = false, and \p utrimmedSize = rect.size. */ virtual void setTextureRect(const Rect& rect); - + /** * Sets the texture rect, rectRotated and untrimmed size of the Sprite in points. * It will update the texture coordinates and the vertex rectangle. */ virtual void setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize); - + /** * Sets the vertex rect. * It will be called internally by setTextureRect. @@ -319,34 +319,34 @@ public: * Do not call it manually. Use setTextureRect instead. */ virtual void setVertexRect(const Rect& rect); - - /// @} end of texture methods - - + /// @} end of texture methods + + + /// @{ /// @name Frames methods - + /** * Sets a new display frame to the Sprite. */ virtual void setDisplayFrame(SpriteFrame *pNewFrame); - + /** * Returns whether or not a SpriteFrame is being displayed */ virtual bool isFrameDisplayed(SpriteFrame *pFrame) const; - + /** @deprecated Use getDisplayFrame() instead */ CC_DEPRECATED_ATTRIBUTE virtual SpriteFrame* displayFrame() { return getDisplayFrame(); }; - + /** * Returns the current displayed frame. */ virtual SpriteFrame* getDisplayFrame(); - + /// @} End of frames methods - + /// @{ /// @name Animation methods @@ -356,23 +356,23 @@ public: */ virtual void setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex); /// @} - - + + /// @{ /// @name Sprite Properties' setter/getters - - /** + + /** * Whether or not the Sprite needs to be updated in the Atlas. * * @return true if the sprite needs to be updated in the Atlas, false otherwise. */ virtual bool isDirty(void) const { return _dirty; } - - /** + + /** * Makes the Sprite to be updated in the Atlas. */ virtual void setDirty(bool bDirty) { _dirty = bDirty; } - + /** * Returns the quad (tex coords, vertex coords and color) information. * @js NA @@ -380,24 +380,24 @@ public: */ inline V3F_C4B_T2F_Quad getQuad(void) const { return _quad; } - /** + /** * Returns whether or not the texture rectangle is rotated. */ inline bool isTextureRectRotated(void) const { return _rectRotated; } - - /** - * Returns the index used on the TextureAtlas. + + /** + * Returns the index used on the TextureAtlas. */ inline int getAtlasIndex(void) const { return _atlasIndex; } - - /** + + /** * Sets the index used on the TextureAtlas. * @warning Don't modify this value unless you know what you are doing */ inline void setAtlasIndex(int atlasIndex) { _atlasIndex = atlasIndex; } - /** - * Returns the rect of the Sprite in points + /** + * Returns the rect of the Sprite in points */ inline const Rect& getTextureRect(void) { return _rect; } @@ -405,19 +405,19 @@ public: * Gets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode */ inline TextureAtlas* getTextureAtlas(void) { return _textureAtlas; } - + /** * Sets the weak reference of the TextureAtlas when the sprite is rendered using via SpriteBatchNode */ inline void setTextureAtlas(TextureAtlas *pobTextureAtlas) { _textureAtlas = pobTextureAtlas; } - /** + /** * Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex. */ inline const Point& getOffsetPosition(void) const { return _offsetPosition; } - /** + /** * Returns the flag which indicates whether the sprite is flipped horizontally or not. * * It only flips the texture of the sprite, and not the texture of the sprite's children. @@ -425,48 +425,48 @@ public: * If you want to flip the anchorPoint too, and/or to flip the children too use: * sprite->setScaleX(sprite->getScaleX() * -1); * - * @return true if the sprite is flipped horizaontally, false otherwise. + * @return true if the sprite is flipped horizontally, false otherwise. */ bool isFlippedX(void) const; /** * Sets whether the sprite should be flipped horizontally or not. * - * @param bFlipX true if the sprite should be flipped horizaontally, false otherwise. + * @param flippedX true if the sprite should be flipped horizontally, false otherwise. */ void setFlippedX(bool flippedX); - - /** @deprecated Use isFlippedX() instead + + /** @deprecated Use isFlippedX() instead * @js NA * @lua NA */ CC_DEPRECATED_ATTRIBUTE bool isFlipX() { return isFlippedX(); }; /** @deprecated Use setFlippedX() instead */ - CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flippedX) { setFlippedX(flippedX); }; - - /** + CC_DEPRECATED_ATTRIBUTE void setFlipX(bool flippedX) { setFlippedX(flippedX); }; + + /** * Return the flag which indicates whether the sprite is flipped vertically or not. - * + * * It only flips the texture of the sprite, and not the texture of the sprite's children. * Also, flipping the texture doesn't alter the anchorPoint. * If you want to flip the anchorPoint too, and/or to flip the children too use: * sprite->setScaleY(sprite->getScaleY() * -1); - * - * @return true if the sprite is flipped vertically, flase otherwise. + * + * @return true if the sprite is flipped vertically, false otherwise. */ bool isFlippedY(void) const; /** * Sets whether the sprite should be flipped vertically or not. * - * @param bFlipY true if the sprite should be flipped vertically, flase otherwise. + * @param flippedY true if the sprite should be flipped vertically, false otherwise. */ void setFlippedY(bool flippedY); - + /// @} End of Sprite properties getter/setters - + /** @deprecated Use isFlippedY() instead */ CC_DEPRECATED_ATTRIBUTE bool isFlipY() { return isFlippedY(); }; /** @deprecated Use setFlippedY() instead */ - CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); }; + CC_DEPRECATED_ATTRIBUTE void setFlipY(bool flippedY) { setFlippedY(flippedY); }; // // Overrides @@ -543,13 +543,13 @@ protected: TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference) int _atlasIndex; /// Absolute (real) Index on the SpriteSheet SpriteBatchNode* _batchNode; /// Used batch node (weak reference) - + bool _dirty; /// Whether the sprite needs to be updated bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated bool _hasChildren; /// Whether the sprite contains children bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible AffineTransform _transformToBatch; - + // // Data used when the sprite is self-rendered // @@ -575,8 +575,8 @@ protected: bool _opacityModifyRGB; // image is flipped - bool _flippedX; /// Whether the sprite is flipped horizaontally or not. - bool _flippedY; /// Whether the sprite is flipped vertically or not. + bool _flippedX; /// Whether the sprite is flipped horizontally or not + bool _flippedY; /// Whether the sprite is flipped vertically or not }; @@ -585,4 +585,4 @@ protected: NS_CC_END -#endif // __SPITE_NODE_CCSPRITE_H__ +#endif // __SPRITE_NODE_CCSPRITE_H__ From 02da3a29ccf68a99756c082d77644a4cf45e777b Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 11 Nov 2013 11:38:02 +0800 Subject: [PATCH 072/185] issue #3025: deprecate TextureCache::reloadAllTextures, call VolatileTextureMgr::reloadAllTextures instead --- cocos/2d/CCTextureCache.cpp | 7 ++++--- cocos/2d/CCTextureCache.h | 5 +++-- cocos/2d/platform/android/nativeactivity.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 7a5e835653..780e0330aa 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -417,9 +417,10 @@ Texture2D* TextureCache::getTextureForKey(const std::string &key) const void TextureCache::reloadAllTextures() { -#if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTextureMgr::reloadAllTextures(); -#endif +//will do nothing +// #if CC_ENABLE_CACHE_TEXTURE_DATA +// VolatileTextureMgr::reloadAllTextures(); +// #endif } void TextureCache::waitForQuit() diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index 8c988ff4c3..c4c14bad53 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -73,9 +73,10 @@ public: CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache() { return TextureCache::destroyInstance(); } /** Reload all textures - It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1 + should not call it, called by frame work + now the function do nothing, use VolatileTextureMgr::reloadAllTextures */ - static void reloadAllTextures(); + CC_DEPRECATED_ATTRIBUTE static void reloadAllTextures(); public: /** diff --git a/cocos/2d/platform/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index 12e25d597d..f0e52140ff 100644 --- a/cocos/2d/platform/android/nativeactivity.cpp +++ b/cocos/2d/platform/android/nativeactivity.cpp @@ -127,7 +127,7 @@ static void cocos_init(cocos_dimensions d, struct android_app* app) { cocos2d::GL::invalidateStateCache(); cocos2d::ShaderCache::getInstance()->reloadDefaultShaders(); cocos2d::DrawPrimitives::init(); - cocos2d::TextureCache::reloadAllTextures(); + cocos2d::VolatileTextureMgr::reloadAllTextures(); cocos2d::NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); cocos2d::Director::getInstance()->setGLDefaultValues(); } From 6c1144ee796608a97733b723fe734fafd650c4ac Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 11 Nov 2013 12:49:38 +0800 Subject: [PATCH 073/185] issue #2770: fix some warning --- cocos/2d/CCLabelBMFont.cpp | 4 +- cocos/2d/CCLabelTextFormatter.cpp | 4 +- cocos/2d/CCProfiling.cpp | 2 +- cocos/2d/CCScene.cpp | 6 +- cocos/2d/CCScheduler.cpp | 64 +++++++++---------- cocos/2d/CCSpriteBatchNode.cpp | 4 +- cocos/base/atitc.cpp | 2 +- cocos/base/s3tc.cpp | 2 +- .../editor-support/cocosbuilder/CCBReader.cpp | 6 +- .../cocostudio/CCDataReaderHelper.cpp | 15 ++--- .../cocostudio/CCSSceneReader.cpp | 4 +- cocos/editor-support/spine/Animation.cpp | 12 ++-- cocos/editor-support/spine/SkeletonJson.cpp | 4 +- extensions/GUI/CCScrollView/CCSorting.cpp | 2 +- extensions/assets-manager/AssetsManager.cpp | 6 +- extensions/assets-manager/AssetsManager.h | 2 +- 16 files changed, 69 insertions(+), 70 deletions(-) diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index fe6026abfe..8eda86469e 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -1073,9 +1073,9 @@ void LabelBMFont::updateLabel() int size = multiline_string.size(); unsigned short* str_new = new unsigned short[size + 1]; - for (int i = 0; i < size; ++i) + for (int j = 0; j < size; ++j) { - str_new[i] = multiline_string[i]; + str_new[j] = multiline_string[j]; } str_new[size] = '\0'; diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 87dd3cf7cd..6f85e1495a 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -200,9 +200,9 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel) int size = multiline_string.size(); unsigned short* strNew = new unsigned short[size + 1]; - for (int i = 0; i < size; ++i) + for (int j = 0; j < size; ++j) { - strNew[i] = multiline_string[i]; + strNew[j] = multiline_string[j]; } strNew[size] = 0; diff --git a/cocos/2d/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp index 1db8ba0678..3c90394d58 100644 --- a/cocos/2d/CCProfiling.cpp +++ b/cocos/2d/CCProfiling.cpp @@ -166,7 +166,7 @@ void ProfilingEndTimingBlock(const char *timerName) CCASSERT(timer, "CCProfilingTimer not found"); - long duration = chrono::duration_cast(now - timer->_startTime).count(); + long duration = static_cast(chrono::duration_cast(now - timer->_startTime).count()); timer->totalTime += duration; timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f; diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 3f05e43c83..9c636382dd 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -133,12 +133,12 @@ void Scene::addChildToPhysicsWorld(Node* child) if (_physicsWorld) { std::function addToPhysicsWorldFunc = nullptr; - addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Object* child) -> void + addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Object* obj) -> void { - if (dynamic_cast(child) != nullptr) + if (dynamic_cast(obj) != nullptr) { - Node* node = dynamic_cast(child); + Node* node = dynamic_cast(obj); if (node->getPhysicsBody()) { diff --git a/cocos/2d/CCScheduler.cpp b/cocos/2d/CCScheduler.cpp index 3f9c9da9f8..230e453a7f 100644 --- a/cocos/2d/CCScheduler.cpp +++ b/cocos/2d/CCScheduler.cpp @@ -601,31 +601,31 @@ void Scheduler::unscheduleAllWithMinPriority(int nMinPriority) } // Updates selectors - tListEntry *pEntry, *pTmp; + tListEntry *entry, *tmp; if(nMinPriority < 0) { - DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { - if(pEntry->priority >= nMinPriority) + if(entry->priority >= nMinPriority) { - unscheduleUpdateForTarget(pEntry->target); + unscheduleUpdateForTarget(entry->target); } } } if(nMinPriority <= 0) { - DL_FOREACH_SAFE(_updates0List, pEntry, pTmp) + DL_FOREACH_SAFE(_updates0List, entry, tmp) { - unscheduleUpdateForTarget(pEntry->target); + unscheduleUpdateForTarget(entry->target); } } - DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { - if(pEntry->priority >= nMinPriority) + if(entry->priority >= nMinPriority) { - unscheduleUpdateForTarget(pEntry->target); + unscheduleUpdateForTarget(entry->target); } } @@ -836,32 +836,32 @@ void Scheduler::update(float dt) } // Iterate over all the Updates' selectors - tListEntry *pEntry, *pTmp; + tListEntry *entry, *tmp; // updates with priority < 0 - DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { - if ((! pEntry->paused) && (! pEntry->markedForDeletion)) + if ((! entry->paused) && (! entry->markedForDeletion)) { - pEntry->target->update(dt); + entry->target->update(dt); } } // updates with priority == 0 - DL_FOREACH_SAFE(_updates0List, pEntry, pTmp) + DL_FOREACH_SAFE(_updates0List, entry, tmp) { - if ((! pEntry->paused) && (! pEntry->markedForDeletion)) + if ((! entry->paused) && (! entry->markedForDeletion)) { - pEntry->target->update(dt); + entry->target->update(dt); } } // updates with priority > 0 - DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { - if ((! pEntry->paused) && (! pEntry->markedForDeletion)) + if ((! entry->paused) && (! entry->markedForDeletion)) { - pEntry->target->update(dt); + entry->target->update(dt); } } @@ -909,43 +909,43 @@ void Scheduler::update(float dt) { for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--) { - SchedulerScriptHandlerEntry* pEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); - if (pEntry->isMarkedForDeletion()) + SchedulerScriptHandlerEntry* eachEntry = static_cast(_scriptHandlerEntries->getObjectAtIndex(i)); + if (eachEntry->isMarkedForDeletion()) { _scriptHandlerEntries->removeObjectAtIndex(i); } - else if (!pEntry->isPaused()) + else if (!eachEntry->isPaused()) { - pEntry->getTimer()->update(dt); + eachEntry->getTimer()->update(dt); } } } // delete all updates that are marked for deletion // updates with priority < 0 - DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesNegList, entry, tmp) { - if (pEntry->markedForDeletion) + if (entry->markedForDeletion) { - this->removeUpdateFromHash(pEntry); + this->removeUpdateFromHash(entry); } } // updates with priority == 0 - DL_FOREACH_SAFE(_updates0List, pEntry, pTmp) + DL_FOREACH_SAFE(_updates0List, entry, tmp) { - if (pEntry->markedForDeletion) + if (entry->markedForDeletion) { - this->removeUpdateFromHash(pEntry); + this->removeUpdateFromHash(entry); } } // updates with priority > 0 - DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp) + DL_FOREACH_SAFE(_updatesPosList, entry, tmp) { - if (pEntry->markedForDeletion) + if (entry->markedForDeletion) { - this->removeUpdateFromHash(pEntry); + this->removeUpdateFromHash(entry); } } diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 820a999401..17198c8cce 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -598,8 +598,8 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) { auto next = std::next(it); - std::for_each(next, _descendants.end(), [](Sprite *sprite) { - sprite->setAtlasIndex( sprite->getAtlasIndex() - 1 ); + std::for_each(next, _descendants.end(), [](Sprite *spr) { + spr->setAtlasIndex( spr->getAtlasIndex() - 1 ); }); _descendants.erase(it); diff --git a/cocos/base/atitc.cpp b/cocos/base/atitc.cpp index 3a60d6d2f7..e93cb801b2 100644 --- a/cocos/base/atitc.cpp +++ b/cocos/base/atitc.cpp @@ -138,7 +138,7 @@ static void atitc_decode_block(uint8_t **blockData, { for (int x = 0; x < 4; ++x) { - initAlpha = (alpha & 0x0f) << 28; + initAlpha = (static_cast(alpha) & 0x0f) << 28; initAlpha += initAlpha >> 4; decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3]; pixelsIndex >>= 2; diff --git a/cocos/base/s3tc.cpp b/cocos/base/s3tc.cpp index e7869df631..2995849603 100644 --- a/cocos/base/s3tc.cpp +++ b/cocos/base/s3tc.cpp @@ -126,7 +126,7 @@ static void s3tc_decode_block(uint8_t **blockData, { for (int x = 0; x < 4; ++x) { - initAlpha = (alpha & 0x0f) << 28; + initAlpha = (static_cast(alpha) & 0x0f) << 28; initAlpha += initAlpha >> 4; decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3]; pixelsIndex >>= 2; diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index 154d2b0b36..d0a70c225b 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -482,12 +482,12 @@ int CCBReader::readInt(bool pSigned) { if(pSigned) { int s = current % 2; if(s) { - num = (int)(current / 2); + num = static_cast(current / 2); } else { - num = (int)(-current / 2); + num = static_cast(-current / 2); } } else { - num = current - 1; + num = static_cast(current - 1); } this->alignBits(); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index defb268ada..17f10067ed 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -579,8 +579,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML ArmatureData *armatureData = new ArmatureData(); armatureData->init(); - const char *name = armatureXML->Attribute(A_NAME); - armatureData->name = name; + armatureData->name = armatureXML->Attribute(A_NAME); tinyxml2::XMLElement *boneXML = armatureXML->FirstChildElement(BONE); @@ -888,21 +887,21 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov //! Change rotation range from (-180 -- 180) to (-infinity -- infinity) FrameData **frames = (FrameData **)movBoneData->frameList.data->arr; - for (int i = movBoneData->frameList.count() - 1; i >= 0; i--) + for (int j = movBoneData->frameList.count() - 1; j >= 0; j--) { - if (i > 0) + if (j > 0) { - float difSkewX = frames[i]->skewX - frames[i - 1]->skewX; - float difSkewY = frames[i]->skewY - frames[i - 1]->skewY; + float difSkewX = frames[j]->skewX - frames[j - 1]->skewX; + float difSkewY = frames[j]->skewY - frames[j - 1]->skewY; if (difSkewX < -M_PI || difSkewX > M_PI) { - frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI; + frames[j - 1]->skewX = difSkewX < 0 ? frames[j - 1]->skewX - 2 * M_PI : frames[j - 1]->skewX + 2 * M_PI; } if (difSkewY < -M_PI || difSkewY > M_PI) { - frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI; + frames[j - 1]->skewY = difSkewY < 0 ? frames[j - 1]->skewY - 2 * M_PI : frames[j - 1]->skewY + 2 * M_PI; } } } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index f26b337d6a..25c84fd773 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -227,9 +227,9 @@ namespace cocostudio { const char *name = DICTOOL->getStringValue_json(subData, "name"); childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path"); - for (long i = 0; i < childrenCount; ++i) + for (long j = 0; j < childrenCount; ++j) { - const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i); + const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", j); std::string plistpath; plistpath += file_path; plistpath.append(plist); diff --git a/cocos/editor-support/spine/Animation.cpp b/cocos/editor-support/spine/Animation.cpp index 655e80be06..0cded9e16a 100644 --- a/cocos/editor-support/spine/Animation.cpp +++ b/cocos/editor-support/spine/Animation.cpp @@ -248,12 +248,12 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float bone = skeleton->bones[self->boneIndex]; if (time >= self->frames[self->framesLength - 2]) { /* Time is after last frame. */ - float amount = bone->data->rotation + self->frames[self->framesLength - 1] - bone->rotation; - while (amount > 180) - amount -= 360; - while (amount < -180) - amount += 360; - bone->rotation += amount * alpha; + float count = bone->data->rotation + self->frames[self->framesLength - 1] - bone->rotation; + while (count > 180) + count -= 360; + while (count < -180) + count += 360; + bone->rotation += count * alpha; return; } diff --git a/cocos/editor-support/spine/SkeletonJson.cpp b/cocos/editor-support/spine/SkeletonJson.cpp index 98e4be4334..6bfeeb24e7 100644 --- a/cocos/editor-support/spine/SkeletonJson.cpp +++ b/cocos/editor-support/spine/SkeletonJson.cpp @@ -118,7 +118,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S skeletonData->animationCount++; for (i = 0; i < boneCount; ++i) { - int timelineCount; + timelineCount = 0; Json* boneMap = Json_getItemAt(bones, i); const char* boneName = boneMap->name; @@ -175,7 +175,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S } for (i = 0; i < slotCount; ++i) { - int timelineCount; + timelineCount = 0; Json* slotMap = Json_getItemAt(slots, i); const char* slotName = slotMap->name; diff --git a/extensions/GUI/CCScrollView/CCSorting.cpp b/extensions/GUI/CCScrollView/CCSorting.cpp index fd9d80f32c..412aa157e1 100644 --- a/extensions/GUI/CCScrollView/CCSorting.cpp +++ b/extensions/GUI/CCScrollView/CCSorting.cpp @@ -33,7 +33,7 @@ class SortedObject : public Object, public SortableObject { public: SortedObject() : objectID(0) {} - virtual void setObjectID(unsigned int objectID) { this->objectID = objectID; } + virtual void setObjectID(unsigned int id) { this->objectID = id; } virtual unsigned int getObjectID() { return objectID; } private: unsigned int objectID; diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index 31795c4f39..06e5bd11c6 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -214,7 +214,7 @@ void AssetsManager::downloadAndUncompress() _isDownloading = false; } -void AssetsManager::update() +void AssetsManager::update(float delta) { if (_isDownloading) return; @@ -651,8 +651,8 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version class DelegateProtocolImpl : public AssetsManagerDelegateProtocol { public : - DelegateProtocolImpl(ErrorCallback errorCallback, ProgressCallback progressCallback, SuccessCallback successCallback) - : errorCallback(errorCallback), progressCallback(progressCallback), successCallback(successCallback) + DelegateProtocolImpl(ErrorCallback aErrorCallback, ProgressCallback aProgressCallback, SuccessCallback aSuccessCallback) + : errorCallback(aErrorCallback), progressCallback(aProgressCallback), successCallback(aSuccessCallback) {} virtual void onError(AssetsManager::ErrorCode errorCode) { errorCallback(int(errorCode)); } diff --git a/extensions/assets-manager/AssetsManager.h b/extensions/assets-manager/AssetsManager.h index f3e413f4bd..5608084c76 100644 --- a/extensions/assets-manager/AssetsManager.h +++ b/extensions/assets-manager/AssetsManager.h @@ -98,7 +98,7 @@ public: /* @brief Download new package if there is a new version, and uncompress downloaded zip file. * Ofcourse it will set search path that stores downloaded files. */ - virtual void update(); + virtual void update(float delta) override; /* @brief Gets url of package. */ From 0a72c3c1c2af1f3d5e9d25ff82c682b6d1ded766 Mon Sep 17 00:00:00 2001 From: 2youyou2 <501251991@qq.com> Date: Mon, 11 Nov 2013 13:33:47 +0800 Subject: [PATCH 074/185] 1.when add a skin to last index, applay it's skindata to the previous skindata 2.Do not retain target when regist frame event and movement event --- .../cocostudio/CCArmatureAnimation.cpp | 17 ++------------ .../cocostudio/CCDisplayManager.cpp | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 49aa8e1c6f..f3e5199d6c 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -69,9 +69,6 @@ ArmatureAnimation::~ArmatureAnimation(void) { CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); - - CC_SAFE_RELEASE_NULL(_movementEventTarget); - CC_SAFE_RELEASE_NULL(_frameEventTarget); } bool ArmatureAnimation::init(Armature *armature) @@ -423,23 +420,13 @@ std::string ArmatureAnimation::getCurrentMovementID() const void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc) { - if (target != _movementEventTarget) - { - CC_SAFE_RETAIN(target); - CC_SAFE_RELEASE_NULL(_movementEventTarget); - _movementEventTarget = target; - } + _movementEventTarget = target; _movementEventCallFunc = callFunc; } void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc) { - if (target != _frameEventTarget) - { - CC_SAFE_RETAIN(target); - CC_SAFE_RELEASE_NULL(_frameEventTarget); - _frameEventTarget = target; - } + _frameEventTarget = target; _frameEventCallFunc = callFunc; } diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index a8c8f5d760..6bcf7eaff3 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -142,8 +142,26 @@ void DisplayManager::addDisplay(Node *display, int index) } else { - BaseData baseData; - skin->setSkinData(baseData); + bool find = false; + + for (int i = _decoDisplayList->count()-2; i>=0; i--) + { + DecorativeDisplay *dd = static_cast(_decoDisplayList->objectAtIndex(i)); + SpriteDisplayData *spriteDisplayData = static_cast(dd->getDisplayData()); + if (spriteDisplayData) + { + find = true; + skin->setSkinData(spriteDisplayData->skinData); + static_cast(displayData)->skinData = spriteDisplayData->skinData; + break; + } + } + + if (!find) + { + BaseData baseData; + skin->setSkinData(baseData); + } } } else if (dynamic_cast(display)) From 058cd9d896db46de077ad5ddd3fb2615fc14628f Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 13:51:44 +0800 Subject: [PATCH 075/185] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 71b6680d05..d553c07d24 100644 --- a/AUTHORS +++ b/AUTHORS @@ -646,6 +646,9 @@ Developers: Luis Parravicini (luisparravicini) Fixed typos in create_project.py. + xhcnb + Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 9b9987206709f96c448d97ce693c2ba958fd6231 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 11 Nov 2013 14:11:06 +0800 Subject: [PATCH 076/185] issue #2770: fix some warning --- cocos/editor-support/cocostudio/CCDatas.h | 18 +++++++-------- cocos/editor-support/spine/CCSkeleton.cpp | 28 +++++++++++------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 4b9c2feca6..8d10f6abc0 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -163,9 +163,9 @@ public: */ virtual ~SpriteDisplayData(); - inline void setParam(const char *displayName) + inline void setParam(const char *name) { - this->displayName = displayName; + this->displayName = name; } void copy(SpriteDisplayData *displayData); public: @@ -197,9 +197,9 @@ public: */ virtual ~ArmatureDisplayData(); - inline void setParam(const char *displayName) + inline void setParam(const char *name) { - this->displayName = displayName; + this->displayName = name; } void copy(ArmatureDisplayData *displayData); public: @@ -230,9 +230,9 @@ public: */ virtual ~ParticleDisplayData() {}; - void setParam(const char *plist) + void setParam(const char *aPlist) { - this->plist = plist; + this->plist = aPlist; } void copy(ParticleDisplayData *displayData); @@ -478,10 +478,10 @@ public: struct ContourVertex2 : public cocos2d::Object { - ContourVertex2(float x, float y) + ContourVertex2(float ax, float ay) { - this->x = x; - this->y = y; + this->x = ax; + this->y = ay; } float x; diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 760dd6702c..2a95f711d7 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -63,26 +63,26 @@ void CCSkeleton::initialize () { scheduleUpdate(); } -void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) { +void CCSkeleton::setSkeletonData (SkeletonData *skeletonData, bool isOwnsSkeletonData) { skeleton = Skeleton_create(skeletonData); rootBone = skeleton->bones[0]; - this->ownsSkeletonData = ownsSkeletonData; + this->ownsSkeletonData = isOwnsSkeletonData; } CCSkeleton::CCSkeleton () { initialize(); } -CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool ownsSkeletonData) { +CCSkeleton::CCSkeleton (SkeletonData *skeletonData, bool isOwnsSkeletonData) { initialize(); - setSkeletonData(skeletonData, ownsSkeletonData); + setSkeletonData(skeletonData, isOwnsSkeletonData); } -CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) { +CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* aAtlas, float scale) { initialize(); - SkeletonJson* json = SkeletonJson_create(atlas); + SkeletonJson* json = SkeletonJson_create(aAtlas); json->scale = scale; SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data."); @@ -164,16 +164,16 @@ void CCSkeleton::draw () { DrawPrimitives::setDrawColor4B(0, 0, 255, 255); glLineWidth(1); Point points[4]; - V3F_C4B_T2F_Quad quad; + V3F_C4B_T2F_Quad tmpQuad; for (int i = 0, n = skeleton->slotCount; i < n; i++) { Slot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; RegionAttachment* attachment = (RegionAttachment*)slot->attachment; - RegionAttachment_updateQuad(attachment, slot, &quad); - points[0] = Point(quad.bl.vertices.x, quad.bl.vertices.y); - points[1] = Point(quad.br.vertices.x, quad.br.vertices.y); - points[2] = Point(quad.tr.vertices.x, quad.tr.vertices.y); - points[3] = Point(quad.tl.vertices.x, quad.tl.vertices.y); + RegionAttachment_updateQuad(attachment, slot, &tmpQuad); + points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y); + points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y); + points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y); + points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y); DrawPrimitives::drawPoly(points, 4, true); } } @@ -275,8 +275,8 @@ const BlendFunc& CCSkeleton::getBlendFunc() const return blendFunc; } -void CCSkeleton::setBlendFunc( const BlendFunc &blendFunc) { - this->blendFunc = blendFunc; +void CCSkeleton::setBlendFunc( const BlendFunc &aBlendFunc) { + this->blendFunc = aBlendFunc; } void CCSkeleton::setOpacityModifyRGB (bool value) { From 55b9462b17eaa740a9cb2f831de025273f2412a5 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 11 Nov 2013 14:21:41 +0800 Subject: [PATCH 077/185] issue #3025: directly use _textureCache in Director --- cocos/2d/CCDirector.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 5a10d83d1e..f948b099bf 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -867,14 +867,13 @@ void Director::getFPSImageData(unsigned char** datapointer, long* length) void Director::createStatsLabel() { Texture2D *texture = nullptr; - TextureCache *textureCache = _textureCache; if (_FPSLabel && _SPFLabel) { CC_SAFE_RELEASE_NULL(_FPSLabel); CC_SAFE_RELEASE_NULL(_SPFLabel); CC_SAFE_RELEASE_NULL(_drawsLabel); - textureCache->removeTextureForKey("/cc_fps_images"); + _textureCache->removeTextureForKey("/cc_fps_images"); FileUtils::getInstance()->purgeCachedEntries(); } @@ -891,7 +890,7 @@ void Director::createStatsLabel() return; } - texture = textureCache->addImage(image, "/cc_fps_images"); + texture = _textureCache->addImage(image, "/cc_fps_images"); CC_SAFE_RELEASE(image); /* From 9d5813b7d9fe2e449d94a63bd4848ed49cb26668 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sun, 10 Nov 2013 11:23:34 +0800 Subject: [PATCH 078/185] =?UTF-8?q?Some=20fixes:=201)=20Moving=20the=20imp?= =?UTF-8?q?lementation=20of=20JSStringWrapper=20to=20.cpp=20file.=20Removi?= =?UTF-8?q?ng=20override=20operator()=20which=20will=20be=20easy=20to=20ma?= =?UTF-8?q?ke=20errors.=202)=20Deleting=20JSCallFuncWrapper=20since=20it?= =?UTF-8?q?=20isn=E2=80=99t=20needed=20after=20using=20std::function=20for?= =?UTF-8?q?=20MenuItem=E2=80=99s=20Callback.=203)=20Fixing=20ChipmunkTest?= =?UTF-8?q?=20crash=20sometimes=20on=20MAC=20platform(64bit).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascript/bindings/ScriptingCore.cpp | 82 +++++++++++++++---- .../javascript/bindings/ScriptingCore.h | 57 +++---------- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../javascript/bindings/cocos2d_specifics.hpp | 13 --- .../javascript/bindings/js_bindings_core.cpp | 12 +-- .../bindings/network/XMLHTTPRequest.cpp | 8 +- 6 files changed, 90 insertions(+), 84 deletions(-) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 263e2c0fae..22de38a70b 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -60,7 +60,7 @@ static std::vector g_queue; static std::mutex g_qMutex; static std::mutex g_rwMutex; static int clientSocket = -1; -static unsigned long s_nestedLoopLevel = 0; +static uint32_t s_nestedLoopLevel = 0; // server entry point for the bg thread static void serverEntryPoint(void); @@ -377,7 +377,7 @@ void ScriptingCore::string_report(jsval val) { LOGD("val : return string is NULL"); } else { JSStringWrapper wrapper(str); - LOGD("val : return string =\n%s\n", (char *)wrapper); + LOGD("val : return string =\n%s\n", wrapper.get()); } } else if (JSVAL_IS_NUMBER(val)) { double number; @@ -631,7 +631,7 @@ JSBool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); if (string) { JSStringWrapper wrapper(string); - js_log("%s", (char *)wrapper); + js_log("%s", wrapper.get()); } } return JS_TRUE; @@ -671,14 +671,14 @@ JSBool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) // js::RootedObject* rootedGlobal = globals[name]; JSObject* debugObj = ScriptingCore::getInstance()->getDebugGlobal(); if (debugObj) { - res = ScriptingCore::getInstance()->runScript(path, debugObj); + res = ScriptingCore::getInstance()->runScript(path.get(), debugObj); } else { - JS_ReportError(cx, "Invalid global object: %s", (char*)name); + JS_ReportError(cx, "Invalid global object: %s", name.get()); return JS_FALSE; } } else { JSObject* glob = JS::CurrentGlobalOrNull(cx); - res = ScriptingCore::getInstance()->runScript(path, glob); + res = ScriptingCore::getInstance()->runScript(path.get(), glob); } return res; } @@ -764,12 +764,7 @@ void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) void ScriptingCore::cleanupSchedulesAndActions(js_proxy_t* p) { - Array * arr = JSCallFuncWrapper::getTargetForNativeNode((Node*)p->ptr); - if (arr) { - arr->removeAllObjects(); - } - - arr = JSScheduleWrapper::getTargetForJSObject(p->obj); + Array* arr = JSScheduleWrapper::getTargetForJSObject(p->obj); if (arr) { Scheduler* pScheduler = Director::getInstance()->getScheduler(); Object* pObj = NULL; @@ -1297,7 +1292,7 @@ JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** r else if (JSVAL_IS_STRING(*vp)) { JSStringWrapper str(JSVAL_TO_STRING(*vp), cx); - pArray->addObject(String::create(str)); + pArray->addObject(String::create(str.get())); } else { @@ -2373,9 +2368,11 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) JS_GetProperty(cx, jsobj, "fontName", &jsr); JS_ValueToString(cx, jsr); JSStringWrapper wrapper(jsr); - if ( wrapper ) + const char* fontName = wrapper.get(); + + if (fontName && strlen(fontName) > 0) { - out->_fontName = (char*)wrapper; + out->_fontName = fontName; } else { @@ -2539,3 +2536,58 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) // we are done here return JS_TRUE; } + +// JSStringWrapper +JSStringWrapper::JSStringWrapper() +{ + _buffer = NULL; +} + +JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) +{ + set(str, cx); +} + +JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) +{ + set(val, cx); +} + +JSStringWrapper::~JSStringWrapper() +{ + if (_buffer) + { + //JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)buffer); + delete[] _buffer; + } +} +void JSStringWrapper::set(jsval val, JSContext* cx) +{ + if (val.isString()) + { + this->set(val.toString(), cx); + } + else + { + _buffer = NULL; + } +} + +void JSStringWrapper::set(JSString* str, JSContext* cx) +{ + _string = str; + if (!cx) + { + cx = ScriptingCore::getInstance()->getGlobalContext(); + } + // JS_EncodeString isn't supported in SpiderMonkey ff19.0. + //buffer = JS_EncodeString(cx, string); + unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); + _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); +} + +const char* JSStringWrapper::get() +{ + return _buffer ? _buffer : ""; +} + diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.h b/cocos/scripting/javascript/bindings/ScriptingCore.h index 992569afc9..6a78f827fe 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.h +++ b/cocos/scripting/javascript/bindings/ScriptingCore.h @@ -248,54 +248,21 @@ JSObject* NewGlobalObject(JSContext* cx, bool debug = false); // just a simple utility to avoid mem leaking when using JSString class JSStringWrapper { - JSString* string; - const char* buffer; public: - JSStringWrapper() { - buffer = NULL; - } - JSStringWrapper(JSString* str, JSContext* cx = NULL) { - set(str, cx); - } - JSStringWrapper(jsval val, JSContext* cx = NULL) { - set(val, cx); - } - ~JSStringWrapper() { - if (buffer) { - //JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)buffer); - delete[] buffer; - } - } - void set(jsval val, JSContext* cx) { - if (val.isString()) { - this->set(val.toString(), cx); - } else { - buffer = NULL; - } - } - void set(JSString* str, JSContext* cx) { - string = str; - if (!cx) { - cx = ScriptingCore::getInstance()->getGlobalContext(); - - } - // JS_EncodeString isn't supported in SpiderMonkey ff19.0. - //buffer = JS_EncodeString(cx, string); - unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); - buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); - } - std::string get() { - return buffer; - } + JSStringWrapper(); + JSStringWrapper(JSString* str, JSContext* cx = NULL); + JSStringWrapper(jsval val, JSContext* cx = NULL); + ~JSStringWrapper(); + + void set(jsval val, JSContext* cx); + void set(JSString* str, JSContext* cx); + const char* get(); - operator std::string() { - return std::string(buffer); - } - operator char*() { - return (char*)buffer; - } private: - /* Copy and assignment are not supported. */ + JSString* _string; + const char* _buffer; + + /* Copy and assignment are not supported. */ JSStringWrapper(const JSStringWrapper &another); JSStringWrapper &operator=(const JSStringWrapper &another); }; diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index bc82fe5227..141c335bfe 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -927efea93a520eeb9db9f62c8d8eb7a7b93b08dc \ No newline at end of file +3ba4ef8fa21631bee450ece05841803624c2e636 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp index f7e9f2bdb4..3e98123689 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -101,19 +101,6 @@ protected: jsval _extraData; }; -class JSCallFuncWrapper: public JSCallbackWrapper { -public: - JSCallFuncWrapper() {} - virtual ~JSCallFuncWrapper(void) { - return; - } - - static void setTargetForNativeNode(Node *pNode, JSCallFuncWrapper *target); - static Array * getTargetForNativeNode(Node *pNode); - - void callbackFunc(Node *node); -}; - class JSScheduleWrapper: public JSCallbackWrapper { diff --git a/cocos/scripting/javascript/bindings/js_bindings_core.cpp b/cocos/scripting/javascript/bindings/js_bindings_core.cpp index 645f9fa94b..19d63c30e3 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_core.cpp +++ b/cocos/scripting/javascript/bindings/js_bindings_core.cpp @@ -57,7 +57,7 @@ static void reportError(JSContext *cx, const char *message, JSErrorReport *repor void* jsb_get_proxy_for_jsobject(JSObject *obj) { tHashJSObject *element = NULL; - HASH_FIND_INT(hash, &obj, element); + HASH_FIND_PTR(hash, &obj, element); if( element ) return element->proxy; @@ -77,13 +77,13 @@ void jsb_set_proxy_for_jsobject(void *proxy, JSObject *obj) element->proxy = proxy; element->jsObject = obj; - HASH_ADD_INT( hash, jsObject, element ); + HASH_ADD_PTR( hash, jsObject, element ); } void jsb_del_proxy_for_jsobject(JSObject *obj) { tHashJSObject *element = NULL; - HASH_FIND_INT(hash, &obj, element); + HASH_FIND_PTR(hash, &obj, element); if( element ) { HASH_DEL(hash, element); free(element); @@ -96,7 +96,7 @@ void jsb_del_proxy_for_jsobject(JSObject *obj) JSObject* jsb_get_jsobject_for_proxy(void *proxy) { tHashJSObject *element = NULL; - HASH_FIND_INT(reverse_hash, &proxy, element); + HASH_FIND_PTR(reverse_hash, &proxy, element); if( element ) return element->jsObject; @@ -112,13 +112,13 @@ void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy) element->proxy = proxy; element->jsObject = jsobj; - HASH_ADD_INT( reverse_hash, proxy, element ); + HASH_ADD_PTR( reverse_hash, proxy, element ); } void jsb_del_jsobject_for_proxy(void* proxy) { tHashJSObject *element = NULL; - HASH_FIND_INT(reverse_hash, &proxy, element); + HASH_FIND_PTR(reverse_hash, &proxy, element); if( element ) { HASH_DEL(reverse_hash, element); free(element); diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp index e3a0ba5b18..cb33e9d413 100644 --- a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp @@ -609,8 +609,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) JSStringWrapper w1(jsMethod); JSStringWrapper w2(jsURL); - method = w1; - urlstr = w2; + method = w1.get(); + urlstr = w2.get(); _url = urlstr; _meth = method; @@ -771,8 +771,8 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) JSStringWrapper w1(jsField); JSStringWrapper w2(jsValue); - field = w1; - value = w2; + field = w1.get(); + value = w2.get(); // Populate the request_header map. _setRequestHeader(field, value); From fe88f7c9414ef17fd272bba8ced625384b19c79f Mon Sep 17 00:00:00 2001 From: James Chen Date: Sun, 10 Nov 2013 13:03:24 +0800 Subject: [PATCH 079/185] Fixing memory leak of JSStringWrapper::set . --- .../javascript/bindings/ScriptingCore.cpp | 17 +++++++++-------- .../javascript/bindings/ScriptingCore.h | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 22de38a70b..bca4e18f53 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -2539,28 +2539,27 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) // JSStringWrapper JSStringWrapper::JSStringWrapper() +: _buffer(nullptr) { - _buffer = NULL; } JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) +: JSStringWrapper() { set(str, cx); } JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) +: JSStringWrapper() { set(val, cx); } JSStringWrapper::~JSStringWrapper() { - if (_buffer) - { - //JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)buffer); - delete[] _buffer; - } + CC_SAFE_DELETE_ARRAY(_buffer); } + void JSStringWrapper::set(jsval val, JSContext* cx) { if (val.isString()) @@ -2569,13 +2568,14 @@ void JSStringWrapper::set(jsval val, JSContext* cx) } else { - _buffer = NULL; + CC_SAFE_DELETE_ARRAY(_buffer); } } void JSStringWrapper::set(JSString* str, JSContext* cx) { - _string = str; + CC_SAFE_DELETE_ARRAY(_buffer); + if (!cx) { cx = ScriptingCore::getInstance()->getGlobalContext(); @@ -2583,6 +2583,7 @@ void JSStringWrapper::set(JSString* str, JSContext* cx) // JS_EncodeString isn't supported in SpiderMonkey ff19.0. //buffer = JS_EncodeString(cx, string); unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); + _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); } diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.h b/cocos/scripting/javascript/bindings/ScriptingCore.h index 6a78f827fe..7f0e367d92 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.h +++ b/cocos/scripting/javascript/bindings/ScriptingCore.h @@ -259,7 +259,6 @@ public: const char* get(); private: - JSString* _string; const char* _buffer; /* Copy and assignment are not supported. */ From 5a0df8d2e893cfbb6ee42d494275f1a65a82befa Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 10:29:30 +0800 Subject: [PATCH 080/185] =?UTF-8?q?VS2012=20doesn=E2=80=99t=20support=20in?= =?UTF-8?q?voke=20another=20constructor=20method=20in=20current=20construc?= =?UTF-8?q?tor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/scripting/javascript/bindings/ScriptingCore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index bca4e18f53..1ce7234d88 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -2544,13 +2544,13 @@ JSStringWrapper::JSStringWrapper() } JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) -: JSStringWrapper() +: _buffer(nullptr) { set(str, cx); } JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) -: JSStringWrapper() +: _buffer(nullptr) { set(val, cx); } From 55cf30b7c8a494779e475ee7fae7d4ce871cef2f Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 12:47:48 +0800 Subject: [PATCH 081/185] =?UTF-8?q?HASH=5FFIND=5FINT=20=E2=80=94>=20HASH?= =?UTF-8?q?=5FFIND=5FPTR=20for=20CCAcitonManager.cpp=20and=20CCScheduler.c?= =?UTF-8?q?pp.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/2d/CCActionManager.cpp | 18 +++++++++--------- cocos/2d/CCScheduler.cpp | 32 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp index 4a01fd7663..0b258f4a6e 100644 --- a/cocos/2d/CCActionManager.cpp +++ b/cocos/2d/CCActionManager.cpp @@ -123,7 +123,7 @@ void ActionManager::removeActionAtIndex(long index, tHashElement *element) void ActionManager::pauseTarget(Object *target) { tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { element->paused = true; @@ -133,7 +133,7 @@ void ActionManager::pauseTarget(Object *target) void ActionManager::resumeTarget(Object *target) { tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { element->paused = false; @@ -176,14 +176,14 @@ void ActionManager::addAction(Action *action, Node *target, bool paused) tHashElement *element = NULL; // we should convert it to Object*, because we save it as Object* Object *tmp = target; - HASH_FIND_INT(_targets, &tmp, element); + HASH_FIND_PTR(_targets, &tmp, element); if (! element) { element = (tHashElement*)calloc(sizeof(*element), 1); element->paused = paused; target->retain(); element->target = target; - HASH_ADD_INT(_targets, target, element); + HASH_ADD_PTR(_targets, target, element); } actionAllocWithHashElement(element); @@ -215,7 +215,7 @@ void ActionManager::removeAllActionsFromTarget(Object *target) } tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged)) @@ -250,7 +250,7 @@ void ActionManager::removeAction(Action *action) tHashElement *element = NULL; Object *target = action->getOriginalTarget(); - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { long i = ccArrayGetIndexOfObject(element->actions, action); @@ -271,7 +271,7 @@ void ActionManager::removeActionByTag(int tag, Object *target) CCASSERT(target != NULL, ""); tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { @@ -298,7 +298,7 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const CCASSERT(tag != Action::INVALID_TAG, ""); tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { @@ -330,7 +330,7 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const unsigned int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const { tHashElement *element = NULL; - HASH_FIND_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { return element->actions ? element->actions->num : 0; diff --git a/cocos/2d/CCScheduler.cpp b/cocos/2d/CCScheduler.cpp index 230e453a7f..efc80847d0 100644 --- a/cocos/2d/CCScheduler.cpp +++ b/cocos/2d/CCScheduler.cpp @@ -294,7 +294,7 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in CCASSERT(target, "Argument target must be non-NULL"); tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (! element) { @@ -304,7 +304,7 @@ void Scheduler::scheduleSelector(SEL_SCHEDULE selector, Object *target, float in { target->retain(); } - HASH_ADD_INT(_hashForTimers, target, element); + HASH_ADD_PTR(_hashForTimers, target, element); // Is this the 1st element ? Then set the pause level to all the selectors of this target element->paused = paused; @@ -352,7 +352,7 @@ void Scheduler::unscheduleSelector(SEL_SCHEDULE selector, Object *target) //CCASSERT(selector); tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { @@ -448,7 +448,7 @@ void Scheduler::priorityIn(tListEntry **list, Object *target, int priority, bool target->retain(); pHashElement->list = list; pHashElement->entry = listElement; - HASH_ADD_INT(_hashForUpdates, target, pHashElement); + HASH_ADD_PTR(_hashForUpdates, target, pHashElement); } void Scheduler::appendIn(_listEntry **list, Object *target, bool paused) @@ -467,14 +467,14 @@ void Scheduler::appendIn(_listEntry **list, Object *target, bool paused) target->retain(); pHashElement->list = list; pHashElement->entry = listElement; - HASH_ADD_INT(_hashForUpdates, target, pHashElement); + HASH_ADD_PTR(_hashForUpdates, target, pHashElement); } void Scheduler::scheduleUpdateForTarget(Object *target, int priority, bool paused) { tHashUpdateEntry *pHashElement = NULL; - HASH_FIND_INT(_hashForUpdates, &target, pHashElement); + HASH_FIND_PTR(_hashForUpdates, &target, pHashElement); if (pHashElement) { #if COCOS2D_DEBUG >= 1 @@ -509,7 +509,7 @@ bool Scheduler::isScheduledForTarget(SEL_SCHEDULE selector, Object *target) CCASSERT(target, "Argument target must be non-NULL"); tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (!element) { @@ -541,7 +541,7 @@ void Scheduler::removeUpdateFromHash(struct _listEntry *entry) { tHashUpdateEntry *element = NULL; - HASH_FIND_INT(_hashForUpdates, &entry->target, element); + HASH_FIND_PTR(_hashForUpdates, &entry->target, element); if (element) { // list entry @@ -567,7 +567,7 @@ void Scheduler::unscheduleUpdateForTarget(const Object *target) } tHashUpdateEntry *element = NULL; - HASH_FIND_INT(_hashForUpdates, &target, element); + HASH_FIND_PTR(_hashForUpdates, &target, element); if (element) { if (_updateHashLocked) @@ -645,7 +645,7 @@ void Scheduler::unscheduleAllForTarget(Object *target) // Custom Selectors tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { @@ -702,7 +702,7 @@ void Scheduler::resumeTarget(Object *target) // custom selectors tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { element->paused = false; @@ -710,7 +710,7 @@ void Scheduler::resumeTarget(Object *target) // update selector tHashUpdateEntry *elementUpdate = NULL; - HASH_FIND_INT(_hashForUpdates, &target, elementUpdate); + HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { CCASSERT(elementUpdate->entry != NULL, ""); @@ -724,7 +724,7 @@ void Scheduler::pauseTarget(Object *target) // custom selectors tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if (element) { element->paused = true; @@ -732,7 +732,7 @@ void Scheduler::pauseTarget(Object *target) // update selector tHashUpdateEntry *elementUpdate = NULL; - HASH_FIND_INT(_hashForUpdates, &target, elementUpdate); + HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if (elementUpdate) { CCASSERT(elementUpdate->entry != NULL, ""); @@ -746,7 +746,7 @@ bool Scheduler::isTargetPaused(Object *target) // Custom selectors tHashTimerEntry *element = NULL; - HASH_FIND_INT(_hashForTimers, &target, element); + HASH_FIND_PTR(_hashForTimers, &target, element); if( element ) { return element->paused; @@ -754,7 +754,7 @@ bool Scheduler::isTargetPaused(Object *target) // We should check update selectors if target does not have custom selectors tHashUpdateEntry *elementUpdate = NULL; - HASH_FIND_INT(_hashForUpdates, &target, elementUpdate); + HASH_FIND_PTR(_hashForUpdates, &target, elementUpdate); if ( elementUpdate ) { return elementUpdate->entry->paused; From ff3bfbe8a27fc23580738a0d0e2aefa3be6cb641 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 12:54:36 +0800 Subject: [PATCH 082/185] Using std::unordered_map instead of UTHASH for js_type_class_t. Since xxx.hash_code() return size_t which is 8bytes on 64bit system, we should not use HASH_ADD_INT and HASH_FIND_INT for js_type_class_t. --- .../javascript/bindings/ScriptingCore.cpp | 14 +- .../chipmunk/js_bindings_chipmunk_manual.cpp | 137 +++++++++++------- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../javascript/bindings/cocos2d_specifics.hpp | 19 ++- .../bindings/js_bindings_opengl.cpp | 28 ++-- .../bindings/spidermonkey_specifics.h | 7 +- 6 files changed, 121 insertions(+), 86 deletions(-) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 1ce7234d88..462debba9d 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -67,7 +67,8 @@ static void serverEntryPoint(void); js_proxy_t *_native_js_global_ht = NULL; js_proxy_t *_js_native_global_ht = NULL; -js_type_class_t *_js_global_type_ht = NULL; +std::unordered_map _js_global_type_map; + static char *_js_log_buf = NULL; static std::vector registrationList; @@ -605,14 +606,13 @@ void ScriptingCore::cleanup() _js_log_buf = NULL; } - js_type_class_t* current, *tmp; - HASH_ITER(hh, _js_global_type_ht, current, tmp) + for (auto iter = _js_global_type_map.begin(); iter != _js_global_type_map.end(); ++iter) { - HASH_DEL(_js_global_type_ht, current); - free(current->jsclass); - free(current); + free(iter->second->jsclass); + free(iter->second); } - HASH_CLEAR(hh, _js_global_type_ht); + + _js_global_type_map.clear(); } void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp index 903b777fde..d7c9f94f57 100644 --- a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.cpp @@ -42,9 +42,13 @@ static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { T* cobj = new T(); cobj->autorelease(); js_type_class_t *p; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - assert(p); + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + p = typeMapIter->second; + CCASSERT(p, "The value is null."); + JSObject *_tmp = JS_NewObject(cx, p->jsclass, p->proto, p->parentProto); js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); JS_AddObjectRoot(cx, &pp->obj); @@ -179,10 +183,14 @@ JSBool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_ do { if (ret) { TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); @@ -265,24 +273,27 @@ void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JSObject* globalObj, cons }; TypeTest t1; - js_type_class_t *typeClass; - uint32_t typeId = t1.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t1.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, typeClass->proto, JSB_CCPhysicsDebugNode_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); TypeTest t; js_type_class_t *p; typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - if (!p) { + + if (_js_global_type_map.find(typeId) == _js_global_type_map.end()) + { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->type = typeId; p->jsclass = JSB_CCPhysicsDebugNode_class; p->proto = JSB_CCPhysicsDebugNode_object; p->parentProto = typeClass->proto; - HASH_ADD_INT(_js_global_type_ht, type, p); + _js_global_type_map.insert(std::make_pair(typeId, p)); } } @@ -305,10 +316,13 @@ JSBool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32 do { if (ret) { TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); @@ -331,10 +345,12 @@ JSBool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32 do { if (ret) { TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); @@ -370,10 +386,12 @@ JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint do { if (ret) { TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); jsret = OBJECT_TO_JSVAL(obj); js_proxy_t *p = jsb_new_proxy(ret, obj); @@ -393,29 +411,35 @@ JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, JSBool ok = JS_TRUE; const char* arg0; std::string arg0_tmp; - if (argc >= 1) { + if (argc == 1) { ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - } - PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return JS_TRUE; + PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); + + jsval jsret; + do { + if (ret) { + TypeTest t; + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; } void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JSObject* globalObj) @@ -450,24 +474,25 @@ void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JSObject* globalObj) }; TypeTest t1; - js_type_class_t *typeClass; - uint32_t typeId = t1.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t1.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, typeClass->proto, JSPROXY_CCPhysicsSprite_class, dummy_constructor, 0,properties,funcs,NULL,st_funcs); TypeTest t; js_type_class_t *p; typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - if (!p) { + if (_js_global_type_map.find(typeId) == _js_global_type_map.end()) + { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->type = typeId; p->jsclass = JSPROXY_CCPhysicsSprite_class; p->proto = JSPROXY_CCPhysicsSprite_object; p->parentProto = typeClass->proto; - HASH_ADD_INT(_js_global_type_ht, type, p); + _js_global_type_map.insert(std::make_pair(typeId, p)); } } diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 141c335bfe..bbc36bbe5b 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -3ba4ef8fa21631bee450ece05841803624c2e636 \ No newline at end of file +36a6cc6177c059364c6ccc3b1151b6475219b396 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp index 3e98123689..9c03489007 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -39,14 +39,23 @@ extern callfuncTarget_proxy_t *_callfuncTarget_native_ht; */ template inline js_type_class_t *js_get_type_from_native(T* native_obj) { - js_type_class_t *typeProxy; + bool found = false; long typeId = typeid(*native_obj).hash_code(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); - if (!typeProxy) { + auto typeProxyIter = _js_global_type_map.find(typeId); + if (typeProxyIter == _js_global_type_map.end()) + { typeId = typeid(T).hash_code(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy); + typeProxyIter = _js_global_type_map.find(typeId); + if (typeProxyIter != _js_global_type_map.end()) + { + found = true; + } } - return typeProxy; + else + { + found = true; + } + return found ? typeProxyIter->second : nullptr; } /** diff --git a/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp b/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp index 9fbf145647..3a35eab630 100644 --- a/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp +++ b/cocos/scripting/javascript/bindings/js_bindings_opengl.cpp @@ -32,24 +32,27 @@ JSBool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 0) { GLNode* cobj = new GLNode(); -#ifdef COCOS2D_JAVASCRIPT cocos2d::Object *_ccobj = dynamic_cast(cobj); if (_ccobj) { _ccobj->autorelease(); } -#endif + TypeTest t; - js_type_class_t *typeClass; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, typeClass); - assert(typeClass); + js_type_class_t *typeClass = nullptr; + long typeId = t.s_id(); + auto typeMapIter = _js_global_type_map.find(typeId); + + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); // link the native object with the javascript object js_proxy_t *p = jsb_new_proxy(cobj, obj); -#ifdef COCOS2D_JAVASCRIPT + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLNode"); -#endif + return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); @@ -131,14 +134,13 @@ void js_register_cocos2dx_GLNode(JSContext *cx, JSObject *global) { // add the proto and JSClass to the type->js info hash table TypeTest t; js_type_class_t *p; - uint32_t typeId = t.s_id(); - HASH_FIND_INT(_js_global_type_ht, &typeId, p); - if (!p) { + long typeId = t.s_id(); + if (_js_global_type_map.find(typeId) == _js_global_type_map.end()) + { p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->type = typeId; p->jsclass = js_cocos2dx_GLNode_class; p->proto = js_cocos2dx_GLNode_prototype; p->parentProto = jsb_Node_prototype; - HASH_ADD_INT(_js_global_type_ht, type, p); + _js_global_type_map.insert(std::make_pair(typeId, p)); } } diff --git a/cocos/scripting/javascript/bindings/spidermonkey_specifics.h b/cocos/scripting/javascript/bindings/spidermonkey_specifics.h index be9c709c49..e526ad7e7a 100644 --- a/cocos/scripting/javascript/bindings/spidermonkey_specifics.h +++ b/cocos/scripting/javascript/bindings/spidermonkey_specifics.h @@ -3,6 +3,7 @@ #include "jsapi.h" #include "uthash.h" +#include typedef struct js_proxy { void *ptr; @@ -14,20 +15,18 @@ extern js_proxy_t *_native_js_global_ht; extern js_proxy_t *_js_native_global_ht; typedef struct js_type_class { - uint32_t type; JSClass *jsclass; JSObject *proto; JSObject *parentProto; - UT_hash_handle hh; } js_type_class_t; -extern js_type_class_t *_js_global_type_ht; +extern std::unordered_map _js_global_type_map; template< typename DERIVED > class TypeTest { public: - static int s_id() + static long s_id() { // return id unique for DERIVED // NOT SURE IT WILL BE REALLY UNIQUE FOR EACH CLASS!! From 8f8d0f86d773a8a11b60bacadf2a7b0779e127e3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 13:02:20 +0800 Subject: [PATCH 083/185] Updating Bindings-generator. --- cocos/scripting/auto-generated | 2 +- tools/bindings-generator | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index c46cc8ed45..7199547f2f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit c46cc8ed45556e377715dcca2da91ae037dbc7e4 +Subproject commit 7199547f2f9ffbac4fdeac20e4bb50328c6d9352 diff --git a/tools/bindings-generator b/tools/bindings-generator index 7ccbabbaa6..22520b8b34 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 7ccbabbaa677607048c511b33cb6d83b2081220e +Subproject commit 22520b8b34bcc73c2adfdf234798908a7dd563b4 From 9d7a8c44f94ff78c6907d0e75829f544a43bbc78 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 14:40:23 +0800 Subject: [PATCH 084/185] Reverts auto-generated. --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 7199547f2f..c46cc8ed45 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 7199547f2f9ffbac4fdeac20e4bb50328c6d9352 +Subproject commit c46cc8ed45556e377715dcca2da91ae037dbc7e4 From 5ba1e4ce105518dea858fe3d1679050e48c6a146 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 11 Nov 2013 14:50:30 +0800 Subject: [PATCH 085/185] 1.remove compiler wornings 2.change void Bone::removeFromParent(bool recursion); to void Bone::removeFromParent(); --- .../editor-support/cocostudio/CCArmature.cpp | 2 +- .../cocostudio/CCArmatureAnimation.cpp | 2 +- .../cocostudio/CCArmatureAnimation.h | 1 + cocos/editor-support/cocostudio/CCBone.cpp | 19 +++++++--------- cocos/editor-support/cocostudio/CCBone.h | 5 ++--- .../cocostudio/CCDataReaderHelper.cpp | 13 +++++------ cocos/editor-support/cocostudio/CCDatas.h | 22 ++++++------------- .../cocostudio/CCProcessBase.cpp | 2 +- .../editor-support/cocostudio/CCProcessBase.h | 3 +-- cocos/editor-support/cocostudio/CCTween.cpp | 2 +- cocos/editor-support/cocostudio/CCTween.h | 1 + 11 files changed, 30 insertions(+), 42 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index b09922ff70..0e19914954 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -289,7 +289,7 @@ void Armature::removeBone(Bone *bone, bool recursion) CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); - bone->removeFromParent(recursion); + bone->removeFromParent(); if (_topBoneList->containsObject(bone)) { diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 49aa8e1c6f..47a475d34a 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -208,7 +208,7 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura loop = (loop < 0) ? _movementData->loop : loop; - ProcessBase::play((void *)animationName, durationTo, durationTween, loop, tweenEasing); + ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (_rawDuration == 0) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 8d306398e9..ffc9401dda 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -100,6 +100,7 @@ public: //! The animation update speed virtual void setAnimationInternal(float animationInternal); + using ProcessBase::play; /** * Play animation by animation name. * diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index cbd4544120..17541e2e78 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -322,19 +322,16 @@ void Bone::addChildBone(Bone *child) } } -void Bone::removeChildBone(Bone *bone, bool recursion) +void Bone::removeChildBone(Bone *bone) { if (_children && _children->getIndexOfObject(bone) != UINT_MAX ) { - if(recursion) - { - Array *ccbones = bone->_children; + Array *ccbones = bone->_children; - for(auto object : *ccbones) - { - Bone *ccBone = (Bone *)object; - bone->removeChildBone(ccBone, recursion); - } + for(auto object : *ccbones) + { + Bone *ccBone = (Bone *)object; + bone->removeChildBone(ccBone); } bone->setParentBone(nullptr); @@ -345,11 +342,11 @@ void Bone::removeChildBone(Bone *bone, bool recursion) } } -void Bone::removeFromParent(bool recursion) +void Bone::removeFromParent() { if (nullptr != _parentBone) { - _parentBone->removeChildBone(this, recursion); + _parentBone->removeChildBone(this); } } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 4d67c41e2e..17dc334c34 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -114,15 +114,14 @@ public: /** * Remove itself from its parent. - * @param recursion whether or not to remove childBone's display */ - void removeFromParent(bool recursion); + void removeFromParent(); /** * Removes a child Bone * @param bone the bone you want to remove */ - void removeChildBone(Bone *bone, bool recursion); + void removeChildBone(Bone *bone); void update(float delta) override; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index defb268ada..45c5d85d41 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -595,10 +595,10 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML if (parentName) { parentXML = armatureXML->FirstChildElement(BONE); - std::string name = parentName; + std::string parentNameStr = parentName; while (parentXML) { - if (name.compare(parentXML->Attribute(A_NAME)) == 0) + if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0) { break; } @@ -823,7 +823,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov } int length = 0; - int i = 0; + int index = 0; int parentTotalDuration = 0; int currentDuration = 0; @@ -864,13 +864,12 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov /* * in this loop we get the corresponding parent frame xml */ - while(i < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) + while(index < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { - parentFrameXML = parentXmlList[i]; + parentFrameXML = parentXmlList[index]; parentTotalDuration += currentDuration; parentFrameXML->QueryIntAttribute(A_DURATION, ¤tDuration); - i++; - + index++; } } diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 4b9c2feca6..065726472e 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -163,10 +163,8 @@ public: */ virtual ~SpriteDisplayData(); - inline void setParam(const char *displayName) - { - this->displayName = displayName; - } + void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; } + void copy(SpriteDisplayData *displayData); public: /** @@ -197,10 +195,7 @@ public: */ virtual ~ArmatureDisplayData(); - inline void setParam(const char *displayName) - { - this->displayName = displayName; - } + void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; } void copy(ArmatureDisplayData *displayData); public: /** @@ -230,10 +225,7 @@ public: */ virtual ~ParticleDisplayData() {}; - void setParam(const char *plist) - { - this->plist = plist; - } + void setParam(const char *pszPlistName) { this->plist = pszPlistName; } void copy(ParticleDisplayData *displayData); public: @@ -478,10 +470,10 @@ public: struct ContourVertex2 : public cocos2d::Object { - ContourVertex2(float x, float y) + ContourVertex2(float xx, float yy) { - this->x = x; - this->y = y; + this->x = xx; + this->y = yy; } float x; diff --git a/cocos/editor-support/cocostudio/CCProcessBase.cpp b/cocos/editor-support/cocostudio/CCProcessBase.cpp index 62bac419b6..f13769e3f7 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.cpp +++ b/cocos/editor-support/cocostudio/CCProcessBase.cpp @@ -77,7 +77,7 @@ void ProcessBase::stop() _currentPercent = 0; } -void ProcessBase::play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing) +void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEasing) { _isComplete = false; _isPause = false; diff --git a/cocos/editor-support/cocostudio/CCProcessBase.h b/cocos/editor-support/cocostudio/CCProcessBase.h index 2b3ef4ab47..e763616c38 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.h +++ b/cocos/editor-support/cocostudio/CCProcessBase.h @@ -63,7 +63,6 @@ public: /** * Play animation by animation name. * - * @param animation It will not used in the ProcessBase Class * @param durationTo The frames between two animation changing-over. * It's meaning is changing to this animation need how many frames * @@ -88,7 +87,7 @@ public: * 2 : fade in and out * */ - virtual void play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing); + virtual void play(int durationTo, int durationTween, int loop, int tweenEasing); /** * Pause the Process diff --git a/cocos/editor-support/cocostudio/CCTween.cpp b/cocos/editor-support/cocostudio/CCTween.cpp index dec84bf295..953ea34583 100644 --- a/cocos/editor-support/cocostudio/CCTween.cpp +++ b/cocos/editor-support/cocostudio/CCTween.cpp @@ -98,7 +98,7 @@ bool Tween::init(Bone *bone) void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing) { - ProcessBase::play(nullptr, durationTo, durationTween, loop, tweenEasing); + ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (loop) { diff --git a/cocos/editor-support/cocostudio/CCTween.h b/cocos/editor-support/cocostudio/CCTween.h index 8b4dcba9d2..ab8bb3f7ff 100644 --- a/cocos/editor-support/cocostudio/CCTween.h +++ b/cocos/editor-support/cocostudio/CCTween.h @@ -59,6 +59,7 @@ public: */ virtual bool init(Bone *bone); + using ProcessBase::play; /** * Start the Process * From 00b477e7563fc4b427069e179d9a346423af7431 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Nov 2013 15:11:28 +0800 Subject: [PATCH 086/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 743d94f96f..e9e1da977c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType + [NEW] Android & iOS screen size change support [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From 677cf0035553e06606ad4799022cda19f92b328c Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 11 Nov 2013 15:29:24 +0800 Subject: [PATCH 087/185] fix compiler warning --- .../editor-support/cocostudio/CCArmature.cpp | 2 +- cocos/editor-support/cocostudio/CCBone.cpp | 19 +++++++++++-------- cocos/editor-support/cocostudio/CCBone.h | 6 ++++-- .../cocostudio/CCDisplayManager.cpp | 10 +++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 0e19914954..b09922ff70 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -289,7 +289,7 @@ void Armature::removeBone(Bone *bone, bool recursion) CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); - bone->removeFromParent(); + bone->removeFromParent(recursion); if (_topBoneList->containsObject(bone)) { diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 17541e2e78..cbd4544120 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -322,16 +322,19 @@ void Bone::addChildBone(Bone *child) } } -void Bone::removeChildBone(Bone *bone) +void Bone::removeChildBone(Bone *bone, bool recursion) { if (_children && _children->getIndexOfObject(bone) != UINT_MAX ) { - Array *ccbones = bone->_children; - - for(auto object : *ccbones) + if(recursion) { - Bone *ccBone = (Bone *)object; - bone->removeChildBone(ccBone); + Array *ccbones = bone->_children; + + for(auto object : *ccbones) + { + Bone *ccBone = (Bone *)object; + bone->removeChildBone(ccBone, recursion); + } } bone->setParentBone(nullptr); @@ -342,11 +345,11 @@ void Bone::removeChildBone(Bone *bone) } } -void Bone::removeFromParent() +void Bone::removeFromParent(bool recursion) { if (nullptr != _parentBone) { - _parentBone->removeChildBone(this); + _parentBone->removeChildBone(this, recursion); } } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 17dc334c34..8a603c1ad3 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -112,16 +112,18 @@ public: */ Bone *getParentBone(); + using Node::removeFromParent; /** * Remove itself from its parent. + * @param recursion whether or not to remove childBone's display */ - void removeFromParent(); + void removeFromParent(bool recursion); /** * Removes a child Bone * @param bone the bone you want to remove */ - void removeChildBone(Bone *bone); + void removeChildBone(Bone *bone, bool recursion); void update(float delta) override; diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index 6bcf7eaff3..3c502f2fe7 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -146,13 +146,13 @@ void DisplayManager::addDisplay(Node *display, int index) for (int i = _decoDisplayList->count()-2; i>=0; i--) { - DecorativeDisplay *dd = static_cast(_decoDisplayList->objectAtIndex(i)); - SpriteDisplayData *spriteDisplayData = static_cast(dd->getDisplayData()); - if (spriteDisplayData) + DecorativeDisplay *dd = static_cast(_decoDisplayList->getObjectAtIndex(i)); + SpriteDisplayData *sdd = static_cast(dd->getDisplayData()); + if (sdd) { find = true; - skin->setSkinData(spriteDisplayData->skinData); - static_cast(displayData)->skinData = spriteDisplayData->skinData; + skin->setSkinData(sdd->skinData); + static_cast(displayData)->skinData = sdd->skinData; break; } } From 3fc16256ab2869eeb02e65b4684c629798e026d3 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 11 Nov 2013 15:40:12 +0800 Subject: [PATCH 088/185] issue #3025: move deprecated texture cache implementation to cpp file --- cocos/2d/CCTextureCache.cpp | 10 ++++++++++ cocos/2d/CCTextureCache.h | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 780e0330aa..c4276757c6 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -79,6 +79,16 @@ void TextureCache::destroyInstance() { } +TextureCache * TextureCache::sharedTextureCache() +{ + return TextureCache::getInstance(); +} + +void TextureCache::purgeSharedTextureCache() +{ + return TextureCache::destroyInstance(); +} + const char* TextureCache::description() const { return String::createWithFormat("", _textures.size() )->getCString(); diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index c4c14bad53..eb6ca47a22 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -50,6 +50,10 @@ NS_CC_BEGIN * @addtogroup textures * @{ */ +/* +* from version 3.0, TextureCache will never to treated as a singleton, it will be owned by director. +* all call by TextureCache::getInstance() should be replaced by Director::getInstance()->getTextureCache() +*/ /** @brief Singleton that handles the loading of textures * Once the texture is loaded, the next time it will return @@ -62,7 +66,7 @@ public: CC_DEPRECATED_ATTRIBUTE static TextureCache * getInstance(); /** @deprecated Use getInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static TextureCache * sharedTextureCache() { return TextureCache::getInstance(); } + CC_DEPRECATED_ATTRIBUTE static TextureCache * sharedTextureCache(); /** purges the cache. It releases the retained instance. @since v0.99.0 @@ -70,7 +74,7 @@ public: CC_DEPRECATED_ATTRIBUTE static void destroyInstance(); /** @deprecated Use destroyInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache() { return TextureCache::destroyInstance(); } + CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache(); /** Reload all textures should not call it, called by frame work From 891ddb5018a99730eb34ac2a1785a2cdbf3465ef Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Mon, 11 Nov 2013 15:45:07 +0800 Subject: [PATCH 089/185] Fix a bug:we can use 'Custom Class' in CocosBuilder, and assign custom properties to it, but when you create some nodes with the same custom_class , and they have different custom properties, as they are same class and the share one Loader, so in the loader _customProperties will be wrong. So, I dropped some lines to clear _customProperties before handle an new node. --- cocos/editor-support/cocosbuilder/CCNodeLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 7eba8e9340..9677102a59 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -29,7 +29,11 @@ Dictionary* NodeLoader::getCustomProperties() Node * NodeLoader::loadNode(Node * pParent, CCBReader * ccbReader) { Node * ccNode = this->createNode(pParent, ccbReader); - //this->parseProperties(ccNode, pParent, ccbReader); + //clear _customProperties, ready for load next node. + if (_customProperties != nullptr) + { + _customProperties->removeAllObjects(); + } return ccNode; } From 796c75f834570277d7fc78f3cb1bcb16fe217898 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Nov 2013 15:56:15 +0800 Subject: [PATCH 090/185] [ci skip]change the building commands of linux --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1cfd3a014d..2b1a5fa297 100644 --- a/README.md +++ b/README.md @@ -97,11 +97,12 @@ $ open samples.xcodeproj * For Linux ``` -$ cd cocos2d-x -$ cmake CMakeLists.txt -$ make +$ cd cocos2d-x/build +$ ./make-all-linux-project.sh ``` +You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. + * For Windows Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln` From 272afaa7d9d4cd11df732d63e3cb9f1ecfd7c273 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 15:57:15 +0800 Subject: [PATCH 091/185] Updating Bindings-generator. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 22520b8b34..a943736554 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 22520b8b34bcc73c2adfdf234798908a7dd563b4 +Subproject commit a94373655409f756b33d8a58cc798dcb00be257c From dfcae4ed0d6a1dd8d116c251a204d7c59bfcadec Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 11 Nov 2013 16:04:34 +0800 Subject: [PATCH 092/185] issue #3025: change TextureCache::purgeSharedTextureCache() and TextureCache::sharedTextureCache() to do not call deprecate function anymore --- cocos/2d/CCTextureCache.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index c4276757c6..ab1e0c0eec 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -81,12 +81,11 @@ void TextureCache::destroyInstance() TextureCache * TextureCache::sharedTextureCache() { - return TextureCache::getInstance(); + return Director::getInstance()->getTextureCache(); } void TextureCache::purgeSharedTextureCache() { - return TextureCache::destroyInstance(); } const char* TextureCache::description() const From 2e52dd49050812625d1b9db5972121534276a2c2 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 11 Nov 2013 08:05:15 +0000 Subject: [PATCH 093/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index c46cc8ed45..5788b25003 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit c46cc8ed45556e377715dcca2da91ae037dbc7e4 +Subproject commit 5788b2500339473ecc19acf1c2e43656a2537a6d From 0151ac60ba6cb69f45d8a7d32ac9b7fd58b21c6a Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 15:26:25 +0800 Subject: [PATCH 094/185] =?UTF-8?q?fix=2064bit=20warning.=20unsigned=20int?= =?UTF-8?q?=20(int)=20=E2=80=94>=20long.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/2d/CCActionInterval.cpp | 6 +++--- cocos/2d/CCActionManager.cpp | 2 +- cocos/2d/CCActionManager.h | 2 +- cocos/2d/CCAtlasNode.cpp | 4 ++-- cocos/2d/CCAtlasNode.h | 4 ++-- cocos/2d/CCTextureAtlas.cpp | 28 ++++++++++++++-------------- cocos/2d/CCTextureAtlas.h | 8 ++++---- cocos/2d/CCTextureCache.cpp | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 0fe7e055b9..14c0fec762 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -203,7 +203,7 @@ Sequence* Sequence::create(Array* arrayOfActions) Sequence* pRet = NULL; do { - unsigned int count = arrayOfActions->count(); + long count = arrayOfActions->count(); CC_BREAK_IF(count == 0); FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); @@ -576,7 +576,7 @@ Spawn* Spawn::create(Array *arrayOfActions) Spawn* pRet = NULL; do { - unsigned int count = arrayOfActions->count(); + long count = arrayOfActions->count(); CC_BREAK_IF(count == 0); FiniteTimeAction* prev = static_cast(arrayOfActions->getObjectAtIndex(0)); if (count > 1) @@ -2100,7 +2100,7 @@ void Animate::update(float t) } Array* frames = _animation->getFrames(); - int numberOfFrames = frames->count(); + long numberOfFrames = frames->count(); SpriteFrame *frameToDisplay = NULL; for( int i=_nextFrame; i < numberOfFrames; i++ ) { diff --git a/cocos/2d/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp index 0b258f4a6e..dd2b528bce 100644 --- a/cocos/2d/CCActionManager.cpp +++ b/cocos/2d/CCActionManager.cpp @@ -327,7 +327,7 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const // XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer // and, it is not possible to get the address of a reference -unsigned int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const +long ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const { tHashElement *element = NULL; HASH_FIND_PTR(_targets, &target, element); diff --git a/cocos/2d/CCActionManager.h b/cocos/2d/CCActionManager.h index 9e21a77125..8a2c077511 100644 --- a/cocos/2d/CCActionManager.h +++ b/cocos/2d/CCActionManager.h @@ -102,7 +102,7 @@ public: * - If you are running 1 Sequence of 7 actions, it will return 1. * - If you are running 7 Sequences of 2 actions, it will return 7. */ - unsigned int getNumberOfRunningActionsInTarget(const Object *target) const; + long getNumberOfRunningActionsInTarget(const Object *target) const; /** @deprecated use getNumberOfRunningActionsInTarget() instead */ CC_DEPRECATED_ATTRIBUTE inline unsigned int numberOfRunningActionsInTarget(Object *target) const { return getNumberOfRunningActionsInTarget(target); } diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index 7ced2ffc9d..b756a36193 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -245,12 +245,12 @@ TextureAtlas * AtlasNode::getTextureAtlas() const return _textureAtlas; } -unsigned int AtlasNode::getQuadsToDraw() const +long AtlasNode::getQuadsToDraw() const { return _quadsToDraw; } -void AtlasNode::setQuadsToDraw(unsigned int uQuadsToDraw) +void AtlasNode::setQuadsToDraw(long uQuadsToDraw) { _quadsToDraw = uQuadsToDraw; } diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index 9f06456589..8c31496d41 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -77,8 +77,8 @@ public: void setTextureAtlas(TextureAtlas* textureAtlas); TextureAtlas* getTextureAtlas() const; - void setQuadsToDraw(unsigned int quadsToDraw); - unsigned int getQuadsToDraw() const; + void setQuadsToDraw(long quadsToDraw); + long getQuadsToDraw() const; // Overrides diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index f19a2f5f87..efb944db25 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -72,12 +72,12 @@ TextureAtlas::~TextureAtlas() #endif } -int TextureAtlas::getTotalQuads() const +long TextureAtlas::getTotalQuads() const { return _totalQuads; } -int TextureAtlas::getCapacity() const +long TextureAtlas::getCapacity() const { return _capacity; } @@ -216,7 +216,7 @@ void TextureAtlas::listenBackToForeground(Object *obj) const char* TextureAtlas::description() const { - return String::createWithFormat("", _totalQuads)->getCString(); + return String::createWithFormat("", _totalQuads)->getCString(); } @@ -357,7 +357,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount) CCASSERT( _totalQuads <= _capacity, "invalid totalQuads"); // issue #575. index can be > totalQuads - int remaining = (_totalQuads-1) - index - amount; + long remaining = (_totalQuads-1) - index - amount; // last object doesn't need to be moved if( remaining > 0) @@ -367,9 +367,9 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount) } - int max = index + amount; + long max = index + amount; int j = 0; - for (int i = index; i < max ; i++) + for (long i = index; i < max ; i++) { _quads[index] = quads[j]; index++; @@ -390,9 +390,9 @@ void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex) } // because it is ambiguous in iphone, so we implement abs ourselves // unsigned int howMany = abs( oldIndex - newIndex); - int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); - int dst = oldIndex; - int src = oldIndex + 1; + long howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); + long dst = oldIndex; + long src = oldIndex + 1; if( oldIndex > newIndex) { dst = newIndex+1; @@ -412,7 +412,7 @@ void TextureAtlas::removeQuadAtIndex(long index) { CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index"); - int remaining = (_totalQuads-1) - index; + long remaining = (_totalQuads-1) - index; // last object doesn't need to be moved if( remaining ) @@ -431,7 +431,7 @@ void TextureAtlas::removeQuadsAtIndex(long index, long amount) { CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds"); - int remaining = (_totalQuads) - (index + amount); + long remaining = (_totalQuads) - (index + amount); _totalQuads -= amount; @@ -456,7 +456,7 @@ bool TextureAtlas::resizeCapacity(long newCapacity) { return true; } - int oldCapactiy = _capacity; + long oldCapactiy = _capacity; // update capacity and totolQuads _totalQuads = MIN(_totalQuads, newCapacity); _capacity = newCapacity; @@ -575,8 +575,8 @@ void TextureAtlas::fillWithEmptyQuadsFromIndex(long index, long amount) V3F_C4B_T2F_Quad quad; memset(&quad, 0, sizeof(quad)); - int to = index + amount; - for (int i = index ; i < to ; i++) + long to = index + amount; + for (long i = index ; i < to ; i++) { _quads[i] = quad; } diff --git a/cocos/2d/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h index 1e5ec742d7..42922ee80b 100644 --- a/cocos/2d/CCTextureAtlas.h +++ b/cocos/2d/CCTextureAtlas.h @@ -197,10 +197,10 @@ public: const char* description() const; /** Gets the quantity of quads that are going to be drawn */ - int getTotalQuads() const; + long getTotalQuads() const; /** Gets the quantity of quads that can be stored with the current texture atlas size */ - int getCapacity() const; + long getCapacity() const; /** Gets the texture of the texture atlas */ Texture2D* getTexture() const; @@ -231,9 +231,9 @@ protected: GLuint _buffersVBO[2]; //0: vertex 1: indices bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated /** quantity of quads that are going to be drawn */ - int _totalQuads; + long _totalQuads; /** quantity of quads that can be stored with the current texture atlas size */ - int _capacity; + long _capacity; /** Texture of the texture atlas */ Texture2D* _texture; /** Quads that are going to be rendered */ diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 780e0330aa..17aa00effb 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -441,7 +441,7 @@ void TextureCache::dumpCachedTextureInfo() const Texture2D* tex = it->second; unsigned int bpp = tex->getBitsPerPixelForFormat(); // Each texture takes up width * height * bytesPerPixel bytes. - unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; + long bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; totalBytes += bytes; count++; log("cocos2d: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB", From 20b350a58b00d29f1c91999a28aea819885da2df Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 15:27:58 +0800 Subject: [PATCH 095/185] Removing cocosjs_manual_conversions.h(.cpp). Put all jsval <-> native value conversion codes to js_manual_conversions.h(.cpp). --- .../project.pbxproj.REMOVED.git-id | 2 +- .../scripting/javascript/bindings/Android.mk | 1 - .../javascript/bindings/ScriptingCore.cpp | 1037 -------------- .../javascript/bindings/ScriptingCore.h | 40 +- ...s_chipmunk_auto_classes.cpp.REMOVED.git-id | 2 +- ...ings_chipmunk_functions.cpp.REMOVED.git-id | 2 +- .../chipmunk/js_bindings_chipmunk_manual.h | 1 - .../bindings/cocosjs_manual_conversions.cpp | 134 -- .../bindings/cocosjs_manual_conversions.h | 24 - .../bindings/js_manual_conversions.cpp | 1227 ++++++++++++++++- .../bindings/js_manual_conversions.h | 69 +- .../bindings/jsb_opengl_functions.cpp | 515 ++++--- .../javascript/bindings/jsb_opengl_manual.cpp | 1 - .../bindings/proj.win32/libJSBinding.vcxproj | 2 - .../proj.win32/libJSBinding.vcxproj.filters | 6 - 15 files changed, 1470 insertions(+), 1593 deletions(-) delete mode 100644 cocos/scripting/javascript/bindings/cocosjs_manual_conversions.cpp delete mode 100644 cocos/scripting/javascript/bindings/cocosjs_manual_conversions.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 1ebbc707a8..5639c9df83 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -30ca6c02884f9bc20405b3e657b444c0153bead7 \ No newline at end of file +a70914e0a87ee8ced4d662bd6038fc955e77f6ca \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/Android.mk b/cocos/scripting/javascript/bindings/Android.mk index 8195fde121..ffb0167ce1 100644 --- a/cocos/scripting/javascript/bindings/Android.mk +++ b/cocos/scripting/javascript/bindings/Android.mk @@ -9,7 +9,6 @@ LOCAL_MODULE_FILENAME := libcocos2dxjsb LOCAL_SRC_FILES := ScriptingCore.cpp \ cocos2d_specifics.cpp \ js_manual_conversions.cpp \ - cocosjs_manual_conversions.cpp \ js_bindings_core.cpp \ js_bindings_opengl.cpp \ jsb_opengl_functions.cpp \ diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 462debba9d..86ddb4bd2e 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -1159,803 +1159,6 @@ int ScriptingCore::sendEvent(ScriptEvent* evt) return 0; } -#pragma mark - Conversion Routines -JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval ) -{ - JSBool ok = JS_TRUE; - double dp; - ok &= JS_ValueToNumber(cx, vp, &dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - ok &= !isnan(dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - *outval = (int32_t)dp; - - return ok; -} - -JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval ) -{ - JSBool ok = JS_TRUE; - double dp; - ok &= JS_ValueToNumber(cx, vp, &dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - ok &= !isnan(dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - *outval = (uint32_t)dp; - - return ok; -} - -JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval ) -{ - JSBool ok = JS_TRUE; - double dp; - ok &= JS_ValueToNumber(cx, vp, &dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - ok &= !isnan(dp); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - *outval = (uint16_t)dp; - - return ok; -} - -JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) { - JSObject *tmp_arg; - JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg ); - JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); - JSB_PRECONDITION3( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object"); - JSB_PRECONDITION3( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length"); - - uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); - long long ret = arg_array[0]; - ret = ret << 32; - ret |= arg_array[1]; - - *r = ret; - return JS_TRUE; -} - -JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret) { - JSString *tmp = JS_ValueToString(cx, v); - JSB_PRECONDITION3(tmp, cx, JS_FALSE, "Error processing arguments"); - - JSStringWrapper str(tmp); - *ret = str.get(); - return JS_TRUE; -} - -JSBool jsval_to_ccpoint(JSContext *cx, jsval v, Point* ret) { - JSObject *tmp; - JS::RootedValue jsx(cx); - JS::RootedValue jsy(cx); - double x, y; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "x", &jsx) && - JS_GetProperty(cx, tmp, "y", &jsy) && - JS_ValueToNumber(cx, jsx, &x) && - JS_ValueToNumber(cx, jsy, &y); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - ret->x = (float)x; - ret->y = (float)y; - return JS_TRUE; -} - -JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, Acceleration* ret) { - JSObject *tmp; - JS::RootedValue jsx(cx); - JS::RootedValue jsy(cx); - JS::RootedValue jsz(cx); - JS::RootedValue jstimestamp(cx); - - double x, y, timestamp, z; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "x", &jsx) && - JS_GetProperty(cx, tmp, "y", &jsy) && - JS_GetProperty(cx, tmp, "z", &jsz) && - JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) && - JS_ValueToNumber(cx, jsx, &x) && - JS_ValueToNumber(cx, jsy, &y) && - JS_ValueToNumber(cx, jsz, &z) && - JS_ValueToNumber(cx, jstimestamp, ×tamp); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - ret->x = x; - ret->y = y; - ret->z = z; - ret->timestamp = timestamp; - return JS_TRUE; -} - -JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** ret) -{ - JSBool ok = JS_TRUE; - Array* pArray = Array::create(); - for( int i=0; i < argc; i++ ) - { - double num = 0.0; - // optimization: JS_ValueToNumber is expensive. And can convert an string like "12" to a number - if ( JSVAL_IS_NUMBER(*vp)) { - ok &= JS_ValueToNumber(cx, *vp, &num ); - if (!ok) { - break; - } - pArray->addObject(Integer::create((int)num)); - } - else if (JSVAL_IS_STRING(*vp)) - { - JSStringWrapper str(JSVAL_TO_STRING(*vp), cx); - pArray->addObject(String::create(str.get())); - } - else - { - js_proxy_t* p; - JSObject* obj = JSVAL_TO_OBJECT(*vp); - p = jsb_get_js_proxy(obj); - if (p) { - pArray->addObject((Object*)p->ptr); - } - } - // next - vp++; - } - *ret = pArray; - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - return ok; -} - -JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret) { - JSObject *tmp; - JS::RootedValue jsx(cx); - JS::RootedValue jsy(cx); - JS::RootedValue jswidth(cx); - JS::RootedValue jsheight(cx); - - double x, y, width, height; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "x", &jsx) && - JS_GetProperty(cx, tmp, "y", &jsy) && - JS_GetProperty(cx, tmp, "width", &jswidth) && - JS_GetProperty(cx, tmp, "height", &jsheight) && - JS_ValueToNumber(cx, jsx, &x) && - JS_ValueToNumber(cx, jsy, &y) && - JS_ValueToNumber(cx, jswidth, &width) && - JS_ValueToNumber(cx, jsheight, &height); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - ret->origin.x = x; - ret->origin.y = y; - ret->size.width = width; - ret->size.height = height; - return JS_TRUE; -} - -JSBool jsval_to_ccsize(JSContext *cx, jsval v, Size* ret) { - JSObject *tmp; - JS::RootedValue jsw(cx); - JS::RootedValue jsh(cx); - double w, h; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "width", &jsw) && - JS_GetProperty(cx, tmp, "height", &jsh) && - JS_ValueToNumber(cx, jsw, &w) && - JS_ValueToNumber(cx, jsh, &h); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - ret->width = w; - ret->height = h; - return JS_TRUE; -} - -JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret) { - JSObject *tmp; - JS::RootedValue jsr(cx); - JS::RootedValue jsg(cx); - JS::RootedValue jsb(cx); - JS::RootedValue jsa(cx); - - double r, g, b, a; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "r", &jsr) && - JS_GetProperty(cx, tmp, "g", &jsg) && - JS_GetProperty(cx, tmp, "b", &jsb) && - JS_GetProperty(cx, tmp, "a", &jsa) && - JS_ValueToNumber(cx, jsr, &r) && - JS_ValueToNumber(cx, jsg, &g) && - JS_ValueToNumber(cx, jsb, &b) && - JS_ValueToNumber(cx, jsa, &a); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - ret->r = r; - ret->g = g; - ret->b = b; - ret->a = a; - return JS_TRUE; -} - -JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret) { - JSObject *tmp; - JS::RootedValue jsr(cx); - JS::RootedValue jsg(cx); - JS::RootedValue jsb(cx); - JS::RootedValue jsa(cx); - double r, g, b, a; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "r", &jsr) && - JS_GetProperty(cx, tmp, "g", &jsg) && - JS_GetProperty(cx, tmp, "b", &jsb) && - JS_GetProperty(cx, tmp, "a", &jsa) && - JS_ValueToNumber(cx, jsr, &r) && - JS_ValueToNumber(cx, jsg, &g) && - JS_ValueToNumber(cx, jsb, &b) && - JS_ValueToNumber(cx, jsa, &a); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - ret->r = r; - ret->g = g; - ret->b = b; - ret->a = a; - return JS_TRUE; -} - -JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) { - JSObject *tmp; - JS::RootedValue jsr(cx); - JS::RootedValue jsg(cx); - JS::RootedValue jsb(cx); - double r, g, b; - JSBool ok = v.isObject() && - JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "r", &jsr) && - JS_GetProperty(cx, tmp, "g", &jsg) && - JS_GetProperty(cx, tmp, "b", &jsb) && - JS_ValueToNumber(cx, jsr, &r) && - JS_ValueToNumber(cx, jsg, &g) && - JS_ValueToNumber(cx, jsb, &b); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - ret->r = r; - ret->g = g; - ret->b = b; - return JS_TRUE; -} - -JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *numPoints) { - // Parsing sequence - JSObject *jsobj; - JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); - JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); - JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); - - uint32_t len; - JS_GetArrayLength(cx, jsobj, &len); - - Point *array = (Point*)malloc( sizeof(Point) * len); - - for( uint32_t i=0; i< len;i++ ) { - jsval valarg; - JS_GetElement(cx, jsobj, i, &valarg); - - ok = jsval_to_ccpoint(cx, valarg, &array[i]); - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - } - - *numPoints = len; - *points = array; - - return JS_TRUE; -} - - -JSBool jsval_to_ccarray(JSContext* cx, jsval v, Array** ret) { - JSObject *jsobj; - JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); - JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); - JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); - - uint32_t len = 0; - JS_GetArrayLength(cx, jsobj, &len); - Array* arr = Array::createWithCapacity(len); - for (uint32_t i=0; i < len; i++) { - jsval value; - if (JS_GetElement(cx, jsobj, i, &value)) { - if (value.isObject()) - { - js_proxy_t *proxy; - JSObject *tmp = JSVAL_TO_OBJECT(value); - proxy = jsb_get_js_proxy(tmp); - cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); - // Don't test it. - //TEST_NATIVE_OBJECT(cx, cobj) - if (cobj) { - // It's a native js object. - arr->addObject(cobj); - } - else if (!JS_IsArrayObject(cx, tmp)){ - // It's a normal js object. - Dictionary* dictVal = NULL; - JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); - if (ok) { - arr->addObject(dictVal); - } - } - else { - // It's a js array object. - Array* arrVal = NULL; - JSBool ok = jsval_to_ccarray(cx, value, &arrVal); - if (ok) { - arr->addObject(arrVal); - } - } - } - else if (JSVAL_IS_STRING(value)) { - JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); - arr->addObject(String::create(valueWapper.get())); -// CCLOG("iterate array: value = %s", valueWapper.get().c_str()); - } - else if (JSVAL_IS_NUMBER(value)) { - double number = 0.0; - JSBool ok = JS_ValueToNumber(cx, value, &number); - if (ok) { - arr->addObject(Double::create(number)); -// CCLOG("iterate array: value = %lf", number); - } - } - else if (JSVAL_IS_BOOLEAN(value)) { - JSBool boolVal = JS_FALSE; - JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); - if (ok) { - arr->addObject(Bool::create(boolVal)); -// CCLOG("iterate object: value = %d", boolVal); - } - } - else { - CCASSERT(false, "not supported type"); - } - } - } - *ret = arr; - return JS_TRUE; -} - - -jsval ccarray_to_jsval(JSContext* cx, Array *arr) -{ - JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); - - Object* obj; - int i = 0; - CCARRAY_FOREACH(arr, obj) - { - jsval arrElement; - - //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); - if (jsproxy) { - arrElement = OBJECT_TO_JSVAL(jsproxy->obj); - } - else { - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; - - if ((strVal = dynamic_cast(obj))) { - arrElement = c_string_to_jsval(cx, strVal->getCString()); - } else if ((dictVal = dynamic_cast(obj))) { - arrElement = ccdictionary_to_jsval(cx, dictVal); - } else if ((arrVal = dynamic_cast(obj))) { - arrElement = ccarray_to_jsval(cx, arrVal); - } else if ((doubleVal = dynamic_cast(obj))) { - arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); - } else if ((floatVal = dynamic_cast(obj))) { - arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); - } else if ((intVal = dynamic_cast(obj))) { - arrElement = INT_TO_JSVAL(intVal->getValue()); - } else if ((boolVal = dynamic_cast(obj))) { - arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); - } else { - CCASSERT(false, "the type isn't suppored."); - } - } - if (!JS_SetElement(cx, jsretArr, i, &arrElement)) { - break; - } - ++i; - } - return OBJECT_TO_JSVAL(jsretArr); -} - -jsval ccdictionary_to_jsval(JSContext* cx, Dictionary* dict) -{ - JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); - DictElement* pElement = NULL; - CCDICT_FOREACH(dict, pElement) - { - JS::RootedValue dictElement(cx); - Object* obj = pElement->getObject(); - //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); - if (jsproxy) { - dictElement = OBJECT_TO_JSVAL(jsproxy->obj); - } - else { - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; - - if ((strVal = dynamic_cast(obj))) { - dictElement = c_string_to_jsval(cx, strVal->getCString()); - } else if ((dictVal = dynamic_cast(obj))) { - dictElement = ccdictionary_to_jsval(cx, dictVal); - } else if ((arrVal = dynamic_cast(obj))) { - dictElement = ccarray_to_jsval(cx, arrVal); - } else if ((doubleVal = dynamic_cast(obj))) { - dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); - } else if ((floatVal = dynamic_cast(obj))) { - dictElement = DOUBLE_TO_JSVAL(floatVal->getValue()); - } else if ((intVal = dynamic_cast(obj))) { - dictElement = INT_TO_JSVAL(intVal->getValue()); - } else if ((boolVal = dynamic_cast(obj))) { - dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); - } else { - CCASSERT(false, "the type isn't suppored."); - } - } - const char* key = pElement->getStrKey(); - if (key && strlen(key) > 0) - { - JS_SetProperty(cx, jsRet, key, dictElement); - } - } - return OBJECT_TO_JSVAL(jsRet); -} - -JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) { - - if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) - { - *ret = NULL; - return JS_TRUE; - } - - JSObject* tmp = JSVAL_TO_OBJECT(v); - if (!tmp) { - LOGD("jsval_to_ccdictionary: the jsval is not an object."); - return JS_FALSE; - } - - JSObject* it = JS_NewPropertyIterator(cx, tmp); - Dictionary* dict = NULL; - - while (true) - { - jsid idp; - jsval key; - if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { - return JS_FALSE; // error - } - - if (key == JSVAL_VOID) { - break; // end of iteration - } - - if (!JSVAL_IS_STRING(key)) { - continue; // ignore integer properties - } - - JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); - if (!dict) { - dict = Dictionary::create(); - } - - JS::RootedValue value(cx); - JS_GetPropertyById(cx, tmp, idp, &value); - if (value.isObject()) - { - js_proxy_t *proxy; - JSObject *tmp = JSVAL_TO_OBJECT(value); - proxy = jsb_get_js_proxy(tmp); - cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); - // Don't test it. - //TEST_NATIVE_OBJECT(cx, cobj) - if (cobj) { - // It's a native <-> js glue object. - dict->setObject(cobj, keyWrapper.get()); - } - else if (!JS_IsArrayObject(cx, tmp)){ - // It's a normal js object. - Dictionary* dictVal = NULL; - JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); - if (ok) { - dict->setObject(dictVal, keyWrapper.get()); - } - } - else { - // It's a js array object. - Array* arrVal = NULL; - JSBool ok = jsval_to_ccarray(cx, value, &arrVal); - if (ok) { - dict->setObject(arrVal, keyWrapper.get()); - } - } - } - else if (JSVAL_IS_STRING(value)) { - JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); - dict->setObject(String::create(valueWapper.get()), keyWrapper.get()); -// CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); - } - else if (JSVAL_IS_NUMBER(value)) { - double number = 0.0; - JSBool ok = JS_ValueToNumber(cx, value, &number); - if (ok) { - dict->setObject(Double::create(number), keyWrapper.get()); -// CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); - } - } - else if (JSVAL_IS_BOOLEAN(value)) { - JSBool boolVal = JS_FALSE; - JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); - if (ok) { - dict->setObject(Bool::create(boolVal), keyWrapper.get()); -// CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); - } - } - else { - CCASSERT(false, "not supported type"); - } - } - - *ret = dict; - return JS_TRUE; -} - -JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, AffineTransform* ret) -{ - JSObject *tmp; - JS::RootedValue jsa(cx); - JS::RootedValue jsb(cx); - JS::RootedValue jsc(cx); - JS::RootedValue jsd(cx); - JS::RootedValue jstx(cx); - JS::RootedValue jsty(cx); - double a, b, c, d, tx, ty; - JSBool ok = JS_ValueToObject(cx, v, &tmp) && - JS_GetProperty(cx, tmp, "a", &jsa) && - JS_GetProperty(cx, tmp, "b", &jsb) && - JS_GetProperty(cx, tmp, "c", &jsc) && - JS_GetProperty(cx, tmp, "d", &jsd) && - JS_GetProperty(cx, tmp, "tx", &jstx) && - JS_GetProperty(cx, tmp, "ty", &jsty) && - JS_ValueToNumber(cx, jsa, &a) && - JS_ValueToNumber(cx, jsb, &b) && - JS_ValueToNumber(cx, jsc, &c) && - JS_ValueToNumber(cx, jsd, &d) && - JS_ValueToNumber(cx, jstx, &tx) && - JS_ValueToNumber(cx, jsty, &ty); - - JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); - - *ret = AffineTransformMake(a, b, c, d, tx, ty); - return JS_TRUE; -} - -// From native type to jsval -jsval int32_to_jsval( JSContext *cx, int32_t number ) -{ - return INT_TO_JSVAL(number); -} - -jsval uint32_to_jsval( JSContext *cx, uint32_t number ) -{ - return UINT_TO_JSVAL(number); -} - -jsval long_long_to_jsval(JSContext* cx, long long v) { - JSObject *tmp = JS_NewUint32Array(cx, 2); - uint32_t *data = (uint32_t *)JS_GetArrayBufferViewData(tmp); - data[0] = ((uint32_t *)(&v))[0]; - data[1] = ((uint32_t *)(&v))[1]; - return OBJECT_TO_JSVAL(tmp); -} - -jsval std_string_to_jsval(JSContext* cx, const std::string& v) -{ - return c_string_to_jsval(cx, v.c_str(), v.size()); -} - -jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) -{ - if (v == NULL) - { - return JSVAL_NULL; - } - - JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - - if (0 == length) - { - auto emptyStr = JS_NewStringCopyZ(cx, ""); - return STRING_TO_JSVAL(emptyStr); - } - - jsval ret = JSVAL_NULL; - int utf16_size = 0; - jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, length, &utf16_size); - - if (strUTF16 && utf16_size > 0) { - JSString* str = JS_NewUCStringCopyN(cx, strUTF16, utf16_size); - if (str) { - ret = STRING_TO_JSVAL(str); - } - delete[] strUTF16; - } - return ret; -} - -jsval ccpoint_to_jsval(JSContext* cx, const Point& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval ccacceleration_to_jsval(JSContext* cx, const Acceleration& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(v.z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "timestamp", DOUBLE_TO_JSVAL(v.timestamp), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval ccrect_to_jsval(JSContext* cx, const Rect& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.origin.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.origin.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.size.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.size.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval ccsize_to_jsval(JSContext* cx, const Size& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "r", DOUBLE_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "g", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) { - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval ccaffinetransform_to_jsval(JSContext* cx, const AffineTransform& t) -{ - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(t.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(t.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "c", DOUBLE_TO_JSVAL(t.c), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "d", DOUBLE_TO_JSVAL(t.d), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "tx", DOUBLE_TO_JSVAL(t.tx), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "ty", DOUBLE_TO_JSVAL(t.ty), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - -jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) -{ - JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); - if (!tmp) return JSVAL_NULL; - JSBool ok = JS_TRUE; - - ok &= JS_DefineProperty(cx, tmp, "fontName", std_string_to_jsval(cx, t._fontName), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fontSize", int32_to_jsval(cx, t._fontSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fontAlignmentH", int32_to_jsval(cx, (int32_t)t._alignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fontAlignmentV", int32_to_jsval(cx, (int32_t)t._vertAlignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fontFillColor", cccolor3b_to_jsval(cx, t._fontFillColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "fontDimensions", ccsize_to_jsval(cx, t._dimensions), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - // Shadow - ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "shadowOffset", ccsize_to_jsval(cx, t._shadow._shadowOffset), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "shadowBlur", DOUBLE_TO_JSVAL(t._shadow._shadowBlur), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", DOUBLE_TO_JSVAL(t._shadow._shadowOpacity), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - // Stroke - ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "strokeColor", cccolor3b_to_jsval(cx, t._stroke._strokeColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - ok &= JS_DefineProperty(cx, tmp, "strokeSize", DOUBLE_TO_JSVAL(t._stroke._strokeSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - - if (ok) { - return OBJECT_TO_JSVAL(tmp); - } - return JSVAL_NULL; -} - #pragma mark - Debug void SimpleRunLoop::update(float dt) @@ -2297,246 +1500,6 @@ void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) JS_REMOVE_PROXY(nativeProxy, jsProxy); } -static Color3B getColorFromJSObject(JSContext *cx, JSObject *colorObject) -{ - JS::RootedValue jsr(cx); - Color3B out; - JS_GetProperty(cx, colorObject, "r", &jsr); - double fontR = 0.0; - JS_ValueToNumber(cx, jsr, &fontR); - - JS_GetProperty(cx, colorObject, "g", &jsr); - double fontG = 0.0; - JS_ValueToNumber(cx, jsr, &fontG); - - JS_GetProperty(cx, colorObject, "b", &jsr); - double fontB = 0.0; - JS_ValueToNumber(cx, jsr, &fontB); - - // the out - out.r = (unsigned char)fontR; - out.g = (unsigned char)fontG; - out.b = (unsigned char)fontB; - - return out; -} - -Size getSizeFromJSObject(JSContext *cx, JSObject *sizeObject) -{ - JS::RootedValue jsr(cx); - Size out; - JS_GetProperty(cx, sizeObject, "width", &jsr); - double width = 0.0; - JS_ValueToNumber(cx, jsr, &width); - - JS_GetProperty(cx, sizeObject, "height", &jsr); - double height = 0.0; - JS_ValueToNumber(cx, jsr, &height); - - - // the out - out.width = width; - out.height = height; - - return out; -} - -JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) -{ - JSObject *jsobj; - - if (!JS_ValueToObject( cx, vp, &jsobj ) ) - return JS_FALSE; - - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - // defaul values - const char * defautlFontName = "Arial"; - const int defaultFontSize = 32; - TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; - TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; - - // by default shadow and stroke are off - out->_shadow._shadowEnabled = false; - out->_stroke._strokeEnabled = false; - - // white text by default - out->_fontFillColor = Color3B::WHITE; - - // font name - JS::RootedValue jsr(cx); - JS_GetProperty(cx, jsobj, "fontName", &jsr); - JS_ValueToString(cx, jsr); - JSStringWrapper wrapper(jsr); - const char* fontName = wrapper.get(); - - if (fontName && strlen(fontName) > 0) - { - out->_fontName = fontName; - } - else - { - out->_fontName = defautlFontName; - } - - // font size - JSBool hasProperty; - JS_HasProperty(cx, jsobj, "fontSize", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "fontSize", &jsr); - double fontSize = 0.0; - JS_ValueToNumber(cx, jsr, &fontSize); - out->_fontSize = fontSize; - } - else - { - out->_fontSize = defaultFontSize; - } - - // font alignment horizontal - JS_HasProperty(cx, jsobj, "fontAlignmentH", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr); - double fontAlign = 0.0; - JS_ValueToNumber(cx, jsr, &fontAlign); - out->_alignment = (TextHAlignment)(int)fontAlign; - } - else - { - out->_alignment = defaultTextAlignment; - } - - // font alignment vertical - JS_HasProperty(cx, jsobj, "fontAlignmentV", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr); - double fontAlign = 0.0; - JS_ValueToNumber(cx, jsr, &fontAlign); - out->_vertAlignment = (TextVAlignment)(int)fontAlign; - } - else - { - out->_vertAlignment = defaultTextVAlignment; - } - - // font fill color - JS_HasProperty(cx, jsobj, "fontFillColor", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "fontFillColor", &jsr); - - JSObject *jsobjColor; - if (!JS_ValueToObject( cx, jsr, &jsobjColor ) ) - return JS_FALSE; - - out->_fontFillColor = getColorFromJSObject(cx, jsobjColor); - } - - // font rendering box dimensions - JS_HasProperty(cx, jsobj, "fontDimensions", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "fontDimensions", &jsr); - - JSObject *jsobjSize; - if (!JS_ValueToObject( cx, jsr, &jsobjSize ) ) - return JS_FALSE; - - out->_dimensions = getSizeFromJSObject(cx, jsobjSize); - } - - // shadow - JS_HasProperty(cx, jsobj, "shadowEnabled", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "shadowEnabled", &jsr); - out->_shadow._shadowEnabled = ToBoolean(jsr); - - if ( out->_shadow._shadowEnabled ) - { - // default shadow values - out->_shadow._shadowOffset = Size(5, 5); - out->_shadow._shadowBlur = 1; - out->_shadow._shadowOpacity = 1; - - // shado offset - JS_HasProperty(cx, jsobj, "shadowOffset", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "shadowOffset", &jsr); - - JSObject *jsobjShadowOffset; - if (!JS_ValueToObject( cx, jsr, &jsobjShadowOffset ) ) - return JS_FALSE; - out->_shadow._shadowOffset = getSizeFromJSObject(cx, jsobjShadowOffset); - } - - // shadow blur - JS_HasProperty(cx, jsobj, "shadowBlur", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "shadowBlur", &jsr); - double shadowBlur = 0.0; - JS_ValueToNumber(cx, jsr, &shadowBlur); - out->_shadow._shadowBlur = shadowBlur; - } - - // shadow intensity - JS_HasProperty(cx, jsobj, "shadowOpacity", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "shadowOpacity", &jsr); - double shadowOpacity = 0.0; - JS_ValueToNumber(cx, jsr, &shadowOpacity); - out->_shadow._shadowOpacity = shadowOpacity; - } - } - } - - // stroke - JS_HasProperty(cx, jsobj, "strokeEnabled", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "strokeEnabled", &jsr); - out->_stroke._strokeEnabled = ToBoolean(jsr); - - if ( out->_stroke._strokeEnabled ) - { - // default stroke values - out->_stroke._strokeSize = 1; - out->_stroke._strokeColor = Color3B::BLUE; - - // stroke color - JS_HasProperty(cx, jsobj, "strokeColor", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "strokeColor", &jsr); - - JSObject *jsobjStrokeColor; - if (!JS_ValueToObject( cx, jsr, &jsobjStrokeColor ) ) - return JS_FALSE; - out->_stroke._strokeColor = getColorFromJSObject(cx, jsobjStrokeColor); - } - - // stroke size - JS_HasProperty(cx, jsobj, "strokeSize", &hasProperty); - if ( hasProperty ) - { - JS_GetProperty(cx, jsobj, "strokeSize", &jsr); - double strokeSize = 0.0; - JS_ValueToNumber(cx, jsr, &strokeSize); - out->_stroke._strokeSize = strokeSize; - } - } - } - - // we are done here - return JS_TRUE; -} - // JSStringWrapper JSStringWrapper::JSStringWrapper() : _buffer(nullptr) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.h b/cocos/scripting/javascript/bindings/ScriptingCore.h index 7f0e367d92..b0c6c45acb 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.h +++ b/cocos/scripting/javascript/bindings/ScriptingCore.h @@ -17,6 +17,7 @@ #include "jsapi.h" #include "jsfriendapi.h" #include "spidermonkey_specifics.h" +#include "js_manual_conversions.h" void js_log(const char *format, ...); @@ -204,45 +205,6 @@ public: int handleKeypadEvent(void* data); }; -// some utility functions -// to native -JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret ); -JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); -JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); -JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret); -JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret); -JSBool jsval_to_ccpoint(JSContext *cx, jsval v, Point* ret); -JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret); -JSBool jsval_to_ccsize(JSContext *cx, jsval v, Size* ret); -JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret); -JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret); -JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret); -JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *numPoints); -JSBool jsval_to_ccarray(JSContext* cx, jsval v, Array** ret); -JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret); -JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, Acceleration* ret); -JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** ret); -JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, AffineTransform* ret); -JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition* ret ); - -// from native -jsval int32_to_jsval( JSContext *cx, int32_t l); -jsval uint32_to_jsval( JSContext *cx, uint32_t number ); -jsval long_long_to_jsval(JSContext* cx, long long v); -jsval std_string_to_jsval(JSContext* cx, const std::string& v); -jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); -jsval ccpoint_to_jsval(JSContext* cx, const Point& v); -jsval ccrect_to_jsval(JSContext* cx, const Rect& v); -jsval ccsize_to_jsval(JSContext* cx, const Size& v); -jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v); -jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v); -jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v); -jsval ccdictionary_to_jsval(JSContext* cx, Dictionary *dict); -jsval ccarray_to_jsval(JSContext* cx, Array *arr); -jsval ccacceleration_to_jsval(JSContext* cx, const Acceleration& v); -jsval ccaffinetransform_to_jsval(JSContext* cx, const AffineTransform& t); -jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t); - JSObject* NewGlobalObject(JSContext* cx, bool debug = false); // just a simple utility to avoid mem leaking when using JSString diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id index c8c345c32c..0e67c34489 100644 --- a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_auto_classes.cpp.REMOVED.git-id @@ -1 +1 @@ -6558be4f421be9227dc4fabf1b682d479825bd18 \ No newline at end of file +2a8f07a22574900290f772ad5a580ef9fc57a9b8 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id index 5cf2a4495d..264696d780 100644 --- a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_functions.cpp.REMOVED.git-id @@ -1 +1 @@ -1c5eb9cd58c82de77374cdfa5c9ff647cc8b2f02 \ No newline at end of file +ac3eca550f3b923d03d042ed63edf3b66cc183b7 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h index c6b40ca757..6807bd63e1 100644 --- a/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h +++ b/cocos/scripting/javascript/bindings/chipmunk/js_bindings_chipmunk_manual.h @@ -27,7 +27,6 @@ #define __js_bindings_chipmunk_manual #include "js_bindings_config.h" -#include "cocosjs_manual_conversions.h" #include "js_manual_conversions.h" #include "ScriptingCore.h" #ifdef JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.cpp b/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.cpp deleted file mode 100644 index 56bd017069..0000000000 --- a/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "jsapi.h" -#include "jsfriendapi.h" -#include "ScriptingCore.h" -#include "js_bindings_config.h" -#include "cocosjs_manual_conversions.h" - -#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - -using namespace cocos2d; - -JSBool jsval_to_CCPoint( JSContext *cx, jsval vp, Point *ret ) -{ -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *jsobj; - if( ! JS_ValueToObject( cx, vp, &jsobj ) ) - return JS_FALSE; - - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - JS::RootedValue valx(cx); - JS::RootedValue valy(cx); - JSBool ok = JS_TRUE; - ok &= JS_GetProperty(cx, jsobj, "x", &valx); - ok &= JS_GetProperty(cx, jsobj, "y", &valy); - - if( ! ok ) - return JS_FALSE; - - double x, y; - ok &= JS_ValueToNumber(cx, valx, &x); - ok &= JS_ValueToNumber(cx, valy, &y); - - if( ! ok ) - return JS_FALSE; - - ret->x = x; - ret->y = y; - - return JS_TRUE; - -#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; - - JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); - - *ret = *(Point*)JS_GetArrayBufferViewData( tmp_arg, cx ); - - return JS_TRUE; -#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} - - -JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *ret ) -{ -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *jsobj; - if( ! JS_ValueToObject( cx, vp, &jsobj ) ) - return JS_FALSE; - - JSB_PRECONDITION( jsobj, "Not a valid JS object"); - - JS::RootedValue valx(cx); - JS::RootedValue valy(cx); - JSBool ok = JS_TRUE; - ok &= JS_GetProperty(cx, jsobj, "x", &valx); - ok &= JS_GetProperty(cx, jsobj, "y", &valy); - - if( ! ok ) - return JS_FALSE; - - double x, y; - ok &= JS_ValueToNumber(cx, valx, &x); - ok &= JS_ValueToNumber(cx, valy, &y); - - if( ! ok ) - return JS_FALSE; - - ret->x = x; - ret->y = y; - - return JS_TRUE; - -#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *tmp_arg; - if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) - return JS_FALSE; - - JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); - - JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); - - *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); - - return JS_TRUE; -#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} - - -jsval CGPoint_to_jsval( JSContext *cx, cpVect p) -{ - -#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - - JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); - if (!object) - return JSVAL_VOID; - - if (!JS_DefineProperty(cx, object, "x", DOUBLE_TO_JSVAL(p.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || - !JS_DefineProperty(cx, object, "y", DOUBLE_TO_JSVAL(p.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) - return JSVAL_VOID; - - return OBJECT_TO_JSVAL(object); - -#else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES - -#ifdef __LP64__ - JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); -#else - JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); -#endif - - cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); - *buffer = p; - return OBJECT_TO_JSVAL(typedArray); -#endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES -} diff --git a/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.h b/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.h deleted file mode 100644 index 339ac7da9c..0000000000 --- a/cocos/scripting/javascript/bindings/cocosjs_manual_conversions.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __COCOSJS_MANUAL_CONVERSIONS_H__ -#define __COCOSJS_MANUAL_CONVERSIONS_H__ - -#include "chipmunk.h" -#include "cocos2d.h" -#include "js_manual_conversions.h" - -//#ifdef __cplusplus -//extern "C" { -//#endif - -JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); -jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); - - -//#ifdef __cplusplus -//} -//#endif - -#define cpVect_to_jsval CGPoint_to_jsval -#define jsval_to_cpVect jsval_to_CGPoint - -#endif /* __COCOSJS_MANUAL_CONVERSIONS_H__ */ - diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index 521d1be2aa..0e3e20b617 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp @@ -8,6 +8,53 @@ #include "ScriptingCore.h" #include "js_bindings_config.h" #include "js_manual_conversions.h" +#include "cocos2d_specifics.hpp" + +USING_NS_CC; + +static Color3B getColorFromJSObject(JSContext *cx, JSObject *colorObject) +{ + JS::RootedValue jsr(cx); + Color3B out; + JS_GetProperty(cx, colorObject, "r", &jsr); + double fontR = 0.0; + JS_ValueToNumber(cx, jsr, &fontR); + + JS_GetProperty(cx, colorObject, "g", &jsr); + double fontG = 0.0; + JS_ValueToNumber(cx, jsr, &fontG); + + JS_GetProperty(cx, colorObject, "b", &jsr); + double fontB = 0.0; + JS_ValueToNumber(cx, jsr, &fontB); + + // the out + out.r = (unsigned char)fontR; + out.g = (unsigned char)fontG; + out.b = (unsigned char)fontB; + + return out; +} + +static Size getSizeFromJSObject(JSContext *cx, JSObject *sizeObject) +{ + JS::RootedValue jsr(cx); + Size out; + JS_GetProperty(cx, sizeObject, "width", &jsr); + double width = 0.0; + JS_ValueToNumber(cx, jsr, &width); + + JS_GetProperty(cx, sizeObject, "height", &jsr); + double height = 0.0; + JS_ValueToNumber(cx, jsr, &height); + + + // the out + out.width = width; + out.height = height; + + return out; +} JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **r) { @@ -74,24 +121,6 @@ JSBool jsval_to_long( JSContext *cx, jsval vp, long *r ) return JS_TRUE; } -JSBool jsval_to_longlong( JSContext *cx, jsval vp, long long *r ) -{ - JSObject *tmp_arg; - JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg ); - JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object"); - JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object"); - JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length"); - - uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); - long long ret = arg_array[0]; - ret = ret << 32; - ret |= arg_array[1]; - - *r = ret; - return JS_TRUE; -} - - jsval opaque_to_jsval( JSContext *cx, void *opaque ) { #ifdef __LP64__ @@ -147,53 +176,6 @@ JSBool jsval_to_uint( JSContext *cx, jsval vp, unsigned int *ret ) return jsval_to_int32(cx, vp, (int32_t*)ret); } - -JSBool JSB_jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval ) -{ - JSBool ret = JS_FALSE; - double dp; - if( (ret=JS_ValueToNumber(cx, vp, &dp)) ) { - if( isnan(dp)) - return JS_FALSE; - *outval = (int32_t)dp; - } - return ret; -} - -JSBool JSB_jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval ) -{ - JSBool ret = JS_FALSE; - double dp; - if( (ret=JS_ValueToNumber(cx, vp, &dp)) ) { - if( isnan(dp)) - return JS_FALSE; - *outval = (uint32_t)dp; - } - return ret; -} - -JSBool JSB_jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval ) -{ - JSBool ret = JS_FALSE; - double dp; - if( (ret=JS_ValueToNumber(cx, vp, &dp)) ) { - if( isnan(dp)) - return JS_FALSE; - *outval = (uint16_t)dp; - } - return ret; -} - -jsval int_to_jsval( JSContext *cx, int number ) -{ - return INT_TO_JSVAL(number); -} - -jsval uint_to_jsval( JSContext *cx, unsigned int number ) -{ - return UINT_TO_JSVAL(number); -} - jsval long_to_jsval( JSContext *cx, long number ) { #ifdef __LP64__ @@ -249,12 +231,9 @@ JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **ret ) jsval charptr_to_jsval( JSContext *cx, const char *str) { - JSString *ret_obj = JS_NewStringCopyZ(cx, str); - return STRING_TO_JSVAL(ret_obj); + return c_string_to_jsval(cx, str); } - - JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t) { JSObject *jsobj; @@ -345,4 +324,1114 @@ JSBool JSB_get_arraybufferview_dataptr( JSContext *cx, jsval vp, GLsizei *count, } +#pragma mark - Conversion Routines +JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval ) +{ + JSBool ok = JS_TRUE; + double dp; + ok &= JS_ValueToNumber(cx, vp, &dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + ok &= !isnan(dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + *outval = (int32_t)dp; + + return ok; +} +JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval ) +{ + JSBool ok = JS_TRUE; + double dp; + ok &= JS_ValueToNumber(cx, vp, &dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + ok &= !isnan(dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + *outval = (uint32_t)dp; + + return ok; +} + +JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval ) +{ + JSBool ok = JS_TRUE; + double dp; + ok &= JS_ValueToNumber(cx, vp, &dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + ok &= !isnan(dp); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + *outval = (uint16_t)dp; + + return ok; +} + +JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) { + JSObject *tmp_arg; + JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg ); + JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); + JSB_PRECONDITION3( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object"); + JSB_PRECONDITION3( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length"); + + uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); + long long ret = arg_array[0]; + ret = ret << 32; + ret |= arg_array[1]; + + *r = ret; + return JS_TRUE; +} + +JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret) { + JSString *tmp = JS_ValueToString(cx, v); + JSB_PRECONDITION3(tmp, cx, JS_FALSE, "Error processing arguments"); + + JSStringWrapper str(tmp); + *ret = str.get(); + return JS_TRUE; +} + +JSBool jsval_to_ccpoint(JSContext *cx, jsval v, Point* ret) { + JSObject *tmp; + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + double x, y; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_ValueToNumber(cx, jsx, &x) && + JS_ValueToNumber(cx, jsy, &y); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + ret->x = (float)x; + ret->y = (float)y; + return JS_TRUE; +} + +JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, Acceleration* ret) { + JSObject *tmp; + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jsz(cx); + JS::RootedValue jstimestamp(cx); + + double x, y, timestamp, z; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "z", &jsz) && + JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) && + JS_ValueToNumber(cx, jsx, &x) && + JS_ValueToNumber(cx, jsy, &y) && + JS_ValueToNumber(cx, jsz, &z) && + JS_ValueToNumber(cx, jstimestamp, ×tamp); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + ret->x = x; + ret->y = y; + ret->z = z; + ret->timestamp = timestamp; + return JS_TRUE; +} + +JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** ret) +{ + JSBool ok = JS_TRUE; + Array* pArray = Array::create(); + for( int i=0; i < argc; i++ ) + { + double num = 0.0; + // optimization: JS_ValueToNumber is expensive. And can convert an string like "12" to a number + if ( JSVAL_IS_NUMBER(*vp)) { + ok &= JS_ValueToNumber(cx, *vp, &num ); + if (!ok) { + break; + } + pArray->addObject(Integer::create((int)num)); + } + else if (JSVAL_IS_STRING(*vp)) + { + JSStringWrapper str(JSVAL_TO_STRING(*vp), cx); + pArray->addObject(String::create(str.get())); + } + else + { + js_proxy_t* p; + JSObject* obj = JSVAL_TO_OBJECT(*vp); + p = jsb_get_js_proxy(obj); + if (p) { + pArray->addObject((Object*)p->ptr); + } + } + // next + vp++; + } + *ret = pArray; + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + return ok; +} + +JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret) { + JSObject *tmp; + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jswidth(cx); + JS::RootedValue jsheight(cx); + + double x, y, width, height; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "width", &jswidth) && + JS_GetProperty(cx, tmp, "height", &jsheight) && + JS_ValueToNumber(cx, jsx, &x) && + JS_ValueToNumber(cx, jsy, &y) && + JS_ValueToNumber(cx, jswidth, &width) && + JS_ValueToNumber(cx, jsheight, &height); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + ret->origin.x = x; + ret->origin.y = y; + ret->size.width = width; + ret->size.height = height; + return JS_TRUE; +} + +JSBool jsval_to_ccsize(JSContext *cx, jsval v, Size* ret) { + JSObject *tmp; + JS::RootedValue jsw(cx); + JS::RootedValue jsh(cx); + double w, h; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "width", &jsw) && + JS_GetProperty(cx, tmp, "height", &jsh) && + JS_ValueToNumber(cx, jsw, &w) && + JS_ValueToNumber(cx, jsh, &h); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + ret->width = w; + ret->height = h; + return JS_TRUE; +} + +JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret) { + JSObject *tmp; + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsa(cx); + + double r, g, b, a; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS_ValueToNumber(cx, jsr, &r) && + JS_ValueToNumber(cx, jsg, &g) && + JS_ValueToNumber(cx, jsb, &b) && + JS_ValueToNumber(cx, jsa, &a); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + ret->r = r; + ret->g = g; + ret->b = b; + ret->a = a; + return JS_TRUE; +} + +JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret) { + JSObject *tmp; + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsa(cx); + double r, g, b, a; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS_ValueToNumber(cx, jsr, &r) && + JS_ValueToNumber(cx, jsg, &g) && + JS_ValueToNumber(cx, jsb, &b) && + JS_ValueToNumber(cx, jsa, &a); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + ret->r = r; + ret->g = g; + ret->b = b; + ret->a = a; + return JS_TRUE; +} + +JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) { + JSObject *tmp; + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + double r, g, b; + JSBool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_ValueToNumber(cx, jsr, &r) && + JS_ValueToNumber(cx, jsg, &g) && + JS_ValueToNumber(cx, jsb, &b); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + ret->r = r; + ret->g = g; + ret->b = b; + return JS_TRUE; +} + +JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *numPoints) { + // Parsing sequence + JSObject *jsobj; + JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); + JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); + + uint32_t len; + JS_GetArrayLength(cx, jsobj, &len); + + Point *array = (Point*)malloc( sizeof(Point) * len); + + for( uint32_t i=0; i< len;i++ ) { + jsval valarg; + JS_GetElement(cx, jsobj, i, &valarg); + + ok = jsval_to_ccpoint(cx, valarg, &array[i]); + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + } + + *numPoints = len; + *points = array; + + return JS_TRUE; +} + + +JSBool jsval_to_ccarray(JSContext* cx, jsval v, Array** ret) { + JSObject *jsobj; + JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); + JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + Array* arr = Array::createWithCapacity(len); + for (uint32_t i=0; i < len; i++) { + jsval value; + if (JS_GetElement(cx, jsobj, i, &value)) { + if (value.isObject()) + { + js_proxy_t *proxy; + JSObject *tmp = JSVAL_TO_OBJECT(value); + proxy = jsb_get_js_proxy(tmp); + cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); + // Don't test it. + //TEST_NATIVE_OBJECT(cx, cobj) + if (cobj) { + // It's a native js object. + arr->addObject(cobj); + } + else if (!JS_IsArrayObject(cx, tmp)){ + // It's a normal js object. + Dictionary* dictVal = NULL; + JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); + if (ok) { + arr->addObject(dictVal); + } + } + else { + // It's a js array object. + Array* arrVal = NULL; + JSBool ok = jsval_to_ccarray(cx, value, &arrVal); + if (ok) { + arr->addObject(arrVal); + } + } + } + else if (JSVAL_IS_STRING(value)) { + JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); + arr->addObject(String::create(valueWapper.get())); + // CCLOG("iterate array: value = %s", valueWapper.get().c_str()); + } + else if (JSVAL_IS_NUMBER(value)) { + double number = 0.0; + JSBool ok = JS_ValueToNumber(cx, value, &number); + if (ok) { + arr->addObject(Double::create(number)); + // CCLOG("iterate array: value = %lf", number); + } + } + else if (JSVAL_IS_BOOLEAN(value)) { + JSBool boolVal = JS_FALSE; + JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); + if (ok) { + arr->addObject(Bool::create(boolVal)); + // CCLOG("iterate object: value = %d", boolVal); + } + } + else { + CCASSERT(false, "not supported type"); + } + } + } + *ret = arr; + return JS_TRUE; +} + + +jsval ccarray_to_jsval(JSContext* cx, Array *arr) +{ + JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); + + Object* obj; + int i = 0; + CCARRAY_FOREACH(arr, obj) + { + jsval arrElement; + + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + else { + String* strVal = NULL; + Dictionary* dictVal = NULL; + Array* arrVal = NULL; + Double* doubleVal = NULL; + Bool* boolVal = NULL; + Float* floatVal = NULL; + Integer* intVal = NULL; + + if ((strVal = dynamic_cast(obj))) { + arrElement = c_string_to_jsval(cx, strVal->getCString()); + } else if ((dictVal = dynamic_cast(obj))) { + arrElement = ccdictionary_to_jsval(cx, dictVal); + } else if ((arrVal = dynamic_cast(obj))) { + arrElement = ccarray_to_jsval(cx, arrVal); + } else if ((doubleVal = dynamic_cast(obj))) { + arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast(obj))) { + arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); + } else if ((intVal = dynamic_cast(obj))) { + arrElement = INT_TO_JSVAL(intVal->getValue()); + } else if ((boolVal = dynamic_cast(obj))) { + arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); + } else { + CCASSERT(false, "the type isn't suppored."); + } + } + if (!JS_SetElement(cx, jsretArr, i, &arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval ccdictionary_to_jsval(JSContext* cx, Dictionary* dict) +{ + JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); + DictElement* pElement = NULL; + CCDICT_FOREACH(dict, pElement) + { + JS::RootedValue dictElement(cx); + Object* obj = pElement->getObject(); + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + dictElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + else { + String* strVal = NULL; + Dictionary* dictVal = NULL; + Array* arrVal = NULL; + Double* doubleVal = NULL; + Bool* boolVal = NULL; + Float* floatVal = NULL; + Integer* intVal = NULL; + + if ((strVal = dynamic_cast(obj))) { + dictElement = c_string_to_jsval(cx, strVal->getCString()); + } else if ((dictVal = dynamic_cast(obj))) { + dictElement = ccdictionary_to_jsval(cx, dictVal); + } else if ((arrVal = dynamic_cast(obj))) { + dictElement = ccarray_to_jsval(cx, arrVal); + } else if ((doubleVal = dynamic_cast(obj))) { + dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast(obj))) { + dictElement = DOUBLE_TO_JSVAL(floatVal->getValue()); + } else if ((intVal = dynamic_cast(obj))) { + dictElement = INT_TO_JSVAL(intVal->getValue()); + } else if ((boolVal = dynamic_cast(obj))) { + dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); + } else { + CCASSERT(false, "the type isn't suppored."); + } + } + const char* key = pElement->getStrKey(); + if (key && strlen(key) > 0) + { + JS_SetProperty(cx, jsRet, key, dictElement); + } + } + return OBJECT_TO_JSVAL(jsRet); +} + +JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) +{ + if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) + { + *ret = NULL; + return JS_TRUE; + } + + JSObject* tmp = JSVAL_TO_OBJECT(v); + if (!tmp) { + CCLOG("%s", "jsval_to_ccdictionary: the jsval is not an object."); + return JS_FALSE; + } + + JSObject* it = JS_NewPropertyIterator(cx, tmp); + Dictionary* dict = NULL; + + while (true) + { + jsid idp; + jsval key; + if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { + return JS_FALSE; // error + } + + if (key == JSVAL_VOID) { + break; // end of iteration + } + + if (!JSVAL_IS_STRING(key)) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); + if (!dict) { + dict = Dictionary::create(); + } + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + if (value.isObject()) + { + js_proxy_t *proxy; + JSObject *tmp = JSVAL_TO_OBJECT(value); + proxy = jsb_get_js_proxy(tmp); + cocos2d::Object* cobj = (cocos2d::Object *)(proxy ? proxy->ptr : NULL); + // Don't test it. + //TEST_NATIVE_OBJECT(cx, cobj) + if (cobj) { + // It's a native <-> js glue object. + dict->setObject(cobj, keyWrapper.get()); + } + else if (!JS_IsArrayObject(cx, tmp)){ + // It's a normal js object. + Dictionary* dictVal = NULL; + JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); + if (ok) { + dict->setObject(dictVal, keyWrapper.get()); + } + } + else { + // It's a js array object. + Array* arrVal = NULL; + JSBool ok = jsval_to_ccarray(cx, value, &arrVal); + if (ok) { + dict->setObject(arrVal, keyWrapper.get()); + } + } + } + else if (JSVAL_IS_STRING(value)) { + JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx); + dict->setObject(String::create(valueWapper.get()), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); + } + else if (JSVAL_IS_NUMBER(value)) { + double number = 0.0; + JSBool ok = JS_ValueToNumber(cx, value, &number); + if (ok) { + dict->setObject(Double::create(number), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); + } + } + else if (JSVAL_IS_BOOLEAN(value)) { + JSBool boolVal = JS_FALSE; + JSBool ok = JS_ValueToBoolean(cx, value, &boolVal); + if (ok) { + dict->setObject(Bool::create(boolVal), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); + } + } + else { + CCASSERT(false, "not supported type"); + } + } + + *ret = dict; + return JS_TRUE; +} + +JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, AffineTransform* ret) +{ + JSObject *tmp; + JS::RootedValue jsa(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsc(cx); + JS::RootedValue jsd(cx); + JS::RootedValue jstx(cx); + JS::RootedValue jsty(cx); + double a, b, c, d, tx, ty; + JSBool ok = JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "c", &jsc) && + JS_GetProperty(cx, tmp, "d", &jsd) && + JS_GetProperty(cx, tmp, "tx", &jstx) && + JS_GetProperty(cx, tmp, "ty", &jsty) && + JS_ValueToNumber(cx, jsa, &a) && + JS_ValueToNumber(cx, jsb, &b) && + JS_ValueToNumber(cx, jsc, &c) && + JS_ValueToNumber(cx, jsd, &d) && + JS_ValueToNumber(cx, jstx, &tx) && + JS_ValueToNumber(cx, jsty, &ty); + + JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments"); + + *ret = AffineTransformMake(a, b, c, d, tx, ty); + return JS_TRUE; +} + +// From native type to jsval +jsval int32_to_jsval( JSContext *cx, int32_t number ) +{ + return INT_TO_JSVAL(number); +} + +jsval uint32_to_jsval( JSContext *cx, uint32_t number ) +{ + return UINT_TO_JSVAL(number); +} + +jsval std_string_to_jsval(JSContext* cx, const std::string& v) +{ + return c_string_to_jsval(cx, v.c_str(), v.size()); +} + +jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) +{ + if (v == NULL) + { + return JSVAL_NULL; + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + if (0 == length) + { + auto emptyStr = JS_NewStringCopyZ(cx, ""); + return STRING_TO_JSVAL(emptyStr); + } + + jsval ret = JSVAL_NULL; + int utf16_size = 0; + jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, length, &utf16_size); + + if (strUTF16 && utf16_size > 0) { + JSString* str = JS_NewUCStringCopyN(cx, strUTF16, utf16_size); + if (str) { + ret = STRING_TO_JSVAL(str); + } + delete[] strUTF16; + } + return ret; +} + +jsval ccpoint_to_jsval(JSContext* cx, const Point& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccacceleration_to_jsval(JSContext* cx, const Acceleration& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(v.z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timestamp", DOUBLE_TO_JSVAL(v.timestamp), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccrect_to_jsval(JSContext* cx, const Rect& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(v.origin.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(v.origin.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.size.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.size.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccsize_to_jsval(JSContext* cx, const Size& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "width", DOUBLE_TO_JSVAL(v.width), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "r", DOUBLE_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) { + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccaffinetransform_to_jsval(JSContext* cx, const AffineTransform& t) +{ + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(t.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(t.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "c", DOUBLE_TO_JSVAL(t.c), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "d", DOUBLE_TO_JSVAL(t.d), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "tx", DOUBLE_TO_JSVAL(t.tx), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "ty", DOUBLE_TO_JSVAL(t.ty), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) +{ + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) return JSVAL_NULL; + JSBool ok = JS_TRUE; + + ok &= JS_DefineProperty(cx, tmp, "fontName", std_string_to_jsval(cx, t._fontName), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontSize", int32_to_jsval(cx, t._fontSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontAlignmentH", int32_to_jsval(cx, (int32_t)t._alignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontAlignmentV", int32_to_jsval(cx, (int32_t)t._vertAlignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontFillColor", cccolor3b_to_jsval(cx, t._fontFillColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontDimensions", ccsize_to_jsval(cx, t._dimensions), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + // Shadow + ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowOffset", ccsize_to_jsval(cx, t._shadow._shadowOffset), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowBlur", DOUBLE_TO_JSVAL(t._shadow._shadowBlur), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", DOUBLE_TO_JSVAL(t._shadow._shadowOpacity), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + // Stroke + ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "strokeColor", cccolor3b_to_jsval(cx, t._stroke._strokeColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "strokeSize", DOUBLE_TO_JSVAL(t._stroke._strokeSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) +{ + JSObject *jsobj; + + if (!JS_ValueToObject( cx, vp, &jsobj ) ) + return JS_FALSE; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + // defaul values + const char * defautlFontName = "Arial"; + const int defaultFontSize = 32; + TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; + TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; + + // by default shadow and stroke are off + out->_shadow._shadowEnabled = false; + out->_stroke._strokeEnabled = false; + + // white text by default + out->_fontFillColor = Color3B::WHITE; + + // font name + JS::RootedValue jsr(cx); + JS_GetProperty(cx, jsobj, "fontName", &jsr); + JS_ValueToString(cx, jsr); + JSStringWrapper wrapper(jsr); + const char* fontName = wrapper.get(); + + if (fontName && strlen(fontName) > 0) + { + out->_fontName = fontName; + } + else + { + out->_fontName = defautlFontName; + } + + // font size + JSBool hasProperty; + JS_HasProperty(cx, jsobj, "fontSize", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontSize", &jsr); + double fontSize = 0.0; + JS_ValueToNumber(cx, jsr, &fontSize); + out->_fontSize = fontSize; + } + else + { + out->_fontSize = defaultFontSize; + } + + // font alignment horizontal + JS_HasProperty(cx, jsobj, "fontAlignmentH", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr); + double fontAlign = 0.0; + JS_ValueToNumber(cx, jsr, &fontAlign); + out->_alignment = (TextHAlignment)(int)fontAlign; + } + else + { + out->_alignment = defaultTextAlignment; + } + + // font alignment vertical + JS_HasProperty(cx, jsobj, "fontAlignmentV", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr); + double fontAlign = 0.0; + JS_ValueToNumber(cx, jsr, &fontAlign); + out->_vertAlignment = (TextVAlignment)(int)fontAlign; + } + else + { + out->_vertAlignment = defaultTextVAlignment; + } + + // font fill color + JS_HasProperty(cx, jsobj, "fontFillColor", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontFillColor", &jsr); + + JSObject *jsobjColor; + if (!JS_ValueToObject( cx, jsr, &jsobjColor ) ) + return JS_FALSE; + + out->_fontFillColor = getColorFromJSObject(cx, jsobjColor); + } + + // font rendering box dimensions + JS_HasProperty(cx, jsobj, "fontDimensions", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontDimensions", &jsr); + + JSObject *jsobjSize; + if (!JS_ValueToObject( cx, jsr, &jsobjSize ) ) + return JS_FALSE; + + out->_dimensions = getSizeFromJSObject(cx, jsobjSize); + } + + // shadow + JS_HasProperty(cx, jsobj, "shadowEnabled", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowEnabled", &jsr); + out->_shadow._shadowEnabled = ToBoolean(jsr); + + if ( out->_shadow._shadowEnabled ) + { + // default shadow values + out->_shadow._shadowOffset = Size(5, 5); + out->_shadow._shadowBlur = 1; + out->_shadow._shadowOpacity = 1; + + // shado offset + JS_HasProperty(cx, jsobj, "shadowOffset", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowOffset", &jsr); + + JSObject *jsobjShadowOffset; + if (!JS_ValueToObject( cx, jsr, &jsobjShadowOffset ) ) + return JS_FALSE; + out->_shadow._shadowOffset = getSizeFromJSObject(cx, jsobjShadowOffset); + } + + // shadow blur + JS_HasProperty(cx, jsobj, "shadowBlur", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowBlur", &jsr); + double shadowBlur = 0.0; + JS_ValueToNumber(cx, jsr, &shadowBlur); + out->_shadow._shadowBlur = shadowBlur; + } + + // shadow intensity + JS_HasProperty(cx, jsobj, "shadowOpacity", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowOpacity", &jsr); + double shadowOpacity = 0.0; + JS_ValueToNumber(cx, jsr, &shadowOpacity); + out->_shadow._shadowOpacity = shadowOpacity; + } + } + } + + // stroke + JS_HasProperty(cx, jsobj, "strokeEnabled", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "strokeEnabled", &jsr); + out->_stroke._strokeEnabled = ToBoolean(jsr); + + if ( out->_stroke._strokeEnabled ) + { + // default stroke values + out->_stroke._strokeSize = 1; + out->_stroke._strokeColor = Color3B::BLUE; + + // stroke color + JS_HasProperty(cx, jsobj, "strokeColor", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "strokeColor", &jsr); + + JSObject *jsobjStrokeColor; + if (!JS_ValueToObject( cx, jsr, &jsobjStrokeColor ) ) + return JS_FALSE; + out->_stroke._strokeColor = getColorFromJSObject(cx, jsobjStrokeColor); + } + + // stroke size + JS_HasProperty(cx, jsobj, "strokeSize", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "strokeSize", &jsr); + double strokeSize = 0.0; + JS_ValueToNumber(cx, jsr, &strokeSize); + out->_stroke._strokeSize = strokeSize; + } + } + } + + // we are done here + return JS_TRUE; +} + +#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +JSBool jsval_to_CCPoint( JSContext *cx, jsval vp, Point *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *jsobj; + if( ! JS_ValueToObject( cx, vp, &jsobj ) ) + return JS_FALSE; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + JS::RootedValue valx(cx); + JS::RootedValue valy(cx); + JSBool ok = JS_TRUE; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return JS_FALSE; + + double x, y; + ok &= JS_ValueToNumber(cx, valx, &x); + ok &= JS_ValueToNumber(cx, valy, &y); + + if( ! ok ) + return JS_FALSE; + + ret->x = x; + ret->y = y; + + return JS_TRUE; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return JS_FALSE; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(Point*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return JS_TRUE; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + + +JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *jsobj; + if( ! JS_ValueToObject( cx, vp, &jsobj ) ) + return JS_FALSE; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + JS::RootedValue valx(cx); + JS::RootedValue valy(cx); + JSBool ok = JS_TRUE; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return JS_FALSE; + + double x, y; + ok &= JS_ValueToNumber(cx, valx, &x); + ok &= JS_ValueToNumber(cx, valy, &y); + + if( ! ok ) + return JS_FALSE; + + ret->x = x; + ret->y = y; + + return JS_TRUE; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return JS_FALSE; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return JS_TRUE; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + + +jsval CGPoint_to_jsval( JSContext *cx, cpVect p) +{ + +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *object = JS_NewObject(cx, NULL, NULL, NULL ); + if (!object) + return JSVAL_VOID; + + if (!JS_DefineProperty(cx, object, "x", DOUBLE_TO_JSVAL(p.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "y", DOUBLE_TO_JSVAL(p.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JSVAL_VOID; + + return OBJECT_TO_JSVAL(object); + +#else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +#ifdef __LP64__ + JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); +#else + JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); +#endif + + cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); + *buffer = p; + return OBJECT_TO_JSVAL(typedArray); +#endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.h b/cocos/scripting/javascript/bindings/js_manual_conversions.h index 7a4999ae80..b3d15c86e1 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.h +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.h @@ -7,37 +7,70 @@ #include "jsapi.h" #include "js_bindings_core.h" - -//#ifdef __cplusplus -//extern "C" { -//#endif +#include "cocos2d.h" extern JSBool jsval_to_opaque( JSContext *cx, jsval vp, void **out ); extern JSBool jsval_to_int( JSContext *cx, jsval vp, int *out); extern JSBool jsval_to_uint( JSContext *cx, jsval vp, unsigned int *out); extern JSBool jsval_to_long( JSContext *cx, jsval vp, long *out); -extern JSBool jsval_to_longlong( JSContext *cx, jsval vp, long long *out); -extern jsval opaque_to_jsval( JSContext *cx, void* opaque); -extern jsval c_class_to_jsval( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* class_name); extern JSBool jsval_to_c_class( JSContext *cx, jsval vp, void **out_native, struct jsb_c_proxy_s **out_proxy); -extern jsval int_to_jsval( JSContext *cx, int number ); -extern jsval uint_to_jsval( JSContext *cx, unsigned int number ); -extern jsval long_to_jsval( JSContext *cx, long number ); -extern jsval longlong_to_jsval( JSContext *cx, long long number ); /** converts a jsval (JS string) into a char */ extern JSBool jsval_to_charptr( JSContext *cx, jsval vp, const char **out); + +extern jsval opaque_to_jsval( JSContext *cx, void* opaque); +extern jsval c_class_to_jsval( JSContext *cx, void* handle, JSObject* object, JSClass *klass, const char* class_name); +extern jsval long_to_jsval( JSContext *cx, long number ); +extern jsval longlong_to_jsval( JSContext *cx, long long number ); + /* Converts a char ptr into a jsval (using JS string) */ extern jsval charptr_to_jsval( JSContext *cx, const char *str); - -extern JSBool JSB_jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval ); -extern JSBool JSB_jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval); extern JSBool JSB_jsval_typedarray_to_dataptr( JSContext *cx, jsval vp, GLsizei *count, void **data, JSArrayBufferViewType t); extern JSBool JSB_get_arraybufferview_dataptr( JSContext *cx, jsval vp, GLsizei *count, GLvoid **data ); -extern JSBool JSB_jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval ); -//#ifdef __cplusplus -//} -//#endif +// some utility functions +// to native +JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *ret ); +JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *ret ); +JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *ret ); +JSBool jsval_to_long_long(JSContext *cx, jsval v, long long* ret); +JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret); +JSBool jsval_to_ccpoint(JSContext *cx, jsval v, cocos2d::Point* ret); +JSBool jsval_to_ccrect(JSContext *cx, jsval v, cocos2d::Rect* ret); +JSBool jsval_to_ccsize(JSContext *cx, jsval v, cocos2d::Size* ret); +JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, cocos2d::Color4B* ret); +JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, cocos2d::Color4F* ret); +JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, cocos2d::Color3B* ret); +JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, cocos2d::Point **points, int *numPoints); +JSBool jsval_to_ccarray(JSContext* cx, jsval v, cocos2d::Array** ret); +JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, cocos2d::Dictionary** ret); +JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, cocos2d::Acceleration* ret); +JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::Array** ret); +JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, cocos2d::AffineTransform* ret); +JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, cocos2d::FontDefinition* ret ); + +// from native +jsval int32_to_jsval( JSContext *cx, int32_t l); +jsval uint32_to_jsval( JSContext *cx, uint32_t number ); +jsval long_long_to_jsval(JSContext* cx, long long v); +jsval std_string_to_jsval(JSContext* cx, const std::string& v); +jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); +jsval ccpoint_to_jsval(JSContext* cx, const cocos2d::Point& v); +jsval ccrect_to_jsval(JSContext* cx, const cocos2d::Rect& v); +jsval ccsize_to_jsval(JSContext* cx, const cocos2d::Size& v); +jsval cccolor4b_to_jsval(JSContext* cx, const cocos2d::Color4B& v); +jsval cccolor4f_to_jsval(JSContext* cx, const cocos2d::Color4F& v); +jsval cccolor3b_to_jsval(JSContext* cx, const cocos2d::Color3B& v); +jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::Dictionary *dict); +jsval ccarray_to_jsval(JSContext* cx, cocos2d::Array *arr); +jsval ccacceleration_to_jsval(JSContext* cx, const cocos2d::Acceleration& v); +jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& t); +jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); + +JSBool jsval_to_CGPoint( JSContext *cx, jsval vp, cpVect *out ); +jsval CGPoint_to_jsval( JSContext *cx, cpVect p ); + +#define cpVect_to_jsval CGPoint_to_jsval +#define jsval_to_cpVect jsval_to_CGPoint #endif /* __JS_MANUAL_CONVERSIONS_H__ */ diff --git a/cocos/scripting/javascript/bindings/jsb_opengl_functions.cpp b/cocos/scripting/javascript/bindings/jsb_opengl_functions.cpp index 1d99cff3b3..878191adfd 100644 --- a/cocos/scripting/javascript/bindings/jsb_opengl_functions.cpp +++ b/cocos/scripting/javascript/bindings/jsb_opengl_functions.cpp @@ -12,7 +12,6 @@ //#include "jsb_config.h" #include "js_bindings_core.h" #include "js_manual_conversions.h" -#include "cocosjs_manual_conversions.h" #include "jsb_opengl_functions.h" // Arguments: GLenum @@ -23,7 +22,7 @@ JSBool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glActiveTexture((GLenum)arg0 ); @@ -39,8 +38,8 @@ JSBool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glAttachShader((GLuint)arg0 , (GLuint)arg1 ); @@ -56,8 +55,8 @@ JSBool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; const char* arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); ok &= jsval_to_charptr(cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -74,8 +73,8 @@ JSBool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindBuffer((GLenum)arg0 , (GLuint)arg1 ); @@ -91,8 +90,8 @@ JSBool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 ); @@ -108,8 +107,8 @@ JSBool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 ); @@ -125,8 +124,8 @@ JSBool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBindTexture((GLenum)arg0 , (GLuint)arg1 ); @@ -142,10 +141,10 @@ JSBool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); @@ -161,7 +160,7 @@ JSBool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendEquation((GLenum)arg0 ); @@ -177,8 +176,8 @@ JSBool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 ); @@ -194,8 +193,8 @@ JSBool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendFunc((GLenum)arg0 , (GLenum)arg1 ); @@ -211,10 +210,10 @@ JSBool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); @@ -230,10 +229,10 @@ JSBool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; uint32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg1); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 ); @@ -249,8 +248,8 @@ JSBool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg2); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -268,7 +267,7 @@ JSBool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLenum ret_val; @@ -285,7 +284,7 @@ JSBool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClear((GLbitfield)arg0 ); @@ -301,10 +300,10 @@ JSBool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); @@ -320,7 +319,7 @@ JSBool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearDepthf((GLclampf)arg0 ); @@ -336,7 +335,7 @@ JSBool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glClearStencil((GLint)arg0 ); @@ -352,10 +351,10 @@ JSBool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 ); @@ -371,7 +370,7 @@ JSBool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCompileShader((GLuint)arg0 ); @@ -387,13 +386,13 @@ JSBool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_int32( cx, *argvp++, &arg6 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg7); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -411,14 +410,14 @@ JSBool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= jsval_to_int32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -436,14 +435,14 @@ JSBool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_int32( cx, *argvp++, &arg6 ); + ok &= jsval_to_int32( cx, *argvp++, &arg7 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 ); @@ -459,14 +458,14 @@ JSBool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg6 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg7 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_int32( cx, *argvp++, &arg6 ); + ok &= jsval_to_int32( cx, *argvp++, &arg7 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 ); @@ -493,7 +492,7 @@ JSBool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLuint ret_val; @@ -510,7 +509,7 @@ JSBool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glCullFace((GLenum)arg0 ); @@ -526,7 +525,7 @@ JSBool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteProgram((GLuint)arg0 ); @@ -542,7 +541,7 @@ JSBool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDeleteShader((GLuint)arg0 ); @@ -558,7 +557,7 @@ JSBool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthFunc((GLenum)arg0 ); @@ -574,7 +573,7 @@ JSBool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint16_t arg0; - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthMask((GLboolean)arg0 ); @@ -590,8 +589,8 @@ JSBool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 ); @@ -607,8 +606,8 @@ JSBool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDetachShader((GLuint)arg0 , (GLuint)arg1 ); @@ -624,7 +623,7 @@ JSBool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDisable((GLenum)arg0 ); @@ -640,7 +639,7 @@ JSBool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDisableVertexAttribArray((GLuint)arg0 ); @@ -656,9 +655,9 @@ JSBool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 ); @@ -674,9 +673,9 @@ JSBool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg3); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -694,7 +693,7 @@ JSBool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glEnable((GLenum)arg0 ); @@ -710,7 +709,7 @@ JSBool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glEnableVertexAttribArray((GLuint)arg0 ); @@ -746,10 +745,10 @@ JSBool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 ); @@ -765,11 +764,11 @@ JSBool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 ); @@ -785,7 +784,7 @@ JSBool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glFrontFace((GLenum)arg0 ); @@ -801,7 +800,7 @@ JSBool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glGenerateMipmap((GLenum)arg0 ); @@ -817,7 +816,7 @@ JSBool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; const char* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); int ret_val; @@ -846,7 +845,7 @@ JSBool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; const char* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); ok &= jsval_to_charptr( cx, *argvp++, &arg1 ); printf("%s ", arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -865,8 +864,8 @@ JSBool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glHint((GLenum)arg0 , (GLenum)arg1 ); @@ -882,7 +881,7 @@ JSBool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -899,7 +898,7 @@ JSBool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -916,7 +915,7 @@ JSBool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -933,7 +932,7 @@ JSBool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -950,7 +949,7 @@ JSBool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -967,7 +966,7 @@ JSBool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -984,7 +983,7 @@ JSBool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); GLboolean ret_val; @@ -1001,7 +1000,7 @@ JSBool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glLineWidth((GLfloat)arg0 ); @@ -1017,7 +1016,7 @@ JSBool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glLinkProgram((GLuint)arg0 ); @@ -1033,8 +1032,8 @@ JSBool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glPixelStorei((GLenum)arg0 , (GLint)arg1 ); @@ -1050,8 +1049,8 @@ JSBool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 ); @@ -1067,12 +1066,12 @@ JSBool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg5 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg4 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg5 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg6); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1100,10 +1099,10 @@ JSBool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); @@ -1119,8 +1118,8 @@ JSBool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 ); @@ -1136,10 +1135,10 @@ JSBool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); @@ -1155,9 +1154,9 @@ JSBool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 ); @@ -1173,10 +1172,10 @@ JSBool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 ); @@ -1192,7 +1191,7 @@ JSBool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilMask((GLuint)arg0 ); @@ -1208,8 +1207,8 @@ JSBool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 ); @@ -1225,9 +1224,9 @@ JSBool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 ); @@ -1243,10 +1242,10 @@ JSBool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); @@ -1262,14 +1261,14 @@ JSBool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg7 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1287,9 +1286,9 @@ JSBool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 ); @@ -1305,9 +1304,9 @@ JSBool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; uint32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 ); @@ -1323,14 +1322,14 @@ JSBool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg6 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg7 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg6 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg7 ); GLsizei count; ok &= JSB_get_arraybufferview_dataptr( cx, *argvp++, &count, &arg8); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1348,8 +1347,8 @@ JSBool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1f((GLint)arg0 , (GLfloat)arg1 ); @@ -1365,8 +1364,8 @@ JSBool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1384,8 +1383,8 @@ JSBool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform1i((GLint)arg0 , (GLint)arg1 ); @@ -1401,8 +1400,8 @@ JSBool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1420,9 +1419,9 @@ JSBool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); @@ -1438,8 +1437,8 @@ JSBool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1457,9 +1456,9 @@ JSBool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 ); @@ -1475,8 +1474,8 @@ JSBool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1494,10 +1493,10 @@ JSBool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); @@ -1513,8 +1512,8 @@ JSBool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1532,10 +1531,10 @@ JSBool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 ); @@ -1551,8 +1550,8 @@ JSBool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1570,11 +1569,11 @@ JSBool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); @@ -1590,8 +1589,8 @@ JSBool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1609,11 +1608,11 @@ JSBool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 ); @@ -1629,8 +1628,8 @@ JSBool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_INT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1648,8 +1647,8 @@ JSBool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1667,8 +1666,8 @@ JSBool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1686,8 +1685,8 @@ JSBool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; uint16_t arg1; void* arg2; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg1 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg2, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1705,7 +1704,7 @@ JSBool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glUseProgram((GLuint)arg0 ); @@ -1721,7 +1720,7 @@ JSBool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glValidateProgram((GLuint)arg0 ); @@ -1737,8 +1736,8 @@ JSBool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 ); @@ -1754,7 +1753,7 @@ JSBool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1772,9 +1771,9 @@ JSBool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); @@ -1790,7 +1789,7 @@ JSBool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1808,10 +1807,10 @@ JSBool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); @@ -1827,7 +1826,7 @@ JSBool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1845,11 +1844,11 @@ JSBool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); @@ -1865,7 +1864,7 @@ JSBool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; void* arg1; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); GLsizei count; ok &= JSB_jsval_typedarray_to_dataptr( cx, *argvp++, &count, &arg1, js::ArrayBufferView::TYPE_FLOAT32); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); @@ -1883,12 +1882,12 @@ JSBool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_uint32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_uint16( cx, *argvp++, &arg3 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg4 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg5 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_uint32( cx, *argvp++, &arg2 ); + ok &= jsval_to_uint16( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg4 ); + ok &= jsval_to_int32( cx, *argvp++, &arg5 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 ); @@ -1904,10 +1903,10 @@ JSBool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp) { JSBool ok = JS_TRUE; int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg0 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg1 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg2 ); - ok &= JSB_jsval_to_int32( cx, *argvp++, &arg3 ); + ok &= jsval_to_int32( cx, *argvp++, &arg0 ); + ok &= jsval_to_int32( cx, *argvp++, &arg1 ); + ok &= jsval_to_int32( cx, *argvp++, &arg2 ); + ok &= jsval_to_int32( cx, *argvp++, &arg3 ); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); diff --git a/cocos/scripting/javascript/bindings/jsb_opengl_manual.cpp b/cocos/scripting/javascript/bindings/jsb_opengl_manual.cpp index 38a168b935..fa4e2d31c8 100644 --- a/cocos/scripting/javascript/bindings/jsb_opengl_manual.cpp +++ b/cocos/scripting/javascript/bindings/jsb_opengl_manual.cpp @@ -31,7 +31,6 @@ #include "jsb_opengl_manual.h" #include "js_manual_conversions.h" -#include "cocosjs_manual_conversions.h" #include "js_bindings_core.h" #include "jsb_opengl_functions.h" diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index 11085f336c..a4cbbd4d50 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -13,7 +13,6 @@ - @@ -25,7 +24,6 @@ - diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 1d1e1d400a..85bb2eccd3 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -17,9 +17,6 @@ manual - - manual - manual @@ -49,9 +46,6 @@ manual - - manual - manual From 49289d7576501e9c943cc14d49ea518f736061c7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 15:46:00 +0800 Subject: [PATCH 096/185] Adding cc.TextureCache.getInstance() to jsb_deprecated.js. --- cocos/scripting/javascript/script/jsb_deprecated.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos/scripting/javascript/script/jsb_deprecated.js b/cocos/scripting/javascript/script/jsb_deprecated.js index 2c7a7b1ed1..cf2065152f 100644 --- a/cocos/scripting/javascript/script/jsb_deprecated.js +++ b/cocos/scripting/javascript/script/jsb_deprecated.js @@ -14,6 +14,10 @@ var cc = cc || {}; cc.AnimationCache.destroyInstance(); }; + cc.TextureCache.getInstance = function() { + return cc.Director.getInstance().getTextureCache(); + }; + // Deprecated member functions cc.Action.prototype.copy = function() { logW("cc.Action.copy", "cc.Action.clone"); From 22584ca9c2eafd27f344684ecfee68f870924c38 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 15:47:43 +0800 Subject: [PATCH 097/185] Updating submodule of bindings-generator. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index a943736554..9797d44032 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit a94373655409f756b33d8a58cc798dcb00be257c +Subproject commit 9797d4403207848f431d5b6456632cc966d84b0d From 06c7d3e96d7089b3e168227f4636d36affaae7d9 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Mon, 11 Nov 2013 17:03:43 +0800 Subject: [PATCH 098/185] issue #2868:Add ccd lua test samples --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/CCScene.cpp | 6 +- .../editor-support/cocostudio/CCSGUIReader.h | 4 +- .../lua_cocos2dx_coco_studio_manual.cpp | 166 +- .../scripting/lua/script/StudioConstants.lua | 160 ++ .../CocoStudioGUITest/CocoStudioGUITest.lua | 2016 +++++++++++++++-- .../CocoStudioGUITest/UIScene.lua | 71 - .../TestLua/Resources/luaScript/mainMenu.lua | 1 + tools/tolua/cocos2dx_studio.ini | 8 +- 9 files changed, 2026 insertions(+), 408 deletions(-) create mode 100644 cocos/scripting/lua/script/StudioConstants.lua delete mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index 420d377772..5562fe8565 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -3ff18018375c71f683a484652678740cc6395eaf \ No newline at end of file +bb6b434fc4b6f0865e841fd87dddff603200c029 \ No newline at end of file diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 3f05e43c83..53fb2117bb 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -161,7 +161,11 @@ void Scene::update(float delta) { Node::update(delta); - _physicsWorld->update(delta); + if (nullptr != _physicsWorld) + { + _physicsWorld->update(delta); + } + } #endif diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 415b7b9e81..04f62bbf09 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -31,11 +31,11 @@ namespace cocostudio { #define kCCSVersion 1.0 -class CCSGUIReader : cocos2d::Object +class CCSGUIReader : public cocos2d::Object { public: CCSGUIReader(); - ~CCSGUIReader(); + virtual ~CCSGUIReader(); static CCSGUIReader* shareReader(); static void purgeCCSGUIReader(); diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 708c6e80a7..0788252cdc 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -24,16 +24,12 @@ public: LuaCocoStudioEventListener(); virtual ~LuaCocoStudioEventListener(); - virtual void setObjTarget(Object* objTarget); - static LuaCocoStudioEventListener* create(); virtual void eventCallbackFunc(Object* sender,int eventType); -private: - Object* _objTarget; }; -LuaCocoStudioEventListener::LuaCocoStudioEventListener():_objTarget(nullptr) +LuaCocoStudioEventListener::LuaCocoStudioEventListener() { } @@ -54,18 +50,13 @@ LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() return listener; } -void LuaCocoStudioEventListener::setObjTarget(Object* objTarget) -{ - _objTarget = objTarget; -} - void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); if (0 != handler) { - LuaCocoStudioEventListenerData eventData(_objTarget,eventType); + LuaCocoStudioEventListenerData eventData(sender,eventType); BasicScriptData data(this,(void*)&eventData); ScriptEvent scriptEvent(kCocoStudioEventListener,(void*)&data); ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); @@ -93,35 +84,35 @@ static int lua_cocos2dx_UIWidget_addTouchEventListener(lua_State* L) return 0; } #endif - if (2 == argc) + + argc = lua_gettop(L) - 1; + + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); - listern->setObjTarget(obj); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - - self->addTouchEventListener(listern, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->setUserObject(listener); + self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addTouchEventListener' function of UIWidget has wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'addTouchEventListener' function of UIWidget has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -163,34 +154,32 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) } #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); - listern->setObjTarget(obj); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - self->addEventListener(listern, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->setUserObject(listener); + self->addEventListener(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'addEventListener' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -233,34 +222,32 @@ static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) } #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - listern->setObjTarget(obj); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - - self->addEventListener(listern, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->setUserObject(listener); + self->addEventListener(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'addEventListener' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; @@ -303,34 +290,32 @@ static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) } #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - listern->setObjTarget(obj); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - - self->addEventListener(listern, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->setUserObject(listener); + self->addEventListener(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'addEventListener' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; @@ -373,34 +358,32 @@ static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) } #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0; } LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - listern->setObjTarget(obj); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); - - self->addEventListener(listern, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->setUserObject(listener); + self->addEventListener(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 2); + CCLOG("'addEventListener' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; @@ -635,15 +618,12 @@ public: LuaArmatureWrapper(); virtual ~LuaArmatureWrapper(); - virtual void setObjTarget(Object* objTarget); virtual void movementEventCallback(Armature* armature, MovementEventType type,const char* movementID); virtual void frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex); virtual void addArmatureFileInfoAsyncCallback(float percent); -private: - Object* _objTarget; }; -LuaArmatureWrapper::LuaArmatureWrapper():_objTarget(nullptr) +LuaArmatureWrapper::LuaArmatureWrapper() { } @@ -653,11 +633,6 @@ LuaArmatureWrapper::~LuaArmatureWrapper() } -void LuaArmatureWrapper::setObjTarget(Object* objTarget) -{ - _objTarget = objTarget; -} - void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); @@ -736,23 +711,20 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - wrapper->setObjTarget(obj); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback)); @@ -760,7 +732,7 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) return 0; } - CCLOG("'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; @@ -794,29 +766,30 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) #endif argc = lua_gettop(L) - 1; - if (2 == argc) + if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) { goto tolua_lerror; } #endif LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - wrapper->setObjTarget(obj); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback)); return 0; } + + + CCLOG("'setFrameEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n", argc, 1); + #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err); @@ -858,38 +831,34 @@ static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua #endif argc = lua_gettop(L) - 1; - if (3 == argc) + if (2 == argc) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(L, 2, 0, &tolua_err) || - !tolua_isusertype(L, 3, "Object", 0, &tolua_err) || - !toluafix_isfunction(L,4,"LUA_FUNCTION",0,&tolua_err)) + !toluafix_isfunction(L,3,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } #endif const char* configFilePath = tolua_tostring(L, 2, ""); - Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); - LUA_FUNCTION handler = ( toluafix_ref_function(L,4,0)); + LUA_FUNCTION handler = ( toluafix_ref_function(L, 3, 0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - wrapper->setObjTarget(obj); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->addArmatureFileInfoAsync(configFilePath, wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); return 0; } - else if (5 == argc) + else if (4 == argc) { #if COCOS2D_DEBUG >= 1 if ( !tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) || !tolua_isstring(L, 4, 0, &tolua_err) || - !tolua_isusertype(L, 5, "Object", 0, &tolua_err) || - !toluafix_isfunction(L,6,"LUA_FUNCTION",0,&tolua_err)) + !toluafix_isfunction(L,5,"LUA_FUNCTION",0,&tolua_err)) { goto tolua_lerror; } @@ -898,19 +867,20 @@ static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua const char* plistPath = tolua_tostring(L, 3, ""); const char* configFilePath = tolua_tostring(L, 4, ""); - Object* obj = static_cast(tolua_tousertype(L, 5, nullptr)); - LUA_FUNCTION handler = ( toluafix_ref_function(L,6,0)); + LUA_FUNCTION handler = ( toluafix_ref_function(L,5,0)); LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - wrapper->setObjTarget(obj); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); self->addArmatureFileInfoAsync(imagePath, plistPath,configFilePath,wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); return 0; } + + CCLOG("'addArmatureFileInfoAsync' function of ArmatureDataManager has wrong number of arguments: %d, was expecting %d\n", argc, 1); + #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(L,"#ferror in function 'addArmatureFileInfoAsync'.",&tolua_err); @@ -935,7 +905,7 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L) extendUIWidget(L); extendUICheckBox(L); extendUISlider(L); - extendUISlider(L); + extendUITextField(L); extendUIPageView(L); // extendUIListView(L); extendLayoutParameter(L); diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua new file mode 100644 index 0000000000..5b38ac6f69 --- /dev/null +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -0,0 +1,160 @@ +ccs = ccs or {} + +CC_MovementEventType_START = 0 +CC_MovementEventType_COMPLETE = 1 +CC_MovementEventType_LOOP_COMPLETE = 2 + +ccs.BrightStyle = +{ + none = -1, + normal = 0, + highlight = 1, +} + +ccs.WidgetType = +{ + widget = 0, --control + container = 1, --container +}; + +-- ccs.TextureResType = +-- { +-- "local" = 0, +-- "plist" = 1, +-- } + +ccs.TouchEventType = +{ + began = 0, + moved = 1, + ended = 2, + canceled = 3, +} + +ccs.SizeType = +{ + absolute = 0, + percent = 1, +}; + +ccs.PositionType = { + absolute = 0, + percent = 1, +}; + +ccs.CheckBoxEventType = +{ + selected = 0, + unselected = 1, +}; + +ccs.TextFiledEventType = +{ + attach_with_ime = 0, + detach_with_ime = 1, + insert_text = 2, + delete_backward = 3, +}; + +ccs.LayoutBackGroundColorType = +{ + none = 0, + solid = 1, + gradient = 2, +}; + +ccs.LayoutType = +{ + absolute = 0, + linearVertical = 1, + linearHorizontal = 2, + relative = 3, +}; + +ccs.UILayoutParameterType = +{ + none = 0, + linear = 1, + relative = 2, +}; + +ccs.UILinearGravity = +{ + none = 0, + left = 1, + top = 2, + right = 3, + bottom = 4, + centerVertical = 5, + centerHorizontal = 6, +}; + +ccs.UIRelativeAlign = +{ + alignNone = 0, + alignParentTopLeft = 1, + alignParentTopCenterHorizontal = 2, + alignParentTopRight = 3, + alignParentLeftCenterVertical = 4, + centerInParent = 5, + alignParentRightCenterVertical = 6, + alignParentLeftBottom = 7, + alignParentBottomCenterHorizontal = 8, + alignParentRightBottom = 9, + locationAboveLeftAlign = 10, + locationAboveCenter = 11, + locationAboveRightAlign = 12, + locationLeftOfTopAlign = 13, + locationLeftOfCenter = 14, + locationLeftOfBottomAlign = 15, + locationRightOfTopAlign = 16, + locationRightOfCenter = 17, + locationRightOfBottomAlign = 18, + locationBelowLeftAlign = 19, + locationBelowCenter = 20, + locationBelowRightAlign = 21, +}; + +ccs.SliderEventType = {percent_changed = 0}; + +ccs.LoadingBarType = { left = 0, right = 1}; + +ccs.SCROLLVIEW_DIR = { + none = 0, + vertical = 1, + horizontal = 2, +}; + +ccs.SCROLLVIEW_MOVE_DIR = { + none = 0, + up = 1, + down = 2, + left = 3, + right = 4, +}; + +ccs.ScrollviewEventType = { + top = 0, + bottom = 1, + left = 2, + right = 3, +}; + +ccs.ListViewDirection = { + none = 0, + vertical = 1, + horizontal = 2, +}; + +ccs.ListViewMoveDirection = { + none = 0, + up = 1, + down = 2, + left = 3, + right = 4, +}; + +ccs.ListViewEventType = { + init_child = 0, + update_child = 1, +} \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index 92fb321a47..de25ec354b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -1,230 +1,1795 @@ +require "luaScript/CocoStudioTest/CocoStudioGUITest/UIScene" + +local guiSceneManager = {} +guiSceneManager.currentUISceneIdx = 1 + +local UIScene = class("UIScene") +UIScene.__index = UIScene +UIScene._uiLayer= nil +UIScene._widget = nil +UIScene._sceneTitle = nil + +function UIScene.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIScene) + return target +end + +function UIScene:init() + self._uiLayer = ccs.UILayer:create() + self:addChild(self._uiLayer) + + self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + back_label:setVisible(false) + + local function previousCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) + end + end + + local left_button = self._uiLayer:getWidgetByName("left_Button") + left_button:addTouchEventListener(previousCallback) + + local function restartCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) + end + end + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + middle_button:addTouchEventListener(restartCallback) + + local function nextCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) + end + end + + local right_button = self._uiLayer:getWidgetByName("right_Button") + right_button:addTouchEventListener(nextCallback) + + local function menuCloseCallback( sender,eventType) + if eventType == ccs.TouchEventType.ended then + self._uiLayer:removeFromParent() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + end + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function UIScene.create() + local scene = UIScene.extend(cc.Scene:create()) + scene:init() + return scene +end + +local UIButtonTest = class("UIButtonTest",UIScene) +UIButtonTest._displayValueLabel = nil + +function UIButtonTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIButtonTest) + return target +end + +function UIButtonTest:initExtend() + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("Button") + alert:setFontName(font_UIButtonTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function touchEvent(sender,eventType) + if eventType == ccs.TouchEventType.began then + self._displayValueLabel:setText("Touch Down") + elseif eventType == ccs.TouchEventType.moved then + self._displayValueLabel:setText("Touch Move") + elseif eventType == ccs.TouchEventType.ended then + self._displayValueLabel:setText("Touch Up") + elseif eventType == ccs.TouchEventType.canceled then + self._displayValueLabel:setText("Touch Cancelled") + end + end + local button = ccs.UIButton:create() + button:setTouchEnabled(true) + button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addWidget(button) +end + +function UIButtonTest.create() + local scene = UIButtonTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + + +local UIButtonScale9Test = class("UIButtonScale9Test",UIScene) +UIButtonScale9Test._displayValueLabel = nil + +function UIButtonScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIButtonScale9Test) + return target +end + +function UIButtonScale9Test:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("Button scale9 render") + alert:setFontName(font_UIButtonTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function touchEvent(sender,eventType) + if eventType == ccs.TouchEventType.began then + self._displayValueLabel:setText("Touch Down") + elseif eventType == ccs.TouchEventType.moved then + self._displayValueLabel:setText("Touch Move") + elseif eventType == ccs.TouchEventType.ended then + self._displayValueLabel:setText("Touch Up") + elseif eventType == ccs.TouchEventType.canceled then + self._displayValueLabel:setText("Touch Cancelled") + end + end + + local button = ccs.UIButton:create() + button:setTouchEnabled(true) + button:setScale9Enabled(true) + button:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:setSize(cc.size(150, button:getContentSize().height * 1.5)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addWidget(button) +end + +function UIButtonScale9Test.create() + local scene = UIButtonScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UIButtonPressedActionTest = class("UIButtonPressedActionTest",UIScene) +UIButtonPressedActionTest._displayValueLabel = nil + +function UIButtonPressedActionTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIButtonPressedActionTest) + return target +end + +function UIButtonPressedActionTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("Button Pressed Action") + alert:setFontName(font_UIButtonTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function touchEvent(sender,eventType) + if eventType == ccs.TouchEventType.began then + self._displayValueLabel:setText("Touch Down") + elseif eventType == ccs.TouchEventType.moved then + self._displayValueLabel:setText("Touch Move") + elseif eventType == ccs.TouchEventType.ended then + self._displayValueLabel:setText("Touch Up") + elseif eventType == ccs.TouchEventType.canceled then + self._displayValueLabel:setText("Touch Cancelled") + end + end + + local button = ccs.UIButton:create() + button:setTouchEnabled(true) + button:setPressedActionEnabled(true) + button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") + button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + button:addTouchEventListener(touchEvent) + self._uiLayer:addWidget(button) +end + +function UIButtonPressedActionTest.create() + local scene = UIButtonPressedActionTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextButtonTest = class("UITextButtonTest",UIScene) +UITextButtonTest._displayValueLabel = nil + +function UITextButtonTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextButtonTest) + return target +end + +function UITextButtonTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("TextButton") + alert:setFontName(font_UIButtonTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function touchEvent(sender,eventType) + if eventType == ccs.TouchEventType.began then + self._displayValueLabel:setText("Touch Down") + elseif eventType == ccs.TouchEventType.moved then + self._displayValueLabel:setText("Touch Move") + elseif eventType == ccs.TouchEventType.ended then + self._displayValueLabel:setText("Touch Up") + elseif eventType == ccs.TouchEventType.canceled then + self._displayValueLabel:setText("Touch Cancelled") + end + end + + local textButton = ccs.UIButton:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosgui/backtotopnormal.png", "cocosgui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textButton:addTouchEventListener(touchEvent) + self._uiLayer:addWidget(textButton) +end + +function UITextButtonTest.create() + local scene = UITextButtonTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextButtonScale9Test = class("UITextButtonScale9Test",UIScene) +UITextButtonScale9Test._displayValueLabel = nil + +function UITextButtonScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextButtonScale9Test) + return target +end + +function UITextButtonScale9Test:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("TextButton scale9 render") + alert:setFontName(font_UIButtonTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function touchEvent(sender,eventType) + if eventType == ccs.TouchEventType.began then + self._displayValueLabel:setText("Touch Down") + elseif eventType == ccs.TouchEventType.moved then + self._displayValueLabel:setText("Touch Move") + elseif eventType == ccs.TouchEventType.ended then + self._displayValueLabel:setText("Touch Up") + elseif eventType == ccs.TouchEventType.canceled then + self._displayValueLabel:setText("Touch Cancelled") + end + end + + local textButton = ccs.UIButton:create() + textButton:setTouchEnabled(true) + textButton:setScale9Enabled(true) + textButton:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") + textButton:setSize(cc.size(180, textButton:getContentSize().height * 1.5)) + textButton:setTitleText("Text Button scale9 render") + textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textButton:addTouchEventListener(touchEvent) + self._uiLayer:addWidget(textButton) +end + +function UITextButtonScale9Test.create() + local scene = UITextButtonScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UICheckBoxTest = class("UICheckBoxTest",UIScene) +UICheckBoxTest._displayValueLabel = nil + +function UICheckBoxTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UICheckBoxTest) + return target +end + +function UICheckBoxTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UIButtonTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("CheckBox") + alert:setFontName(font_UICheckBoxTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function selectedEvent(sender,eventType) + if eventType == ccs.CheckBoxEventType.selected then + self._displayValueLabel:setText("Selected") + elseif eventType == ccs.CheckBoxEventType.unselected then + self._displayValueLabel:setText("Unselected") + end + end + + local checkBox = ccs.UICheckBox:create() + checkBox:setTouchEnabled(true) + checkBox:loadTextures("cocosgui/check_box_normal.png", + "cocosgui/check_box_normal_press.png", + "cocosgui/check_box_active.png", + "cocosgui/check_box_normal_disable.png", + "cocosgui/check_box_active_disable.png") + checkBox:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + + checkBox:addEventListener(selectedEvent) + + self._uiLayer:addWidget(checkBox) +end + +function UICheckBoxTest.create() + local scene = UICheckBoxTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UISliderTest = class("UISliderTest",UIScene) +UISliderTest._displayValueLabel = nil + +function UISliderTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UISliderTest) + return target +end + +function UISliderTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("Move the slider thumb") + self._displayValueLabel:setFontName(font_UISliderTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("Slider") + alert:setFontName(font_UISliderTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function percentChangedEvent(sender,eventType) + if eventType == ccs.SliderEventType.percent_changed then + local slider = tolua.cast(sender,"UISlider") + local percent = "Percent " .. slider:getPercent() + self._displayValueLabel:setText(percent) + end + end + + local slider = ccs.UISlider:create() + slider:setTouchEnabled(true) + slider:loadBarTexture("cocosgui/sliderTrack.png") + slider:loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosgui/sliderProgress.png") + slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + slider:addEventListener(percentChangedEvent) + + self._uiLayer:addWidget(slider) +end + +function UISliderTest.create() + local scene = UISliderTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UISliderScale9Test = class("UISliderScale9Test",UIScene) +UISliderScale9Test._displayValueLabel = nil + +function UISliderScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UISliderScale9Test) + return target +end + +function UISliderScale9Test:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("Move the slider thumb") + self._displayValueLabel:setFontName(font_UISliderTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("Slider scale9 render") + alert:setFontName(font_UISliderTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function percentChangedEvent(sender,eventType) + if eventType == ccs.SliderEventType.percent_changed then + local slider = tolua.cast(sender,"UISlider") + local percent = "Percent " .. slider:getPercent() + self._displayValueLabel:setText(percent) + end + end + + local slider = ccs.UISlider:create() + slider:setTouchEnabled(true) + slider:loadBarTexture("cocosgui/sliderTrack2.png") + slider:loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosgui/slider_bar_active_9patch.png") + slider:setScale9Enabled(true) + slider:setCapInsets(cc.rect(0, 0, 0, 0)) + slider:setSize(cc.size(250, 10)) + slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + slider:addEventListener(percentChangedEvent) + + self._uiLayer:addWidget(slider) +end + +function UISliderScale9Test.create() + local scene = UISliderScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UIImageViewTest = class("UIImageViewTest",UIScene) + +function UIImageViewTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIImageViewTest) + return target +end + +function UIImageViewTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("ImageView") + alert:setFontName(font_UIImageViewTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local imageView = ccs.UIImageView:create() + imageView:loadTexture("cocosgui/ccicon.png") + imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getSize().height / 4.0)) + self._uiLayer:addWidget(imageView) +end + +function UIImageViewTest.create() + local scene = UIImageViewTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + + +local UIImageViewScale9Test = class("UIImageViewScale9Test",UIScene) + +function UIImageViewScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIImageViewScale9Test) + return target +end + +function UIImageViewScale9Test:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("ImageView scale9 render") + alert:setFontName(font_UIImageViewTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local imageView = ccs.UIImageView:create() + imageView:setScale9Enabled(true) + imageView:loadTexture("cocosgui/buttonHighlighted.png") + imageView:setSize(cc.size(200, 85)) + imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getSize().height / 4.0)) + self._uiLayer:addWidget(imageView) +end + +function UIImageViewScale9Test.create() + local scene = UIImageViewScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILoadingBarLeftTest = class("UILoadingBarLeftTest",UIScene) +UILoadingBarLeftTest._count = 0 + +function UILoadingBarLeftTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILoadingBarLeftTest) + return target +end + +function UILoadingBarLeftTest:initExtend() + + self._uiLayer = ccs.UILayer:create() + self:addChild(self._uiLayer) + + self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + back_label:setVisible(false) + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LoadingBar") + alert:setFontName(font_UILoadingBarTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local loadingBar = ccs.UILoadingBar:create() + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosgui/sliderProgress.png") + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) + self._uiLayer:addWidget(loadingBar) + + local function update(delta) + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + local function previousCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) + end + end + + local left_button = self._uiLayer:getWidgetByName("left_Button") + left_button:addTouchEventListener(previousCallback) + + local function restartCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) + end + end + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + middle_button:addTouchEventListener(restartCallback) + + local function nextCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) + end + end + + local right_button = self._uiLayer:getWidgetByName("right_Button") + right_button:addTouchEventListener(nextCallback) + + local function menuCloseCallback( sender,eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + end + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function UILoadingBarLeftTest.create() + local scene = UILoadingBarLeftTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILoadingBarRightTest = class("UILoadingBarRightTest",UIScene) +UILoadingBarRightTest._count = 0 + +function UILoadingBarRightTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILoadingBarRightTest) + return target +end + +function UILoadingBarRightTest:initExtend() + + self._uiLayer = ccs.UILayer:create() + self:addChild(self._uiLayer) + + self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + back_label:setVisible(false) + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LoadingBar") + alert:setFontName(font_UILoadingBarTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local loadingBar = ccs.UILoadingBar:create() + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosgui/sliderProgress.png") + loadingBar:setDirection(ccs.LoadingBarType.right) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) + self._uiLayer:addWidget(loadingBar) + + local function update(delta) + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + local function previousCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) + end + end + + local left_button = self._uiLayer:getWidgetByName("left_Button") + left_button:addTouchEventListener(previousCallback) + + local function restartCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) + end + end + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + middle_button:addTouchEventListener(restartCallback) + + local function nextCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) + end + end + + local right_button = self._uiLayer:getWidgetByName("right_Button") + right_button:addTouchEventListener(nextCallback) + + local function menuCloseCallback( sender,eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + end + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function UILoadingBarRightTest.create() + local scene = UILoadingBarRightTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILoadingBarLeftScale9Test = class("UILoadingBarLeftScale9Test",UIScene) +UILoadingBarLeftScale9Test._count = 0 + +function UILoadingBarLeftScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILoadingBarLeftScale9Test) + return target +end + +function UILoadingBarLeftScale9Test:initExtend() + + self._uiLayer = ccs.UILayer:create() + self:addChild(self._uiLayer) + + self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + back_label:setVisible(false) + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LoadingBar Scale9 Render") + alert:setFontName(font_UILoadingBarTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local loadingBar = ccs.UILoadingBar:create() + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosgui/slider_bar_active_9patch.png") + loadingBar:setScale9Enabled(true) + loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) + loadingBar:setSize(cc.size(300, 30)) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) + self._uiLayer:addWidget(loadingBar) + + local function update(delta) + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + local function previousCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) + end + end + + local left_button = self._uiLayer:getWidgetByName("left_Button") + left_button:addTouchEventListener(previousCallback) + + local function restartCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) + end + end + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + middle_button:addTouchEventListener(restartCallback) + + local function nextCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) + end + end + + local right_button = self._uiLayer:getWidgetByName("right_Button") + right_button:addTouchEventListener(nextCallback) + + local function menuCloseCallback( sender,eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + end + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function UILoadingBarLeftScale9Test.create() + local scene = UILoadingBarLeftScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILoadingBarRightScale9Test = class("UILoadingBarRightScale9Test",UIScene) +UILoadingBarRightScale9Test._count = 0 + +function UILoadingBarRightScale9Test.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILoadingBarRightScale9Test) + return target +end + +function UILoadingBarRightScale9Test:initExtend() + + self._uiLayer = ccs.UILayer:create() + self:addChild(self._uiLayer) + + self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") + self._uiLayer:addWidget(self._widget) + + self._sceneTitle = self._uiLayer:getWidgetByName("UItest") + + local back_label = self._uiLayer:getWidgetByName("back") + back_label:setVisible(false) + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LoadingBar Scale9 Render") + alert:setFontName(font_UILoadingBarTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local loadingBar = ccs.UILoadingBar:create() + loadingBar:setName("LoadingBar") + loadingBar:loadTexture("cocosgui/slider_bar_active_9patch.png") + loadingBar:setScale9Enabled(true) + loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) + loadingBar:setSize(cc.size(300, 30)) + loadingBar:setDirection(ccs.LoadingBarType.right) + loadingBar:setPercent(0) + + loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) + self._uiLayer:addWidget(loadingBar) + + local function update(delta) + self._count = self._count + 1 + if self._count > 100 then + self._count = 0 + end + + if self._uiLayer ~= nil then + local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") + loadingBar:setPercent(self._count) + end + end + + self:scheduleUpdateWithPriorityLua(update, 0) + + local function onNodeEvent(tag) + if tag == "exit" then + self:unscheduleUpdate() + end + end + + self:registerScriptHandler(onNodeEvent) + + local function previousCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) + end + end + + local left_button = self._uiLayer:getWidgetByName("left_Button") + left_button:addTouchEventListener(previousCallback) + + local function restartCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) + end + end + + local middle_button = self._uiLayer:getWidgetByName("middle_Button") + middle_button:addTouchEventListener(restartCallback) + + local function nextCallback(sender, eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) + end + end + + local right_button = self._uiLayer:getWidgetByName("right_Button") + right_button:addTouchEventListener(nextCallback) + + local function menuCloseCallback( sender,eventType) + if eventType == ccs.TouchEventType.ended then + self:unscheduleUpdate() + self._uiLayer:removeFromParent() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + end + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function UILoadingBarRightScale9Test.create() + local scene = UILoadingBarRightScale9Test.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILabelAtlasTest = class("UILabelAtlasTest",UIScene) + +function UILabelAtlasTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILabelAtlasTest) + return target +end + +function UILabelAtlasTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LabelAtlas") + alert:setFontName(font_UILabelAtlasTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + + local labelAtlas = ccs.UILabelAtlas:create() + labelAtlas:setProperty("1234567890", "cocosgui/labelatlas.png", 17, 22, "0") + labelAtlas:setPosition(cc.p((widgetSize.width) / 2, widgetSize.height / 2.0)) + + self._uiLayer:addWidget(labelAtlas) +end + +function UILabelAtlasTest.create() + local scene = UILabelAtlasTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILabelBMFontTest = class("UILabelBMFontTest",UIScene) + +function UILabelBMFontTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILabelBMFontTest) + return target +end + +function UILabelBMFontTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("LabelBMFont") + alert:setFontName(font_UILabelBMFontTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + + local labelBMFont = ccs.UILabelBMFont:create() + labelBMFont:setFntFile("cocosgui/bitmapFontTest2.fnt") + labelBMFont:setText("BMFont") + labelBMFont:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2.0 + labelBMFont:getSize().height / 8.0)) + + self._uiLayer:addWidget(labelBMFont) +end + +function UILabelBMFontTest.create() + local scene = UILabelBMFontTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UILabelTest = class("UILabelTest",UIScene) + +function UILabelTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UILabelTest) + return target +end + +function UILabelTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("Label") + alert:setFontName(font_UILabelTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local label = ccs.UILabel:create() + label:setText("Label") + label:setFontName("AmericanTypewriter") + label:setFontSize(30) + label:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + label:getSize().height / 4)) + self._uiLayer:addWidget(label) +end + +function UILabelTest.create() + local scene = UILabelTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextAreaTest = class("UITextAreaTest",UIScene) + +function UITextAreaTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextAreaTest) + return target +end + +function UITextAreaTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("TextArea") + alert:setFontName(font_UITextAreaTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local textArea = ccs.UILabel:create() + textArea:setTextAreaSize(cc.size(280, 150)) + textArea:setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER) + textArea:setText("TextArea widget can line wrap") + textArea:setFontName("AmericanTypewriter") + textArea:setFontSize(32) + textArea:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - textArea:getSize().height / 8)) + self._uiLayer:addWidget(textArea) +end + +function UITextAreaTest.create() + local scene = UITextAreaTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextFieldTest = class("UITextFieldTest",UIScene) +UITextFieldTest._displayValueLabel = nil + +function UITextFieldTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextFieldTest) + return target +end + +function UITextFieldTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UITextFieldTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("TextField") + alert:setFontName(font_UITextFieldTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccs.TextFiledEventType.attach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0))) + self._displayValueLabel:setText("attach with IME") + elseif eventType == ccs.TextFiledEventType.detach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + self._displayValueLabel:setText("detach with IME") + elseif eventType == ccs.TextFiledEventType.insert_text then + self._displayValueLabel:setText("insert words") + elseif eventType == ccs.TextFiledEventType.delete_backward then + self._displayValueLabel:setText("delete word") + end + end + + local textField = ccs.UITextField:create() + textField:setTouchEnabled(true) + textField:setFontName(font_UITextFieldTest) + textField:setFontSize(30) + textField:setPlaceHolder("input words here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addWidget(textField) +end + +function UITextFieldTest.create() + local scene = UITextFieldTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextFieldMaxLengthTest = class("UITextFieldMaxLengthTest",UIScene) +UITextFieldMaxLengthTest._displayValueLabel = nil + +function UITextFieldMaxLengthTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextFieldMaxLengthTest) + return target +end + +function UITextFieldMaxLengthTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UITextFieldTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("TextField max length") + alert:setFontName(font_UITextFieldTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccs.TextFiledEventType.attach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0))) + local info = string.format("attach with IME max length %d",textField:getMaxLength()) + self._displayValueLabel:setText(info) + elseif eventType == ccs.TextFiledEventType.detach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + local info = string.format("detach with IME max length %d",textField:getMaxLength()) + self._displayValueLabel:setText(info) + elseif eventType == ccs.TextFiledEventType.insert_text then + local textField = tolua.cast(sender,"UITextField") + local info = string.format("insert words max length %d",textField:getMaxLength()) + self._displayValueLabel:setText(info) + elseif eventType == ccs.TextFiledEventType.delete_backward then + local textField = tolua.cast(sender,"UITextField") + local info = string.format("delete word max length %d",textField:getMaxLength()) + self._displayValueLabel:setText(info) + end + end + + local textField = ccs.UITextField:create() + textField:setMaxLengthEnabled(true) + textField:setMaxLength(3) + textField:setTouchEnabled(true) + textField:setFontName(font_UITextFieldTest) + textField:setFontSize(30) + textField:setPlaceHolder("input words here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addWidget(textField) +end + +function UITextFieldMaxLengthTest.create() + local scene = UITextFieldMaxLengthTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UITextFieldPasswordTest = class("UITextFieldPasswordTest",UIScene) +UITextFieldPasswordTest._displayValueLabel = nil + +function UITextFieldPasswordTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UITextFieldPasswordTest) + return target +end + +function UITextFieldPasswordTest:initExtend() + + self:init() + local widgetSize = self._widget:getSize() + + self._displayValueLabel = ccs.UILabel:create() + self._displayValueLabel:setText("No Event") + self._displayValueLabel:setFontName(font_UITextFieldTest) + self._displayValueLabel:setFontSize(32) + self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) + self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) + self._uiLayer:addWidget(self._displayValueLabel) + + local alert = ccs.UILabel:create() + alert:setText("TextField password") + alert:setFontName(font_UITextFieldTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local function textFieldEvent(sender, eventType) + if eventType == ccs.TextFiledEventType.attach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + self._displayValueLabel:setText("detach with IME password") + elseif eventType == ccs.TextFiledEventType.detach_with_ime then + local textField = tolua.cast(sender,"UITextField") + local screenSize = cc.Director:getInstance():getWinSize() + textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) + self._displayValueLabel:setText("detach with IME password") + elseif eventType == ccs.TextFiledEventType.insert_text then + self._displayValueLabel:setText("insert words password") + elseif eventType == ccs.TextFiledEventType.delete_backward then + self._displayValueLabel:setText("delete word password") + end + end + + local textField = ccs.UITextField:create() + textField:setPasswordEnabled(true) + textField:setPasswordStyleText("*") + textField:setTouchEnabled(true) + textField:setFontName(font_UITextFieldTest) + textField:setFontSize(30) + textField:setPlaceHolder("input password here") + textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) + textField:addEventListener(textFieldEvent) + self._uiLayer:addWidget(textField) +end + +function UITextFieldPasswordTest.create() + local scene = UITextFieldPasswordTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + +local UIPanelTest = class("UIPanelTest",UIScene) + +function UIPanelTest.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, UIPanelTest) + return target +end + +function UIPanelTest:initExtend() + + self:init() + + local widgetSize = self._widget:getSize() + + local alert = ccs.UILabel:create() + alert:setText("Panel") + alert:setFontName(font_UIPanelTest) + alert:setFontSize(30) + alert:setColor(cc.c3b(159, 168, 176)) + alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) + self._uiLayer:addWidget(alert) + + local background = self._uiLayer:getWidgetByName("background_Panel") + + local layout = ccs.UILayout:create() + layout:setSize(cc.size(280, 150)) + local backgroundSize = background:getSize() + layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + + (backgroundSize.width - layout:getSize().width) / 2, + (widgetSize.height - backgroundSize.height) / 2 + + (backgroundSize.height - layout:getSize().height) / 2)) + self._uiLayer:addWidget(layout) + + local button = ccs.UIButton:create() + button:setTouchEnabled(true) + button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") + button:setPosition(cc.p(button:getSize().width / 2, layout:getSize().height - button:getSize().height / 2)) + layout:addChild(button) + + local textButton = UIButton:create() + textButton:setTouchEnabled(true) + textButton:loadTextures("cocosgui/backtotopnormal.png", "cocosgui/backtotoppressed.png", "") + textButton:setTitleText("Text Button") + textButton:setPosition(cc.p(layout:getSize().width / 2, layout:getSize().height / 2)) + layout:addChild(textButton) + + local button_scale9 = UIButton:create() + button_scale9:setTouchEnabled(true) + button_scale9:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") + button_scale9:setScale9Enabled(true) + button_scale9:setSize(cc.size(100, button_scale9:getContentSize().height)) + button_scale9:setPosition(cc.p(layout:getSize().width - button_scale9:getSize().width / 2, button_scale9:getSize().height / 2)) + layout:addChild(button_scale9) +end + +function UIPanelTest.create() + local scene = UIPanelTest.extend(cc.Scene:create()) + scene:initExtend() + return scene +end + local cocoStudioGuiArray = { { title = "UIButtonTest", func = function () - --return new UIButtonTest() - print("come in UIButtonTest") - return cc.Scene:create() - end + return UIButtonTest.create() + end, }, - { - title = "UIButtonTest_Scale9", - func = function () - --return new UIButtonTest_Scale9(); - end - }, - -- { - -- title: "UIButtonTest_PressedAction", - -- -- func: function () { - -- -- return new UIButtonTest_PressedAction(); - -- -- } - -- }, - -- { - -- title: "UITextButtonTest", - -- -- func: function () { - -- -- return new UITextButtonTest(); - -- -- } - -- }, - -- { - -- title: "UITextButtonTest_Scale9", - -- -- func: function () { - -- -- return new UITextButtonTest_Scale9(); - -- -- } - -- }, - -- { - -- title: "UICheckBoxTest", - -- -- func: function () { - -- -- return new UICheckBoxTest(); - -- -- } - -- }, - -- { - -- title: "UISliderTest", - -- -- func: function () { - -- -- return new UISliderTest(); - -- -- } - -- }, - -- { - -- title: "UIButtonTest", - -- -- func: function () { - -- -- return new UISliderTest_Scale9(); - -- -- } - -- }, - -- { - -- title: "UIImageViewTest", - -- -- func: function () { - -- -- return new UIImageViewTest(); - -- -- } - -- }, - -- { - -- title: "UIImageViewTest_Scale9", - -- -- func: function () { - -- -- return new UIImageViewTest_Scale9(); - -- -- } - -- }, - -- { - -- title: "UILoadingBarTest_Left", - -- -- func: function () { - -- -- return new UILoadingBarTest_Left(); - -- -- } - -- }, - -- { - -- title: "UILoadingBarTest_Right", - -- -- func: function () { - -- -- return new UILoadingBarTest_Right(); - -- -- } - -- }, - -- { - -- title: "UILoadingBarTest_Left_Scale9", - -- -- func: function () { - -- -- return new UILoadingBarTest_Left_Scale9(); - -- -- } - -- }, - -- { - -- title: "UILoadingBarTest_Right_Scale9", - -- -- func: function () { - -- -- return new UILoadingBarTest_Right_Scale9(); - -- -- } - -- }, - -- { - -- title: "UILabelAtlasTest", - -- -- func: function () { - -- -- return new UILabelAtlasTest(); - -- -- } - -- }, - -- { - -- title: "UILabelTest", - -- -- func: function () { - -- -- return new UILabelTest(); - -- -- } - -- }, - -- { - -- title: "UITextAreaTest", - -- -- func: function () { - -- -- return new UITextAreaTest(); - -- -- } - -- }, - -- { - -- title: "UILabelBMFontTest", - -- -- func: function () { - -- -- return new UILabelBMFontTest(); - -- -- } - -- }, - -- { - -- title: "UITextFieldTest", - -- -- func: function () { - -- -- return new UITextFieldTest(); - -- -- } - -- }, - -- { - -- title: "UITextFieldTest_MaxLength", - -- -- func: function () { - -- -- return new UITextFieldTest_MaxLength(); - -- -- } - -- }, - -- { - -- title: "UITextFieldTest_Password", - -- -- func: function () { - -- -- return new UITextFieldTest_Password(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest", - -- -- func: function () { - -- -- return new UIPanelTest(); - -- -- } - -- }, - -- { title: "UIPanelTest_Color", - -- -- func: function () { - -- -- return new UIPanelTest_Color(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest_Gradient", - -- -- func: function () { - -- -- return new UIPanelTest_Gradient(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest_BackGroundImage", - -- -- func: function () { - -- -- return new UIPanelTest_BackGroundImage(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest_BackGroundImage_Scale9", - -- -- func: function () { - -- -- return new UIPanelTest_BackGroundImage_Scale9(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest_Layout_Linear_Vertical", - -- -- func: function () { - -- -- return new UIPanelTest_Layout_Linear_Vertical(); - -- -- } - -- }, - -- { - -- title: "UIPanelTest_Layout_Linear_Horizontal", - -- -- func: function () { - -- -- return new UIPanelTest_Layout_Linear_Horizontal(); - -- -- } - -- }, - -- { - -- title: "UIScrollViewTest_Vertical", - -- -- func: function () { - -- -- return new UIScrollViewTest_Vertical(); - -- -- } - -- }, - -- { - -- title: "UIScrollViewTest_Horizontal", - -- -- func: function () { - -- -- return new UIScrollViewTest_Horizontal(); - -- -- } - -- }, - -- { - -- title: "UIPageViewTest", - -- -- func: function () { - -- -- return new UIPageViewTest(); - -- -- } - -- }, - -- { - -- title: "UIListViewTest_Vertical", - -- -- func: function () { - -- -- return new UIListViewTest_Vertical(); - -- -- } - -- }, - -- { - -- title: "UIListViewTest_Horizontal", - -- -- func: function () { - -- -- return new UIListViewTest_Horizontal(); - -- -- } - -- }, - -- { - -- title: "UIDragPanelTest", - -- -- func: function () { - -- -- return new UIDragPanelTest(); - -- -- } - -- }, - -- { - -- title: "UIDragPanelTest_Bounce", - -- -- func: function () { - -- -- return new UIDragPanelTest_Bounce(); - -- -- } - -- }, - -- { - -- title: "UINodeContainerTest", - -- -- func: function () { - -- -- return new UINodeContainerTest(); - -- -- } - -- } -} -guiSceneManager = guiSceneManager or {} -guiSceneManager.currentUISceneIdx = 1 + { + title = "UIButtonScale9Test", + func = function () + return UIButtonScale9Test.create() + end, + }, + + { + title = "ButtonPressedActionTest", + func = function () + return UIButtonPressedActionTest.create() + end, + }, + + { + title = "UITextButtonTest", + func = function () + return UITextButtonTest.create() + end, + }, + + { + title = "UITextButtonScale9Test", + func = function () + return UITextButtonScale9Test.create() + end, + }, + + { + title = "UICheckBoxTest", + func = function () + return UICheckBoxTest.create() + end, + }, + + { + title = "UISliderTest", + func = function () + return UISliderTest.create() + end, + }, + + { + title = "UISliderScale9Test", + func = function () + return UISliderScale9Test.create() + end, + }, + + { + title = "UIImageViewTest", + func = function ( ) + return UIImageViewTest.create() + end, + }, + + { + title = "UIImageViewScale9Test", + func = function ( ) + return UIImageViewScale9Test.create() + end, + }, + + { + title = "UILoadingBarLeftTest", + func = function ( ) + return UILoadingBarLeftTest.create() + end, + }, + + { + title = "UILoadingBarRightTest", + func = function ( ) + return UILoadingBarRightTest.create() + end, + }, + + { + title = "UILoadingBarLeftScale9Test", + func = function ( ) + return UILoadingBarLeftScale9Test.create() + end, + }, + + { + title = "UILoadingBarRightScale9Test", + func = function ( ) + return UILoadingBarRightScale9Test.create() + end, + }, + + { + title = "UILabelAtlasTest", + func = function ( ) + return UILabelAtlasTest.create() + end, + }, + + { + title = "UILabelBMFontTest", + func = function ( ) + return UILabelBMFontTest.create() + end, + }, + + { + title = "UILabelTest", + func = function ( ) + return UILabelTest.create() + end, + }, + + { + title = "UITextAreaTest", + func = function ( ) + return UITextAreaTest.create() + end, + }, + + { + title = "UITextFieldTest", + func = function ( ) + return UITextFieldTest.create() + end, + }, + + { + title = "UITextFieldMaxLengthTest", + func = function ( ) + return UITextFieldMaxLengthTest.create() + end, + }, + + { + title = "UITextFieldPasswordTest", + func = function ( ) + return UITextFieldPasswordTest.create() + end, + }, + + { + title = "UIPanelTest", + func = function ( ) + return UIPanelTest.create() + end, + }, + + { + title = "UIPanelColorTest", + func = function ( ) + return UIPanelColorTest.create() + end, + }, + + { + title = "UIPanelGradientTest", + func = function ( ) + return UIPanelGradientTest.create() + end, + }, +} function guiSceneManager.nextUIScene() guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray) - if 1 == guiSceneManager.currentUISceneIdx then + if 0 == guiSceneManager.currentUISceneIdx then guiSceneManager.currentUISceneIdx = table.getn(cocoStudioGuiArray) end @@ -245,22 +1810,9 @@ function guiSceneManager.currentUIScene() return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() end -function guiSceneManager:getInstance() - local gsMgr = _G.guiSceneManager - if gsMgr then return gsMgr end - - gsMgr = {} - _G.guiSceneManager = gsMgr - setmetatable(o, self) - self.__index = self - return gsMgr -end - -function guiSceneManager:purge() - _G.guiSceneManager = nil -end + function runCocosGUITestScene() - local scene = guiSceneManager:getInstance().currentUIScene() + local scene = guiSceneManager.currentUIScene() cc.Director:getInstance():replaceScene(scene) end diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua deleted file mode 100644 index eaa574baac..0000000000 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/UIScene.lua +++ /dev/null @@ -1,71 +0,0 @@ -UIScene = class("UIScene") -UIScene.__index = UIScene -UIScene._uiLayer= nil -UIScene._widget=nil -UIScene._sceneTitle=nil -UIScene._topDisplayLabel=nil -UIScene._bottomDisplayLabel=nil - -function UIScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScene) - return target -end - -function UIScene:init() - self._uiLayer = ccs.UILayer:create() - self._uiLayer:scheduleUpdate() - self:addChild(this._uiLayer) - - self._widget = ccs.UIHelper:getInstance():createWidgetFromJsonFile("res/cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - --back_label:addTouchEventListener(this.toExtensionsMainLayer, this) - - local left_button = self._uiLayer:getWidgetByName("left_Button") - --left_button:addTouchEventListener(this.previousCallback ,this) - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - --middle_button.addTouchEventListener(this.restartCallback ,this) - - local right_button = self._uiLayer:getWidgetByName("right_Button") - --right_button.addTouchEventListener(this.nextCallback ,this) - - local winSize = cc.Director:getInstance():getWinSize() - local scale = winSize.height / 320 - self._uiLayer:setAnchorPoint(cc.p(0,0)) - self._uiLayer:setScale(scale) - self._uiLayer:setPosition(cc.p((winSize.width - 480 * scale) / 2, (winSize.height - 320 * scale) / 2)) - - local widgetSize = self._widget.getRect().size - local eventLabel = ccs.UILabel:create() - eventLabel:setText("") - eventLabel:setFontName("Marker Felt") - eventLabel:setFontSize(32) - eventLabel:setAnchorPoint(cc.p(0.5, -1)) - eventLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(eventLabel) - self._topDisplayLabel = eventLabel - - local uiLabel = ccs.UILabel:create() - uiLabel:setText("") - uiLabel:setFontName("Marker Felt") - uiLabel:setFontSize(30) - uiLabel:setColor(cc.c3b(159, 168, 176)) - uiLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - uiLabel.getRect().size.height * 1.75)) - self._uiLayer.addWidget(uiLabel) - self._bottomDisplayLabel = uiLabel -end - -function UIScene.create() - local scene = UIScene.extend(cc.Scene:create()) - scene:init() - return scene -end \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 8b2478ad82..efa249a6a9 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -4,6 +4,7 @@ require "Cocos2d" require "Cocos2dConstants" require "Opengl" require "OpenglConstants" +require "StudioConstants" require "luaScript/helper" require "luaScript/testResource" require "luaScript/VisibleRect" diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 0f4ea3ffbf..5c40f4fade 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget Layout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter CCSGUIReader # 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 @@ -44,10 +44,12 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* Bone::[(s|g)etIgnoreMovementBoneData], UILayer::[getInputManager], UILayoutParameter::[(s|g)etMargin], - UIHelper::[init] + UIHelper::[init], + CCSGUIReader::[setPropsForImageButtonFromJsonDictionary] rename_functions = UIHelper::[instance=getInstance], - ArmatureDataManager::[sharedArmatureDataManager=getInstance] + ArmatureDataManager::[sharedArmatureDataManager=getInstance], + CCSGUIReader::[shareReader=getInstance] rename_classes = From 394f4e703b068ebb83e17fe23cd3b939238e499d Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 17:06:32 +0800 Subject: [PATCH 099/185] Reverting AssetsManager::update. --- extensions/assets-manager/AssetsManager.cpp | 2 +- extensions/assets-manager/AssetsManager.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index 06e5bd11c6..4913e5efd0 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -214,7 +214,7 @@ void AssetsManager::downloadAndUncompress() _isDownloading = false; } -void AssetsManager::update(float delta) +void AssetsManager::update() { if (_isDownloading) return; diff --git a/extensions/assets-manager/AssetsManager.h b/extensions/assets-manager/AssetsManager.h index 5608084c76..f3e413f4bd 100644 --- a/extensions/assets-manager/AssetsManager.h +++ b/extensions/assets-manager/AssetsManager.h @@ -98,7 +98,7 @@ public: /* @brief Download new package if there is a new version, and uncompress downloaded zip file. * Ofcourse it will set search path that stores downloaded files. */ - virtual void update(float delta) override; + virtual void update(); /* @brief Gets url of package. */ From 1e15071dc7465020facc3756a97694875d7a75a7 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Nov 2013 17:29:48 +0800 Subject: [PATCH 100/185] remove makefiles --- build/Makefile | 91 ----- build/make-all-linux-project.sh | 24 -- cocos/2d/Makefile | 204 ----------- cocos/audio/CMakeLists.txt | 11 + cocos/audio/proj.linux/.cproject | 378 ------------------- cocos/audio/proj.linux/.project | 100 ----- cocos/audio/proj.linux/CocosDenshion.prf | 20 - cocos/audio/proj.linux/Makefile | 49 --- cocos/editor-support/cocosbuilder/Makefile | 44 --- cocos/editor-support/cocostudio/Makefile | 69 ---- cocos/editor-support/spine/Makefile | 42 --- cocos/gui/Makefile | 43 --- cocos/network/Makefile | 22 -- cocos/scripting/lua/bindings/Makefile | 94 ----- extensions/proj.linux/.cproject | 404 --------------------- extensions/proj.linux/.project | 90 ----- extensions/proj.linux/Makefile | 49 --- external/Box2D/proj.linux/.cproject | 267 -------------- external/Box2D/proj.linux/.project | 110 ------ external/Box2D/proj.linux/Makefile | 72 ---- external/Box2D/proj.linux/box2d.prf | 19 - external/chipmunk/proj.linux/.cproject | 236 ------------ external/chipmunk/proj.linux/.project | 95 ----- external/chipmunk/proj.linux/Makefile | 47 --- external/chipmunk/proj.linux/chipmunk.prf | 19 - 25 files changed, 11 insertions(+), 2588 deletions(-) delete mode 100644 build/Makefile delete mode 100755 build/make-all-linux-project.sh delete mode 100644 cocos/2d/Makefile delete mode 100644 cocos/audio/proj.linux/.cproject delete mode 100644 cocos/audio/proj.linux/.project delete mode 100644 cocos/audio/proj.linux/CocosDenshion.prf delete mode 100644 cocos/audio/proj.linux/Makefile delete mode 100644 cocos/editor-support/cocosbuilder/Makefile delete mode 100644 cocos/editor-support/cocostudio/Makefile delete mode 100644 cocos/editor-support/spine/Makefile delete mode 100644 cocos/gui/Makefile delete mode 100644 cocos/network/Makefile delete mode 100644 cocos/scripting/lua/bindings/Makefile delete mode 100644 extensions/proj.linux/.cproject delete mode 100644 extensions/proj.linux/.project delete mode 100644 extensions/proj.linux/Makefile delete mode 100644 external/Box2D/proj.linux/.cproject delete mode 100644 external/Box2D/proj.linux/.project delete mode 100644 external/Box2D/proj.linux/Makefile delete mode 100644 external/Box2D/proj.linux/box2d.prf delete mode 100644 external/chipmunk/proj.linux/.cproject delete mode 100644 external/chipmunk/proj.linux/.project delete mode 100644 external/chipmunk/proj.linux/Makefile delete mode 100644 external/chipmunk/proj.linux/chipmunk.prf diff --git a/build/Makefile b/build/Makefile deleted file mode 100644 index 761855d264..0000000000 --- a/build/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -PLATFORM ?= linux - -all: - -chipmunk: - $(MAKE) -C ../external/chipmunk/proj.$(PLATFORM) -chipmunk-clean: - $(MAKE) -C ../external/chipmunk/proj.$(PLATFORM) clean - -box2d: - $(MAKE) -C ../external/Box2D/proj.$(PLATFORM) -box2d-clean: - $(MAKE) -C ../external/Box2D/proj.$(PLATFORM) clean - -cocos2dx: chipmunk - $(MAKE) -C ../cocos/2d -cocos2dx-clean: - $(MAKE) -C ../cocos/2d clean - -audio: cocos2dx - $(MAKE) -C ../cocos/audio/proj.$(PLATFORM) -audio-clean: - $(MAKE) -C ../cocos/audio/proj.$(PLATFORM) clean - -gui: - $(MAKE) -C ../cocos/gui -gui-clean: - $(MAKE) -C ../cocos/gui clean - -network: cocos2dx - $(MAKE) -C ../cocos/network -network-clean: - $(MAKE) -C ../cocos/network clean - -cocosbuilder: - $(MAKE) -C ../cocos/editor-support/cocosbuilder -cocosbuilder-clean: - $(MAKE) -C ../cocos/editor-support/cocosbuilder clean - -spine: - $(MAKE) -C ../cocos/editor-support/spine -spine-clean: - $(MAKE) -C ../cocos/editor-support/spine clean - -cocostudio: - $(MAKE) -C ../cocos/editor-support/cocostudio -cocostudio-clean: - $(MAKE) -C ../cocos/editor-support/cocostudio clean - -extensions: chipmunk audio box2d - $(MAKE) -C ../extensions/proj.$(PLATFORM) -extensions-clean: - $(MAKE) -C ../extensions/proj.$(PLATFORM) clean - -lua: extensions cocosbuilder cocostudio - $(MAKE) -C ../cocos/scripting/lua/bindings -lua-clean: - $(MAKE) -C ../cocos/scripting/lua/bindings clean - -hellocpp: cocos2dx - $(MAKE) -C ../samples/Cpp/HelloCpp/proj.$(PLATFORM) -hellocpp-clean: - $(MAKE) -C ../samples/Cpp/HelloCpp/proj.$(PLATFORM) clean - -testcpp: cocos2dx audio extensions cocostudio gui cocosbuilder spine network - $(MAKE) -C ../samples/Cpp/TestCpp/proj.$(PLATFORM) -testcpp-clean: - $(MAKE) -C ../samples/Cpp/TestCpp/proj.$(PLATFORM) clean - -simplegame: cocos2dx audio - $(MAKE) -C ../samples/Cpp/SimpleGame/proj.$(PLATFORM) -simplegame-clean: - $(MAKE) -C ../samples/Cpp/SimpleGame/proj.$(PLATFORM) clean - -all: chipmunk audio extensions cocos2dx lua hellocpp testcpp simplegame -clean: cocos2dx-clean box2d-clean chipmunk-clean audio-clean extensions-clean lua-clean hellocpp-clean testcpp-clean simplegame-clean - -hellolua: cocos2dx lua - $(MAKE) -C ../samples/Lua/HelloLua/proj.$(PLATFORM) -hellolua-clean: - $(MAKE) -C ../samples/Lua/HelloLua/proj.$(PLATFORM) clean - -testlua: cocos2dx lua - $(MAKE) -C ../samples/Lua/TestLua/proj.$(PLATFORM) -testlua-clean: - $(MAKE) -C ../samples/Lua/TestLua/proj.$(PLATFORM) clean - -all: hellolua testlua -clean: hellolua-clean testlua-clean - -.PHONY: all clean diff --git a/build/make-all-linux-project.sh b/build/make-all-linux-project.sh deleted file mode 100755 index 98eaeef714..0000000000 --- a/build/make-all-linux-project.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# This script will perform a clean linux build of all targets in both -# debug and release configurations. It will also ensure that all the required -# packages are installed. For day-to-day work on the linux port it is -# faster/better to simply use 'make' either at the top level or in the subpject -# you are working on. - -# Exit of first error. -set -e - -# Change directory to the location of this script -cd $(dirname ${BASH_SOURCE[0]}) - -[ -z "$COCOS2DX_USEAPT" ] && COCOS2DX_USEAPT=true - -if $COCOS2DX_USEAPT; then - ./install-deps-linux.sh -fi - -mkdir -p linux-build -cd linux-build -cmake ../.. -make -j10 - diff --git a/cocos/2d/Makefile b/cocos/2d/Makefile deleted file mode 100644 index 3e711d5d20..0000000000 --- a/cocos/2d/Makefile +++ /dev/null @@ -1,204 +0,0 @@ -TARGET = libcocos2d.so - -INCLUDES = - -SOURCES = \ -CCAction.cpp \ -CCActionCamera.cpp \ -CCActionEase.cpp \ -CCActionGrid.cpp \ -CCActionGrid3D.cpp \ -CCActionInstant.cpp \ -CCActionInterval.cpp \ -CCActionManager.cpp \ -CCActionPageTurn3D.cpp \ -CCActionProgressTimer.cpp \ -CCActionTiledGrid.cpp \ -CCActionCatmullRom.cpp \ -CCActionTween.cpp \ -CCAtlasNode.cpp \ -CCNode.cpp \ -../base/CCAffineTransform.cpp \ -../base/CCAutoreleasePool.cpp \ -../base/CCGeometry.cpp \ -../base/CCNS.cpp \ -../base/CCObject.cpp \ -../base/CCSet.cpp \ -../base/CCArray.cpp \ -../base/CCDictionary.cpp \ -../base/CCString.cpp \ -../base/CCDataVisitor.cpp \ -../base/CCData.cpp \ -CCEventAcceleration.cpp \ -CCEventListenerAcceleration.cpp \ -CCEvent.cpp \ -CCEventDispatcher.cpp \ -CCEventListener.cpp \ -CCEventKeyboard.cpp \ -CCEventListenerKeyboard.cpp \ -CCEventMouse.cpp \ -CCEventListenerMouse.cpp \ -CCTouch.cpp \ -CCEventTouch.cpp \ -CCEventListenerTouch.cpp \ -CCEventCustom.cpp \ -CCEventListenerCustom.cpp \ -CCDrawingPrimitives.cpp \ -CCDrawNode.cpp \ -CCGrabber.cpp \ -CCGrid.cpp \ -CCFont.cpp \ -CCFontAtlas.cpp \ -CCFontAtlasCache.cpp \ -CCFontAtlasFactory.cpp \ -CCFontDefinition.cpp \ -CCFontFNT.cpp \ -CCFontFreeType.cpp \ -CCLabel.cpp \ -CCLabelAtlas.cpp \ -CCLabelBMFont.cpp \ -CCLabelTTF.cpp \ -CCLabelTextFormatter.cpp \ -CCTextImage.cpp \ -CCLayer.cpp \ -CCScene.cpp \ -CCTransition.cpp \ -CCTransitionPageTurn.cpp \ -CCTransitionProgress.cpp \ -CCMenu.cpp \ -CCMenuItem.cpp \ -CCMotionStreak.cpp \ -CCProgressTimer.cpp \ -CCClippingNode.cpp \ -CCRenderTexture.cpp \ -CCParticleExamples.cpp \ -CCParticleSystem.cpp \ -CCParticleSystemQuad.cpp \ -CCParticleBatchNode.cpp \ -../physics/box2d/CCPhysicsContactInfo_box2d.cpp \ -../physics/box2d/CCPhysicsJointInfo_box2d.cpp \ -../physics/box2d/CCPhysicsShapeInfo_box2d.cpp \ -../physics/box2d/CCPhysicsBodyInfo_box2d.cpp \ -../physics/box2d/CCPhysicsWorldInfo_box2d.cpp \ -../physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \ -../physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \ -../physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp \ -../physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp \ -../physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \ -../physics/CCPhysicsBody.cpp \ -../physics/CCPhysicsContact.cpp \ -../physics/CCPhysicsShape.cpp \ -../physics/CCPhysicsJoint.cpp \ -../physics/CCPhysicsWorld.cpp \ -../platform/CCSAXParser.cpp \ -../platform/CCThread.cpp \ -../platform/CCEGLViewProtocol.cpp \ -../platform/CCFileUtils.cpp \ -../platform/linux/CCStdC.cpp \ -../platform/linux/CCFileUtilsLinux.cpp \ -../platform/linux/CCCommon.cpp \ -../platform/linux/CCApplication.cpp \ -../platform/linux/CCEGLView.cpp \ -../platform/linux/CCImage.cpp \ -../platform/linux/CCDevice.cpp \ -../base/etc1.cpp \ -../base/s3tc.cpp \ -../base/atitc.cpp \ -CCScriptSupport.cpp \ -CCAnimation.cpp \ -CCAnimationCache.cpp \ -CCSprite.cpp \ -CCSpriteBatchNode.cpp \ -CCSpriteFrame.cpp \ -CCSpriteFrameCache.cpp \ -ccUTF8.cpp \ -CCProfiling.cpp \ -CCUserDefault.cpp \ -TransformUtils.cpp \ -base64.cpp \ -ccUtils.cpp \ -CCVertex.cpp \ -CCNotificationCenter.cpp \ -TGAlib.cpp \ -../../external/tinyxml2/tinyxml2.cpp \ -ZipUtils.cpp \ -../../external/unzip/ioapi.cpp \ -../../external/unzip/unzip.cpp \ -ccCArray.cpp \ -CCComponent.cpp \ -CCComponentContainer.cpp \ -CCIMEDispatcher.cpp \ -CCTextFieldTTF.cpp \ -CCTexture2D.cpp \ -CCTextureAtlas.cpp \ -CCTextureCache.cpp \ -CCParallaxNode.cpp \ -CCTMXLayer.cpp \ -CCTMXObjectGroup.cpp \ -CCTMXTiledMap.cpp \ -CCTMXXMLParser.cpp \ -CCTileMapAtlas.cpp \ -CCGLProgram.cpp \ -ccGLStateCache.cpp \ -CCShaderCache.cpp \ -ccShaders.cpp \ -../math/kazmath/src/aabb.c \ -../math/kazmath/src/plane.c \ -../math/kazmath/src/vec2.c \ -../math/kazmath/src/mat3.c \ -../math/kazmath/src/quaternion.c \ -../math/kazmath/src/vec3.c \ -../math/kazmath/src/mat4.c \ -../math/kazmath/src/ray2.c \ -../math/kazmath/src/vec4.c \ -../math/kazmath/src/neon_matrix_impl.c \ -../math/kazmath/src/utility.c \ -../math/kazmath/src/GL/mat4stack.c \ -../math/kazmath/src/GL/matrix.c \ -CCCamera.cpp \ -CCConfiguration.cpp \ -CCDirector.cpp \ -CCScheduler.cpp \ -ccFPSImages.c \ -ccTypes.cpp \ -cocos2d.cpp \ -CCDeprecated.cpp - -COCOS_ROOT = ../.. - -include cocos2dx.mk - -CXXFLAGS += -Wno-sequence-point -CCFLAGS += -Wno-sequence-point - -STATICLIBS += $(LIB_DIR)/libchipmunk.a - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - - diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 12fde54f25..2f1d642cb2 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -3,6 +3,17 @@ set(AUDIO_SRC linux/FmodAudioPlayer.cpp ) +# architecture +if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +set(ARCH_DIR "64-bit") +else() +set(ARCH_DIR "32-bit") +endif() + +include_directories( + ../../external/linux-specific/fmod/include/${ARCH_DIR} +) + add_library(audio STATIC ${AUDIO_SRC} ) diff --git a/cocos/audio/proj.linux/.cproject b/cocos/audio/proj.linux/.cproject deleted file mode 100644 index fc010e1ed7..0000000000 --- a/cocos/audio/proj.linux/.cproject +++ /dev/null @@ -1,378 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cocos/audio/proj.linux/.project b/cocos/audio/proj.linux/.project deleted file mode 100644 index 2860d8d849..0000000000 --- a/cocos/audio/proj.linux/.project +++ /dev/null @@ -1,100 +0,0 @@ - - - libCocosDenshion - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/CocosDenshion/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - include - 2 - PARENT-1-PROJECT_LOC/include - - - linux - 2 - PARENT-1-PROJECT_LOC/linux - - - third_party - 2 - PARENT-1-PROJECT_LOC/third_party - - - diff --git a/cocos/audio/proj.linux/CocosDenshion.prf b/cocos/audio/proj.linux/CocosDenshion.prf deleted file mode 100644 index 4c7ec10f0c..0000000000 --- a/cocos/audio/proj.linux/CocosDenshion.prf +++ /dev/null @@ -1,20 +0,0 @@ -################################################################################ -# Do not include this file in your project: see cocos2dx.pri. -################################################################################ - -linux { - # We will compile extensions on demand using Makefile. - build_CocosDension.name = Build extension static library - build_CocosDension.input = $$PWD/Makefile - build_CocosDension.output = $$CC_LIBRARY_DIR/libcocosdenshion.so - build_CocosDension.target = $$CC_LIBRARY_DIR/libcocosdenshion.so - build_CocosDension.CONFIG = no_link target_predeps - build_CocosDension.commands = cd $$PWD && make $$CC_MAKE_FLAGS - - QMAKE_EXTRA_COMPILERS += build_CocosDension - QMAKE_EXTRA_TARGETS += build_CocosDension - - PRE_TARGETDEPS += $$CC_LIBRARY_DIR/libcocosdenshion.so - LIBS += -lcocosdenshion -} - diff --git a/cocos/audio/proj.linux/Makefile b/cocos/audio/proj.linux/Makefile deleted file mode 100644 index e8b18e3972..0000000000 --- a/cocos/audio/proj.linux/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -TARGET = libcocosdenshion.so - -INCLUDES = -I.. -I../include - -##Using OpenAL -ifeq ($(OPENAL),1) -SOURCES = ../openal/OpenALDecoder.cpp \ - ../openal/SimpleAudioEngineOpenAL.cpp -SHAREDLIBS += -lopenal -lalut - -ifeq ($(OPENAL_MP3),1) -DEFINES += -DENABLE_MPG123 -SHAREDLIBS += -lmpg123 -endif - -ifneq ($(NOVORBIS),1) -SHAREDLIBS += -logg -lvorbis -lvorbisfile -else -DEFINES += -DDISABLE_VORBIS -endif - -##Using FMOD -else -SOURCES = \ - ../linux/SimpleAudioEngineFMOD.cpp \ - ../linux/FmodAudioPlayer.cpp - -ifeq ($(LBITS),64) -INCLUDES += -I../third-party/fmod/lib64/api/inc -else -INCLUDES += -I../third-party/fmod/api/inc -endif - -endif - -COCOS_ROOT = ../../.. -include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/cocos/editor-support/cocosbuilder/Makefile b/cocos/editor-support/cocosbuilder/Makefile deleted file mode 100644 index 688c5d49d5..0000000000 --- a/cocos/editor-support/cocosbuilder/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -TARGET = libcocosbuilder.a - -INCLUDES = - -SOURCES = CCBFileLoader.cpp \ -CCMenuItemImageLoader.cpp \ -CCBReader.cpp \ -CCMenuItemLoader.cpp \ -CCControlButtonLoader.cpp \ -CCNodeLoader.cpp \ -CCControlLoader.cpp \ -CCNodeLoaderLibrary.cpp \ -CCLabelBMFontLoader.cpp \ -CCParticleSystemQuadLoader.cpp \ -CCLabelTTFLoader.cpp \ -CCScale9SpriteLoader.cpp \ -CCLayerColorLoader.cpp \ -CCScrollViewLoader.cpp \ -CCLayerGradientLoader.cpp \ -CCSpriteLoader.cpp \ -CCLayerLoader.cpp \ -CCBAnimationManager.cpp \ -CCBKeyframe.cpp \ -CCBSequence.cpp \ -CCBSequenceProperty.cpp \ -CCBValue.cpp \ -CCNode+CCBRelativePositioning.cpp - -include ../../2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - diff --git a/cocos/editor-support/cocostudio/Makefile b/cocos/editor-support/cocostudio/Makefile deleted file mode 100644 index 810c28372e..0000000000 --- a/cocos/editor-support/cocostudio/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -TARGET = libcocostudio.a - -COCOS_ROOT=../../.. - -INCLUDES = -I../../2d \ --I../../../external \ --I.. \ --I../.. \ - -SOURCES = CCActionFrame.cpp \ -CCActionFrameEasing.cpp \ -CCActionManagerEx.cpp \ -CCActionNode.cpp \ -CCActionObject.cpp \ -CCArmature.cpp \ -CCBone.cpp \ -CCArmatureAnimation.cpp \ -CCProcessBase.cpp \ -CCTween.cpp \ -CCDatas.cpp \ -CCBatchNode.cpp \ -CCDecorativeDisplay.cpp \ -CCDisplayFactory.cpp \ -CCDisplayManager.cpp \ -CCSkin.cpp \ -CCColliderDetector.cpp \ -CCArmatureDataManager.cpp \ -CCArmatureDefine.cpp \ -CCDataReaderHelper.cpp \ -CCSpriteFrameCacheHelper.cpp \ -CCTransformHelp.cpp \ -CCTweenFunction.cpp \ -CCUtilMath.cpp \ -CCComAttribute.cpp \ -CCComAudio.cpp \ -CCComController.cpp \ -CCComRender.cpp \ -CCInputDelegate.cpp \ -CSContentJsonDictionary.cpp \ -DictionaryHelper.cpp \ -CCSGUIReader.cpp \ -CCSSceneReader.cpp \ -../../../external/json/json_reader.cpp \ -../../../external/json/json_value.cpp \ -../../../external/json/json_writer.cpp - -include ../../2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../../../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/editor-support/spine/Makefile b/cocos/editor-support/spine/Makefile deleted file mode 100644 index 88514a824e..0000000000 --- a/cocos/editor-support/spine/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -TARGET = libspine.a - -INCLUDES = -I.. - -SOURCES = Animation.cpp \ -AnimationState.cpp \ -AnimationStateData.cpp \ -Atlas.cpp \ -AtlasAttachmentLoader.cpp \ -Attachment.cpp \ -AttachmentLoader.cpp \ -Bone.cpp \ -BoneData.cpp \ -Json.cpp \ -RegionAttachment.cpp \ -Skeleton.cpp \ -SkeletonData.cpp \ -SkeletonJson.cpp \ -Skin.cpp \ -Slot.cpp \ -SlotData.cpp \ -extension.cpp \ -spine-cocos2dx.cpp \ -CCSkeleton.cpp \ -CCSkeletonAnimation.cpp - -include ../../2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - diff --git a/cocos/gui/Makefile b/cocos/gui/Makefile deleted file mode 100644 index 8dcb0cb404..0000000000 --- a/cocos/gui/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -TARGET = libgui.a - -INCLUDES = -I../ \ --I../editor-support \ --I../../external - -SOURCES = UIRootWidget.cpp \ -UIWidget.cpp \ -UILayout.cpp \ -UILayoutParameter.cpp \ -UILayoutDefine.cpp \ -CocosGUI.cpp \ -UIHelper.cpp \ -UIInputManager.cpp \ -UILayer.cpp \ -UIListView.cpp \ -UIPageView.cpp \ -UIScrollView.cpp \ -UIButton.cpp \ -UICheckBox.cpp \ -UIImageView.cpp \ -UILabel.cpp \ -UILabelAtlas.cpp \ -UILabelBMFont.cpp \ -UILoadingBar.cpp \ -UISlider.cpp \ -UITextField.cpp - -include ../2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/network/Makefile b/cocos/network/Makefile deleted file mode 100644 index 029078722d..0000000000 --- a/cocos/network/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = libnetwork.a - -INCLUDES = -I.. - -SOURCES = HttpClient.cpp \ -SocketIO.cpp - -include ../2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos/scripting/lua/bindings/Makefile b/cocos/scripting/lua/bindings/Makefile deleted file mode 100644 index 546ad977b4..0000000000 --- a/cocos/scripting/lua/bindings/Makefile +++ /dev/null @@ -1,94 +0,0 @@ -TARGET = liblua.so - -INCLUDES += -I../../../../external/lua/tolua \ --I../../../../external/lua/lua \ --I../../auto-generated/lua-bindings \ --I../../../../extensions \ --I../../../editor-support \ --I. \ --I../../../editor-support/cocosbuilder \ --I../../../editor-support/cocostudio \ --I../../../../external \ --I../../../ - -SOURCES = ../../../../external/lua/lua/lapi.c \ - ../../../../external/lua/lua/lauxlib.c \ - ../../../../external/lua/lua/lbaselib.c \ - ../../../../external/lua/lua/lcode.c \ - ../../../../external/lua/lua/ldblib.c \ - ../../../../external/lua/lua/ldebug.c \ - ../../../../external/lua/lua/ldo.c \ - ../../../../external/lua/lua/ldump.c \ - ../../../../external/lua/lua/lfunc.c \ - ../../../../external/lua/lua/lgc.c \ - ../../../../external/lua/lua/linit.c \ - ../../../../external/lua/lua/liolib.c \ - ../../../../external/lua/lua/llex.c \ - ../../../../external/lua/lua/lmathlib.c \ - ../../../../external/lua/lua/lmem.c \ - ../../../../external/lua/lua/loadlib.c \ - ../../../../external/lua/lua/lobject.c \ - ../../../../external/lua/lua/lopcodes.c \ - ../../../../external/lua/lua/loslib.c \ - ../../../../external/lua/lua/lparser.c \ - ../../../../external/lua/lua/lstate.c \ - ../../../../external/lua/lua/lstring.c \ - ../../../../external/lua/lua/lstrlib.c \ - ../../../../external/lua/lua/ltable.c \ - ../../../../external/lua/lua/ltablib.c \ - ../../../../external/lua/lua/ltm.c \ - ../../../../external/lua/lua/lundump.c \ - ../../../../external/lua/lua/lvm.c \ - ../../../../external/lua/lua/lzio.c \ - ../../../../external/lua/lua/print.c \ - ../../../../external/lua/tolua/tolua_event.c \ - ../../../../external/lua/tolua/tolua_is.c \ - ../../../../external/lua/tolua/tolua_map.c \ - ../../../../external/lua/tolua/tolua_push.c \ - ../../../../external/lua/tolua/tolua_to.c \ - tolua_fix.c \ - ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ - ../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \ - CCLuaBridge.cpp \ - CCLuaEngine.cpp \ - CCLuaStack.cpp \ - CCLuaValue.cpp \ - Cocos2dxLuaLoader.cpp \ - CCBProxy.cpp \ - LuaOpengl.cpp \ - LuaScriptHandlerMgr.cpp \ - LuaBasicConversions.cpp \ - lua_cocos2dx_manual.cpp \ - lua_cocos2dx_extension_manual.cpp \ - lua_cocos2dx_deprecated.cpp \ - lua_xml_http_request.cpp - - -include ../../../2d/cocos2dx.mk - -TARGET := $(LIB_DIR)/$(TARGET) -SHAREDLIBS += -lextension -lcocostudio -lcocosbuilder -STATICLIBS += $(LIB_DIR)/libbox2d.a - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../../../../%.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/extensions/proj.linux/.cproject b/extensions/proj.linux/.cproject deleted file mode 100644 index 696f0898ce..0000000000 --- a/extensions/proj.linux/.cproject +++ /dev/null @@ -1,404 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/proj.linux/.project b/extensions/proj.linux/.project deleted file mode 100644 index 37e93964dd..0000000000 --- a/extensions/proj.linux/.project +++ /dev/null @@ -1,90 +0,0 @@ - - - libextension - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - CCBReader - 2 - PARENT-1-PROJECT_LOC/CCBReader - - - CCArmature - 2 - PARENT-1-PROJECT_LOC/CCArmature - - - Components - 2 - PARENT-1-PROJECT_LOC/Components - - - spine - 2 - PARENT-1-PROJECT_LOC/spine - - - ExtensionMacros.h - 1 - PARENT-1-PROJECT_LOC/ExtensionMacros.h - - - GUI - 2 - PARENT-1-PROJECT_LOC/GUI - - - LocalStorage - 2 - PARENT-1-PROJECT_LOC/LocalStorage - - - cocos-ext.h - 1 - PARENT-1-PROJECT_LOC/cocos-ext.h - - - network - 2 - PARENT-1-PROJECT_LOC/network - - - physics_nodes - 2 - PARENT-1-PROJECT_LOC/physics_nodes - - - - - 1373359750543 - - 22 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-WebSocket.* - - - - diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile deleted file mode 100644 index fe07e988e5..0000000000 --- a/extensions/proj.linux/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -TARGET = libextension.a - -INCLUDES = -I.. - -SOURCES = \ -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/CCEditBoxImplTizen.cpp \ -GUI/CCEditBox/CCEditBoxImplWin.cpp \ -GUI/CCScrollView/CCScrollView.cpp \ -GUI/CCScrollView/CCSorting.cpp \ -GUI/CCScrollView/CCTableView.cpp \ -GUI/CCScrollView/CCTableViewCell.cpp \ -physics-nodes/CCPhysicsDebugNode.cpp \ -physics-nodes/CCPhysicsSprite.cpp - -include ../../cocos/2d/cocos2dx.mk - -CXXFLAGS += -Wno-multichar -Wno-unused-result - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/Box2D/proj.linux/.cproject b/external/Box2D/proj.linux/.cproject deleted file mode 100644 index 5aa092cac3..0000000000 --- a/external/Box2D/proj.linux/.cproject +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/Box2D/proj.linux/.project b/external/Box2D/proj.linux/.project deleted file mode 100644 index 164d50f52a..0000000000 --- a/external/Box2D/proj.linux/.project +++ /dev/null @@ -1,110 +0,0 @@ - - - libBox2D - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/libBox2D/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Box2D.h - 1 - PARENT-1-PROJECT_LOC/Box2D.h - - - Collision - 2 - PARENT-1-PROJECT_LOC/Collision - - - Common - 2 - PARENT-1-PROJECT_LOC/Common - - - Dynamics - 2 - PARENT-1-PROJECT_LOC/Dynamics - - - Rope - 2 - PARENT-1-PROJECT_LOC/Rope - - - diff --git a/external/Box2D/proj.linux/Makefile b/external/Box2D/proj.linux/Makefile deleted file mode 100644 index b43814ccef..0000000000 --- a/external/Box2D/proj.linux/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -TARGET = libbox2d.a - -SOURCES = ../Collision/Shapes/b2ChainShape.cpp \ -../Collision/Shapes/b2CircleShape.cpp \ -../Collision/Shapes/b2EdgeShape.cpp \ -../Collision/Shapes/b2PolygonShape.cpp \ -../Collision/b2BroadPhase.cpp \ -../Collision/b2CollideCircle.cpp \ -../Collision/b2CollideEdge.cpp \ -../Collision/b2CollidePolygon.cpp \ -../Collision/b2Collision.cpp \ -../Collision/b2Distance.cpp \ -../Collision/b2DynamicTree.cpp \ -../Collision/b2TimeOfImpact.cpp \ -../Common/b2BlockAllocator.cpp \ -../Common/b2Draw.cpp \ -../Common/b2Math.cpp \ -../Common/b2Settings.cpp \ -../Common/b2StackAllocator.cpp \ -../Common/b2Timer.cpp \ -../Dynamics/Contacts/b2ChainAndCircleContact.cpp \ -../Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ -../Dynamics/Contacts/b2CircleContact.cpp \ -../Dynamics/Contacts/b2Contact.cpp \ -../Dynamics/Contacts/b2ContactSolver.cpp \ -../Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ -../Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ -../Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ -../Dynamics/Contacts/b2PolygonContact.cpp \ -../Dynamics/Joints/b2DistanceJoint.cpp \ -../Dynamics/Joints/b2FrictionJoint.cpp \ -../Dynamics/Joints/b2GearJoint.cpp \ -../Dynamics/Joints/b2Joint.cpp \ -../Dynamics/Joints/b2MouseJoint.cpp \ -../Dynamics/Joints/b2PrismaticJoint.cpp \ -../Dynamics/Joints/b2PulleyJoint.cpp \ -../Dynamics/Joints/b2RevoluteJoint.cpp \ -../Dynamics/Joints/b2RopeJoint.cpp \ -../Dynamics/Joints/b2WeldJoint.cpp \ -../Dynamics/Joints/b2WheelJoint.cpp \ -../Dynamics/b2Body.cpp \ -../Dynamics/b2ContactManager.cpp \ -../Dynamics/b2Fixture.cpp \ -../Dynamics/b2Island.cpp \ -../Dynamics/b2World.cpp \ -../Dynamics/b2WorldCallbacks.cpp \ -../Rope/b2Rope.cpp - -include ../../../cocos/2d/cocos2dx.mk - -INCLUDES = -I../.. - -# Cocos2d is not responsible for warnings in external projects -CXXFLAGS += -w - -ifeq ($(DEBUG), 1) -DEFINES = -D_DEBUG -else -DEFINES = -endif - -TARGET := $(LIB_DIR)/$(TARGET) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/Box2D/proj.linux/box2d.prf b/external/Box2D/proj.linux/box2d.prf deleted file mode 100644 index 434ad88406..0000000000 --- a/external/Box2D/proj.linux/box2d.prf +++ /dev/null @@ -1,19 +0,0 @@ -################################################################################ -# Do not include this file in your project: see cocos2dx.pri. -################################################################################ - -linux { - # We will compile box2d on demand using Makefile. - build_box2d.name = Build box2d static library - build_box2d.input = $$PWD/Makefile - build_box2d.output = $$CC_LIBRARY_DIR/libbox2d.a - build_box2d.target = $$CC_LIBRARY_DIR/libbox2d.a - build_box2d.CONFIG = no_link target_predeps - build_box2d.commands = cd $$PWD && make $$CC_MAKE_FLAGS - - QMAKE_EXTRA_COMPILERS += build_box2d - QMAKE_EXTRA_TARGETS += build_box2d - - PRE_TARGETDEPS += $$CC_LIBRARY_DIR/libbox2d.a - LIBS += -Wl,-Bstatic -lbox2d -Wl,-Bdynamic -} diff --git a/external/chipmunk/proj.linux/.cproject b/external/chipmunk/proj.linux/.cproject deleted file mode 100644 index 18467c15ca..0000000000 --- a/external/chipmunk/proj.linux/.cproject +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/chipmunk/proj.linux/.project b/external/chipmunk/proj.linux/.project deleted file mode 100644 index 2f42dedf9b..0000000000 --- a/external/chipmunk/proj.linux/.project +++ /dev/null @@ -1,95 +0,0 @@ - - - libChipmunk - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/libChipmunk/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - include - 2 - PARENT-1-PROJECT_LOC/include - - - src - 2 - PARENT-1-PROJECT_LOC/src - - - diff --git a/external/chipmunk/proj.linux/Makefile b/external/chipmunk/proj.linux/Makefile deleted file mode 100644 index a2cb985b7c..0000000000 --- a/external/chipmunk/proj.linux/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -SOURCES = ../src/chipmunk.c \ - ../src/cpBody.c \ - ../src/cpSpace.c \ - ../src/cpSpatialIndex.c \ - ../src/cpArbiter.c \ - ../src/cpCollision.c \ - ../src/cpSpaceComponent.c \ - ../src/cpSweep1D.c \ - ../src/cpArray.c \ - ../src/cpHashSet.c \ - ../src/cpSpaceHash.c \ - ../src/cpVect.c \ - ../src/cpBB.c \ - ../src/cpPolyShape.c \ - ../src/cpSpaceQuery.c \ - ../src/cpBBTree.c \ - ../src/cpShape.c \ - ../src/cpSpaceStep.c \ - ../src/constraints/cpConstraint.c \ - ../src/constraints/cpPivotJoint.c \ - ../src/constraints/cpDampedRotarySpring.c \ - ../src/constraints/cpRatchetJoint.c \ - ../src/constraints/cpDampedSpring.c \ - ../src/constraints/cpRotaryLimitJoint.c \ - ../src/constraints/cpGearJoint.c \ - ../src/constraints/cpSimpleMotor.c \ - ../src/constraints/cpGrooveJoint.c \ - ../src/constraints/cpSlideJoint.c \ - ../src/constraints/cpPinJoint.c \ - -include ../../../cocos/2d/cocos2dx.mk - -TARGET = $(LIB_DIR)/libchipmunk.a -INCLUDES = -I../include/chipmunk -DEFINES = -DLINUX -CCFLAGS += -std=gnu99 -OBJECTS := $(subst src/,,$(OBJECTS)) - -all: $(TARGET) - -$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_AR)$(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) - -$(OBJ_DIR)/%.o: ../src/%.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/chipmunk/proj.linux/chipmunk.prf b/external/chipmunk/proj.linux/chipmunk.prf deleted file mode 100644 index a807b0ab99..0000000000 --- a/external/chipmunk/proj.linux/chipmunk.prf +++ /dev/null @@ -1,19 +0,0 @@ -################################################################################ -# Do not include this file in your project: see cocos2dx.pri. -################################################################################ - -linux { - # We will compile chipmunk on demand using Makefile. - build_chipmunk.name = Build chipmunk static library - build_chipmunk.input = $$PWD/Makefile - build_chipmunk.output = $$CC_LIBRARY_DIR/libchipmunk.a - build_chipmunk.target = $$CC_LIBRARY_DIR/libchipmunk.a - build_chipmunk.CONFIG = no_link target_predeps - build_chipmunk.commands = cd $$PWD && make $$CC_MAKE_FLAGS - - QMAKE_EXTRA_COMPILERS += build_chipmunk - QMAKE_EXTRA_TARGETS += build_chipmunk - - PRE_TARGETDEPS += $$CC_LIBRARY_DIR/libchipmunk.a - LIBS += -Wl,-Bstatic -lchipmunk -Wl,-Bdynamic -} From 528c257497d23a84f14858f24fde0a2bd0a4b5ca Mon Sep 17 00:00:00 2001 From: 2youyou2 <501251991@qq.com> Date: Mon, 11 Nov 2013 17:30:37 +0800 Subject: [PATCH 101/185] add setUserObject method to CCArmatureAnimation --- .../cocostudio/CCArmatureAnimation.cpp | 10 ++++++ .../cocostudio/CCArmatureAnimation.h | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index f3e5199d6c..274a68342f 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -56,6 +56,7 @@ ArmatureAnimation::ArmatureAnimation() , _toIndex(0) , _tweenList(nullptr) , _ignoreFrameEvent(false) + , _userObject(nullptr) , _movementEventCallFunc(nullptr) , _frameEventCallFunc(nullptr) @@ -69,6 +70,8 @@ ArmatureAnimation::~ArmatureAnimation(void) { CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); + + CC_SAFE_RELEASE_NULL(_userObject); } bool ArmatureAnimation::init(Armature *armature) @@ -430,6 +433,13 @@ void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCall _frameEventCallFunc = callFunc; } +void ArmatureAnimation::setUserObject(Object *pUserObject) +{ + CC_SAFE_RETAIN(pUserObject); + CC_SAFE_RELEASE(_userObject); + _userObject = pUserObject; +} + void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) { if (_frameEventTarget && _frameEventCallFunc) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 8d306398e9..7b9e9821ab 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -202,6 +202,35 @@ public: } } virtual AnimationData *getAnimationData() const { return _animationData; } + + + /** + * Returns a user assigned Object + * + * Similar to userData, but instead of holding a void* it holds an object + * + * @return A user assigned Object + * @js NA + * @lua NA + */ + virtual Object* getUserObject() { return _userObject; } + /** + * @js NA + * @lua NA + */ + virtual const Object* getUserObject() const { return _userObject; } + + /** + * Returns a user assigned Object + * + * Similar to UserData, but instead of holding a void* it holds an object. + * The UserObject will be retained once in this method, + * and the previous UserObject (if existed) will be relese. + * The UserObject will be released in Node's destructure. + * + * @param userObject A user assigned Object + */ + virtual void setUserObject(Object *userObject); protected: /** @@ -242,6 +271,8 @@ protected: bool _ignoreFrameEvent; std::queue _frameEventQueue; + + cocos2d::Object *_userObject; protected: /** * MovementEvent CallFunc. From d1a414194ef5f6f91de2ea31849df9a567a39044 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Nov 2013 17:36:23 +0800 Subject: [PATCH 102/185] [ci skip]update linux build commands --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b1a5fa297..938f0c39fb 100644 --- a/README.md +++ b/README.md @@ -98,10 +98,13 @@ $ open samples.xcodeproj ``` $ cd cocos2d-x/build -$ ./make-all-linux-project.sh +$ ./install-deps-linux.sh +$ cmake .. +$ make ``` -You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. + You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. + `install-deps-linux.sh` only has to be run onece. * For Windows From 4f76141c415cf550f51cece19de1d9fee1af1600 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Mon, 11 Nov 2013 18:22:14 +0800 Subject: [PATCH 103/185] optimize guireader --- .../cocostudio/CCSGUIReader.cpp | 2933 +++++++++-------- .../editor-support/cocostudio/CCSGUIReader.h | 103 +- .../CocoStudioGUITest/UIScene.cpp | 2 +- 3 files changed, 1692 insertions(+), 1346 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 3ad788b563..ca1067e504 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -34,36 +34,36 @@ namespace cocostudio { -static CCSGUIReader* sharedReader = NULL; +static GUIReader* sharedReader = NULL; -CCSGUIReader::CCSGUIReader(): -m_strFilePath(""), -m_bOlderVersion(false) +GUIReader::GUIReader(): +m_strFilePath("") { - _fileDesignSizes = Dictionary::create(); + _fileDesignSizes = CCDictionary::create(); CC_SAFE_RETAIN(_fileDesignSizes); } -CCSGUIReader::~CCSGUIReader() +GUIReader::~GUIReader() { + _fileDesignSizes->removeAllObjects(); CC_SAFE_RELEASE(_fileDesignSizes); } -CCSGUIReader* CCSGUIReader::shareReader() +GUIReader* GUIReader::shareReader() { if (!sharedReader) { - sharedReader = new CCSGUIReader(); + sharedReader = new GUIReader(); } return sharedReader; } -void CCSGUIReader::purgeCCSGUIReader() +void GUIReader::purgeGUIReader() { - CC_SAFE_DELETE(sharedReader); + CC_SAFE_DELETE(sharedReader); } -int CCSGUIReader::getVersionInteger(const char *str) +int GUIReader::getVersionInteger(const char *str) { /*********temp***********/ std::string strVersion = str; @@ -98,11 +98,132 @@ int CCSGUIReader::getVersionInteger(const char *str) /************************/ } -UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) +void GUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) { + if (!_fileDesignSizes) + { + return; + } + cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); + _fileDesignSizes->setObject(strSize, fileName); +} + +const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const +{ + if (!_fileDesignSizes) + { + return cocos2d::Size::ZERO; + } + cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)_fileDesignSizes->objectForKey(fileName))->_string.c_str()); + return designSize; +} + + +UIWidget* GUIReader::widgetFromJsonFile(const char *fileName) +{ + DictionaryHelper* dicHelper = DICTOOL; + const char *des = NULL; + std::string jsonpath; + JsonDictionary *jsonDict = NULL; + jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName); + int pos = jsonpath.find_last_of('/'); + m_strFilePath = jsonpath.substr(0,pos+1); + long size = 0; + des = (char*)(CCFileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); + if(NULL == des || strcmp(des, "") == 0) + { + printf("read json file[%s] error!\n", fileName); + return NULL; + } + std::string strDes(des); + jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(strDes.c_str()); + UIWidget* widget = NULL; - const char* classname = DICTOOL->getStringValue_json(data, "classname"); - JsonDictionary* uiOptions = DICTOOL->getSubDictionary_json(data, "options"); + const char* fileVersion = dicHelper->getStringValue_json(jsonDict, "version"); + WidgetPropertiesReader * pReader = NULL; + if (fileVersion) + { + int versionInteger = getVersionInteger(fileVersion); + if (versionInteger < 250) + { + pReader = new WidgetPropertiesReader0250(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + else + { + pReader = new WidgetPropertiesReader0300(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + } + else + { + pReader = new WidgetPropertiesReader0250(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + + CC_SAFE_DELETE(pReader); + CC_SAFE_DELETE(jsonDict); + CC_SAFE_DELETE_ARRAY(des); + return widget; +} + + + +UIWidget* WidgetPropertiesReader0250::createWidget(JsonDictionary* data, const char* fullPath, const char* fileName) +{ + m_strFilePath = fullPath; + DictionaryHelper* dicHelper = DICTOOL; + int texturesCount = dicHelper->getArrayCount_json(data, "textures"); + + for (int i=0; igetStringValueFromArray_json(data, "textures", i); + std::string tp = fullPath; + tp.append(file); + CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); + } + float fileDesignWidth = dicHelper->getFloatValue_json(data, "designWidth"); + float fileDesignHeight = dicHelper->getFloatValue_json(data, "designHeight"); + if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { + printf("Read design size error!\n"); + Size winSize = Director::getInstance()->getWinSize(); + GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + } + else + { + GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + } + JsonDictionary* widgetTree = dicHelper->getSubDictionary_json(data, "widgetTree"); + UIWidget* widget = widgetFromJsonDictionary(widgetTree); + + /* *********temp********* */ + if (widget->getContentSize().equals(Size::ZERO)) + { + UILayout* rootWidget = dynamic_cast(widget); + rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); + } + /* ********************** */ + + // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); + JsonDictionary* actions = dicHelper->getSubDictionary_json(data, "animation"); + /* *********temp********* */ + // ActionManager::shareManager()->releaseActions(); + /* ********************** */ + CCLOG("file name == [%s]",fileName); + Object* rootWidget = (Object*) widget; + ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,rootWidget); + CC_SAFE_DELETE(widgetTree); + CC_SAFE_DELETE(actions); + return widget; +} + +UIWidget* WidgetPropertiesReader0250::widgetFromJsonDictionary(JsonDictionary *data) +{ + DictionaryHelper* dicHelper = DICTOOL; + UIWidget* widget = NULL; + const char* classname = dicHelper->getStringValue_json(data, "classname"); + JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) { widget = UIButton::create(); @@ -134,12 +255,12 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) else if (classname && strcmp(classname, "TextArea") == 0) { widget = UILabel::create(); - setPropsForTextAreaFromJsonDictionary(widget, uiOptions); + setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) { widget = UIButton::create(); - setPropsForTextButtonFromJsonDictionary(widget, uiOptions); + setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextField") == 0) { @@ -154,13 +275,742 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) else if (classname && strcmp(classname, "Panel") == 0) { widget = UILayout::create(); - setPropsForPanelFromJsonDictionary(widget, uiOptions); + setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Slider") == 0) { widget = UISlider::create(); setPropsForSliderFromJsonDictionary(widget, uiOptions); } + else if (classname && strcmp(classname, "LabelBMFont") == 0) + { + widget = UILabelBMFont::create(); + setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "DragPanel") == 0) + { + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } + + int childrenCount = dicHelper->getArrayCount_json(data, "children"); + for (int i=0;igetDictionaryFromArray_json(data, "children", i); + UIWidget* child = widgetFromJsonDictionary(subData); + if (child) + { + widget->addChild(child); + } + CC_SAFE_DELETE(subData); + } + + CC_SAFE_DELETE(uiOptions); + return widget; +} + +void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + bool ignoreSizeExsit = dicHelper->checkObjectExist_json(options, "ignoreSize"); + if (ignoreSizeExsit) + { + widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize")); + } + + float w = dicHelper->getFloatValue_json(options, "width"); + float h = dicHelper->getFloatValue_json(options, "height"); + widget->setSize(Size(w, h)); + + widget->setTag(dicHelper->getIntValue_json(options, "tag")); + widget->setActionTag(dicHelper->getIntValue_json(options, "actiontag")); + widget->setTouchEnabled(dicHelper->getBooleanValue_json(options, "touchAble")); + const char* name = dicHelper->getStringValue_json(options, "name"); + const char* widgetName = name?name:"default"; + widget->setName(widgetName); + float x = dicHelper->getFloatValue_json(options, "x"); + float y = dicHelper->getFloatValue_json(options, "y"); + widget->setPosition(Point(x,y)); + bool sx = dicHelper->checkObjectExist_json(options, "scaleX"); + if (sx) + { + widget->setScaleX(dicHelper->getFloatValue_json(options, "scaleX")); + } + bool sy = dicHelper->checkObjectExist_json(options, "scaleY"); + if (sy) + { + widget->setScaleY(dicHelper->getFloatValue_json(options, "scaleY")); + } + bool rt = dicHelper->checkObjectExist_json(options, "rotation"); + if (rt) + { + widget->setRotation(dicHelper->getFloatValue_json(options, "rotation")); + } + bool vb = dicHelper->checkObjectExist_json(options, "visible"); + if (vb) + { + widget->setVisible(dicHelper->getBooleanValue_json(options, "visible")); + } + int z = dicHelper->getIntValue_json(options, "ZOrder"); + widget->setZOrder(z); +} + +void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + bool op = dicHelper->checkObjectExist_json(options, "opacity"); + if (op) + { + widget->setOpacity(dicHelper->getIntValue_json(options, "opacity")); + } + bool cr = dicHelper->checkObjectExist_json(options, "colorR"); + bool cg = dicHelper->checkObjectExist_json(options, "colorG"); + bool cb = dicHelper->checkObjectExist_json(options, "colorB"); + int colorR = cr ? dicHelper->getIntValue_json(options, "colorR") : 255; + int colorG = cg ? dicHelper->getIntValue_json(options, "colorG") : 255; + int colorB = cb ? dicHelper->getIntValue_json(options, "colorB") : 255; + widget->setColor(Color3B(colorR, colorG, colorB)); + bool apx = dicHelper->checkObjectExist_json(options, "anchorPointX"); + float apxf = apx ? dicHelper->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + bool apy = dicHelper->checkObjectExist_json(options, "anchorPointY"); + float apyf = apy ? dicHelper->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + widget->setAnchorPoint(Point(apxf, apyf)); + bool flipX = dicHelper->getBooleanValue_json(options, "flipX"); + bool flipY = dicHelper->getBooleanValue_json(options, "flipY"); + widget->setFlipX(flipX); + widget->setFlipY(flipY); +} + +void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UIButton* button = (UIButton*)widget; + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + button->setScale9Enabled(scale9Enable); + + std::string tp_n = m_strFilePath; + std::string tp_p = m_strFilePath; + std::string tp_d = m_strFilePath; + + const char* normalFileName = dicHelper->getStringValue_json(options, "normal"); + const char* pressedFileName = dicHelper->getStringValue_json(options, "pressed"); + const char* disabledFileName = dicHelper->getStringValue_json(options, "disabled"); + + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + if (useMergedTexture) + { + button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); + } + button->setCapInsets(Rect(cx, cy, cw, ch)); + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + button->setSize(Size(swf, shf)); + } + } + else + { + if (useMergedTexture) + { + button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); + } + } + bool tt = dicHelper->checkObjectExist_json(options, "text"); + if (tt) + { + const char* text = dicHelper->getStringValue_json(options, "text"); + if (text) + { + button->setTitleText(text); + } + } + bool cr = dicHelper->checkObjectExist_json(options, "textColorR"); + bool cg = dicHelper->checkObjectExist_json(options, "textColorG"); + bool cb = dicHelper->checkObjectExist_json(options, "textColorB"); + int cri = cr?dicHelper->getIntValue_json(options, "textColorR"):255; + int cgi = cg?dicHelper->getIntValue_json(options, "textColorG"):255; + int cbi = cb?dicHelper->getIntValue_json(options, "textColorB"):255; + button->setTitleColor(Color3B(cri,cgi,cbi)); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + button->setTitleFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + button->setTitleFontName(dicHelper->getStringValue_json(options, "fontName")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UICheckBox* checkBox = (UICheckBox*)widget; + const char* backGroundFileName = dicHelper->getStringValue_json(options, "backGroundBox"); + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(options, "backGroundBoxSelected"); + const char* frontCrossFileName = dicHelper->getStringValue_json(options, "frontCross"); + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(options, "backGroundBoxDisabled"); + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "frontCrossDisabled"); + + + std::string tp_b = m_strFilePath; + std::string tp_bs = m_strFilePath; + std::string tp_c = m_strFilePath; + std::string tp_bd = m_strFilePath; + std::string tp_cd = m_strFilePath; + + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + + if (useMergedTexture) + { + checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp); + } + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + + UIImageView* imageView = (UIImageView*)widget; + const char* imageFileName = dicHelper->getStringValue_json(options, "fileName"); + bool scale9EnableExist = dicHelper->checkObjectExist_json(options, "scale9Enable"); + bool scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + } + imageView->setScale9Enabled(scale9Enable); + + std::string tp_i = m_strFilePath; + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + } + + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (scale9Enable) + { + if (useMergedTexture) + { + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + imageView->loadTexture(imageFileName_tp); + } + + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + imageView->setSize(Size(swf, shf)); + } + + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + imageView->setCapInsets(Rect(cx, cy, cw, ch)); + + } + else + { + if (useMergedTexture) + { + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + imageView->loadTexture(imageFileName_tp); + } + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILabel* label = (UILabel*)widget; + bool touchScaleChangeAble = dicHelper->getBooleanValue_json(options, "touchScaleEnable"); + label->setTouchScaleChangeEnabled(touchScaleChangeAble); + const char* text = dicHelper->getStringValue_json(options, "text"); + label->setText(text); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + label->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + label->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool aw = dicHelper->checkObjectExist_json(options, "areaWidth"); + bool ah = dicHelper->checkObjectExist_json(options, "areaHeight"); + if (aw && ah) + { + Size size = Size(dicHelper->getFloatValue_json(options, "areaWidth"),dicHelper->getFloatValue_json(options,"areaHeight")); + label->setTextAreaSize(size); + } + bool ha = dicHelper->checkObjectExist_json(options, "hAlignment"); + if (ha) + { + label->setTextHorizontalAlignment((TextHAlignment)dicHelper->getIntValue_json(options, "hAlignment")); + } + bool va = dicHelper->checkObjectExist_json(options, "vAlignment"); + if (va) + { + label->setTextVerticalAlignment((TextVAlignment)dicHelper->getIntValue_json(options, "vAlignment")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; + bool sv = dicHelper->checkObjectExist_json(options, "stringValue"); + bool cmf = dicHelper->checkObjectExist_json(options, "charMapFile"); + bool iw = dicHelper->checkObjectExist_json(options, "itemWidth"); + bool ih = dicHelper->checkObjectExist_json(options, "itemHeight"); + bool scm = dicHelper->checkObjectExist_json(options, "startCharMap"); + if (sv && cmf && iw && ih && scm && (strcmp(dicHelper->getStringValue_json(options, "charMapFile"), "") != 0)) + { + std::string tp_c = m_strFilePath; + const char* cmf_tp = NULL; + const char* cmft = dicHelper->getStringValue_json(options, "charMapFile"); + cmf_tp = tp_c.append(cmft).c_str(); + + labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + + setPropsForWidgetFromJsonDictionary(widget, options); + UILayout* containerWidget = (UILayout*)widget; + if (!dynamic_cast(containerWidget) + && !dynamic_cast(containerWidget)) + { + containerWidget->setClippingEnabled(dicHelper->getBooleanValue_json(options, "clipAble")); + } + UILayout* panel = (UILayout*)widget; + bool backGroundScale9Enable = dicHelper->getBooleanValue_json(options, "backGroundScale9Enable"); + panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); + int cr = dicHelper->getIntValue_json(options, "bgColorR"); + int cg = dicHelper->getIntValue_json(options, "bgColorG"); + int cb = dicHelper->getIntValue_json(options, "bgColorB"); + + int scr = dicHelper->getIntValue_json(options, "bgStartColorR"); + int scg = dicHelper->getIntValue_json(options, "bgStartColorG"); + int scb = dicHelper->getIntValue_json(options, "bgStartColorB"); + + int ecr = dicHelper->getIntValue_json(options, "bgEndColorR"); + int ecg = dicHelper->getIntValue_json(options, "bgEndColorG"); + int ecb = dicHelper->getIntValue_json(options, "bgEndColorB"); + + float bgcv1 = dicHelper->getFloatValue_json(options, "vectorX"); + float bgcv2 = dicHelper->getFloatValue_json(options, "vectorY"); + panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); + + int co = dicHelper->getIntValue_json(options, "bgColorOpacity"); + + int colorType = dicHelper->getIntValue_json(options, "colorType"); + panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); + panel->setBackGroundColor(Color3B(cr, cg, cb)); + panel->setBackGroundColorOpacity(co); + + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "backGroundImage"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (backGroundScale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + if (useMergedTexture) + { + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + panel->setBackGroundImage(imageFileName_tp); + } + panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); + } + else + { + + if (useMergedTexture) + { + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + panel->setBackGroundImage(imageFileName_tp); + } + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForLayoutFromJsonDictionary(widget, options); + UIScrollView* scrollView = (UIScrollView*)widget; + float innerWidth = dicHelper->getFloatValue_json(options, "innerWidth"); + float innerHeight = dicHelper->getFloatValue_json(options, "innerHeight"); + scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); + int direction = dicHelper->getFloatValue_json(options, "direction"); + scrollView->setDirection((SCROLLVIEW_DIR)direction); + scrollView->setBounceEnabled(dicHelper->getBooleanValue_json(options, "bounceEnable")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UISlider* slider = (UISlider*)widget; + + bool barTextureScale9Enable = dicHelper->getBooleanValue_json(options, "barTextureScale9Enable"); + slider->setScale9Enabled(barTextureScale9Enable); + bool bt = dicHelper->checkObjectExist_json(options, "barFileName"); + float barLength = dicHelper->getFloatValue_json(options, "length"); + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (bt) + { + if (barTextureScale9Enable) + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadBarTexture(imageFileName_tp); + } + slider->setSize(Size(barLength, slider->getContentSize().height)); + } + else + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadBarTexture(imageFileName_tp); + } + } + } + std::string tp_n = m_strFilePath; + std::string tp_p = m_strFilePath; + std::string tp_d = m_strFilePath; + + const char* normalFileName = dicHelper->getStringValue_json(options, "ballNormal"); + const char* pressedFileName = dicHelper->getStringValue_json(options, "ballPressed"); + const char* disabledFileName = dicHelper->getStringValue_json(options, "ballDisabled"); + + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); + } + slider->setPercent(dicHelper->getIntValue_json(options, "percent")); + + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "progressBarFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); + } + else + { + slider->loadProgressBarTexture(imageFileName_tp); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UITextField* textField = (UITextField*)widget; + bool ph = dicHelper->checkObjectExist_json(options, "placeHolder"); + if (ph) + { + textField->setPlaceHolder(dicHelper->getStringValue_json(options, "placeHolder")); + } + textField->setText(dicHelper->getStringValue_json(options, "text")); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + textField->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + textField->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool tsw = dicHelper->checkObjectExist_json(options, "touchSizeWidth"); + bool tsh = dicHelper->checkObjectExist_json(options, "touchSizeHeight"); + if (tsw && tsh) + { + textField->setTouchSize(Size(dicHelper->getFloatValue_json(options, "touchSizeWidth"), dicHelper->getFloatValue_json(options,"touchSizeHeight"))); + } + + float dw = dicHelper->getFloatValue_json(options, "width"); + float dh = dicHelper->getFloatValue_json(options, "height"); + if (dw > 0.0f || dh > 0.0f) + { + //textField->setSize(Size(dw, dh)); + } + bool maxLengthEnable = dicHelper->getBooleanValue_json(options, "maxLengthEnable"); + textField->setMaxLengthEnabled(maxLengthEnable); + + if (maxLengthEnable) + { + int maxLength = dicHelper->getIntValue_json(options, "maxLength"); + textField->setMaxLength(maxLength); + } + bool passwordEnable = dicHelper->getBooleanValue_json(options, "passwordEnable"); + textField->setPasswordEnabled(passwordEnable); + if (passwordEnable) + { + textField->setPasswordStyleText(dicHelper->getStringValue_json(options, "passwordStyleText")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILoadingBar* loadingBar = (UILoadingBar*)widget; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + std::string tp_b = m_strFilePath; + const char*imageFileName = dicHelper->getStringValue_json(options, "texture"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + loadingBar->loadTexture(imageFileName_tp); + } + loadingBar->setDirection(LoadingBarType(dicHelper->getIntValue_json(options, "direction"))); + loadingBar->setPercent(dicHelper->getIntValue_json(options, "percent")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + + setPropsForWidgetFromJsonDictionary(widget, options); + + UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; + + std::string tp_c = m_strFilePath; + const char* cmf_tp = NULL; + const char* cmft = dicHelper->getStringValue_json(options, "fileName"); + cmf_tp = tp_c.append(cmft).c_str(); + + labelBMFont->setFntFile(cmf_tp); + + const char* text = dicHelper->getStringValue_json(options, "text"); + labelBMFont->setText(text); + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + + +/*0.3.0.0~1.0.0.0*/ +UIWidget* WidgetPropertiesReader0300::createWidget(JsonDictionary* data, const char* fullPath, const char* fileName) +{ + m_strFilePath = fullPath; + DictionaryHelper* dicHelper = DICTOOL; + int texturesCount = dicHelper->getArrayCount_json(data, "textures"); + + for (int i=0; igetStringValueFromArray_json(data, "textures", i); + std::string tp = fullPath; + tp.append(file); + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); + } + float fileDesignWidth = dicHelper->getFloatValue_json(data, "designWidth"); + float fileDesignHeight = dicHelper->getFloatValue_json(data, "designHeight"); + if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { + printf("Read design size error!\n"); + Size winSize = Director::getInstance()->getWinSize(); + GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + } + else + { + GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + } + JsonDictionary* widgetTree = dicHelper->getSubDictionary_json(data, "widgetTree"); + UIWidget* widget = widgetFromJsonDictionary(widgetTree); + + /* *********temp********* */ + if (widget->getContentSize().equals(Size::ZERO)) + { + UILayout* rootWidget = dynamic_cast(widget); + rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); + } + /* ********************** */ + + // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); + JsonDictionary* actions = dicHelper->getSubDictionary_json(data, "animation"); + /* *********temp********* */ + // ActionManager::shareManager()->releaseActions(); + /* ********************** */ + CCLOG("file name == [%s]",fileName); + Object* rootWidget = (Object*) widget; + ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,rootWidget); + CC_SAFE_DELETE(widgetTree); + CC_SAFE_DELETE(actions); + return widget; +} + +UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *data) +{ + DictionaryHelper* dicHelper = DICTOOL; + UIWidget* widget = NULL; + const char* classname = dicHelper->getStringValue_json(data, "classname"); + JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); + if (classname && strcmp(classname, "Button") == 0) + { + widget = UIButton::create(); + setPropsForButtonFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "CheckBox") == 0) + { + widget = UICheckBox::create(); + setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Label") == 0) + { + widget = UILabel::create(); + setPropsForLabelFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LabelAtlas") == 0) + { + widget = UILabelAtlas::create(); + setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LoadingBar") == 0) + { + widget = UILoadingBar::create(); + setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); + }else if (classname && strcmp(classname, "ScrollView") == 0){ + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextArea") == 0) + { + widget = UILabel::create(); + setPropsForLabelFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextButton") == 0) + { + widget = UIButton::create(); + setPropsForButtonFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextField") == 0) + { + widget = UITextField::create(); + setPropsForTextFieldFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "ImageView") == 0) + { + widget = UIImageView::create(); + setPropsForImageViewFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Panel") == 0) + { + widget = UILayout::create(); + setPropsForLayoutFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Slider") == 0) + { + widget = UISlider::create(); + setPropsForSliderFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LabelBMFont") == 0) + { + widget = UILabelBMFont::create(); + setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "DragPanel") == 0) + { + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } else if (classname && strcmp(classname, "ListView") == 0) { widget = UIListView::create(); @@ -171,1389 +1021,466 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) widget = UIPageView::create(); setPropsForPageViewFromJsonDictionary(widget, uiOptions); } - else if (classname && strcmp(classname, "LabelBMFont") == 0) - { - widget = UILabelBMFont::create(); - setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); - } - else if (classname && strcmp(classname, "DragPanel") == 0) - { - widget = UIScrollView::create(); - setPropsForDragPanelFromJsonDictionary(widget, uiOptions); - } - - int childrenCount = DICTOOL->getArrayCount_json(data, "children"); + + int childrenCount = dicHelper->getArrayCount_json(data, "children"); for (int i=0;igetDictionaryFromArray_json(data, "children", i); + JsonDictionary* subData = dicHelper->getDictionaryFromArray_json(data, "children", i); UIWidget* child = widgetFromJsonDictionary(subData); if (child) { widget->addChild(child); } - CC_SAFE_DELETE(subData); + CC_SAFE_DELETE(subData); } - - CC_SAFE_DELETE(uiOptions); + + CC_SAFE_DELETE(uiOptions); return widget; } -void CCSGUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) +void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) { - if (!_fileDesignSizes) - { - _fileDesignSizes = cocos2d::Dictionary::create(); - _fileDesignSizes->retain(); - } - cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); - _fileDesignSizes->setObject(strSize, fileName); -} - -const cocos2d::Size CCSGUIReader::getFileDesignSize(const char* fileName) const -{ - if (!_fileDesignSizes) - { - return cocos2d::Size::ZERO; - } - cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)_fileDesignSizes->objectForKey(fileName))->_string.c_str()); - return designSize; -} - -UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) -{ - m_bOlderVersion = false; - const char *des = NULL; - std::string jsonpath; - JsonDictionary *jsonDict = NULL; - jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName); - - long size = 0; - des = (char*)(FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); - if(NULL == des || strcmp(des, "") == 0) - { - printf("read json file[%s] error!\n", fileName); - return NULL; - } - std::string strDes(des); - jsonDict = new JsonDictionary(); - jsonDict->initWithDescription(strDes.c_str()); - - const char* fileVersion = DICTOOL->getStringValue_json(jsonDict, "version"); - if (!fileVersion || getVersionInteger(fileVersion) < 250) - { - m_bOlderVersion = true; - } - - int texturesCount = DICTOOL->getArrayCount_json(jsonDict, "textures"); - long pos = jsonpath.find_last_of('/'); - m_strFilePath = jsonpath.substr(0,pos+1); - for (int i=0; igetStringValueFromArray_json(jsonDict, "textures", i); - std::string tp = m_strFilePath; - tp.append(file); - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); - } - float fileDesignWidth = DICTOOL->getFloatValue_json(jsonDict, "designWidth"); - float fileDesignHeight = DICTOOL->getFloatValue_json(jsonDict, "designHeight"); - if (fileDesignWidth <= 0 || fileDesignHeight <= 0) - { - printf("Read design size error!\n"); - Size winSize = Director::getInstance()->getWinSize(); - storeFileDesignSize(fileName, winSize); - } - else - { - storeFileDesignSize(fileName, cocos2d::Size(fileDesignWidth, fileDesignHeight)); - } - JsonDictionary* widgetTree = DICTOOL->getSubDictionary_json(jsonDict, "widgetTree"); - UIWidget* widget = widgetFromJsonDictionary(widgetTree); - - /* *********temp********* */ - if (widget->getContentSize().equals(Size::ZERO)) - { - UILayout* rootWidget = dynamic_cast(widget); - rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); - } - /* ********************** */ - -// widget->setFileDesignSize(CCSizeMake(fileDesignWidth, fileDesignHeight)); - JsonDictionary* actions = DICTOOL->getSubDictionary_json(jsonDict, "animation"); - /* *********temp********* */ -// ActionManager::shareManager()->releaseActions(); - /* ********************** */ - CCLOG("file name == [%s]",fileName); - ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,widget); - - CC_SAFE_DELETE(widgetTree); - CC_SAFE_DELETE(actions); - CC_SAFE_DELETE(jsonDict); - CC_SAFE_DELETE_ARRAY(des); - return widget; -} - -void CCSGUIReader::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) -{ - bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, "ignoreSize"); + DictionaryHelper* dicHelper = DICTOOL; + bool ignoreSizeExsit = dicHelper->checkObjectExist_json(options, "ignoreSize"); if (ignoreSizeExsit) { - widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); + widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize")); } - float w = DICTOOL->getFloatValue_json(options, "width"); - float h = DICTOOL->getFloatValue_json(options, "height"); + float w = dicHelper->getFloatValue_json(options, "width"); + float h = dicHelper->getFloatValue_json(options, "height"); widget->setSize(Size(w, h)); - widget->setTag(DICTOOL->getIntValue_json(options, "tag")); - widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); - widget->setTouchEnabled(DICTOOL->getBooleanValue_json(options, "touchAble")); - const char* name = DICTOOL->getStringValue_json(options, "name"); + widget->setTag(dicHelper->getIntValue_json(options, "tag")); + widget->setActionTag(dicHelper->getIntValue_json(options, "actiontag")); + widget->setTouchEnabled(dicHelper->getBooleanValue_json(options, "touchAble")); + const char* name = dicHelper->getStringValue_json(options, "name"); const char* widgetName = name?name:"default"; widget->setName(widgetName); - float x = DICTOOL->getFloatValue_json(options, "x"); - float y = DICTOOL->getFloatValue_json(options, "y"); + float x = dicHelper->getFloatValue_json(options, "x"); + float y = dicHelper->getFloatValue_json(options, "y"); widget->setPosition(Point(x,y)); - bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); + bool sx = dicHelper->checkObjectExist_json(options, "scaleX"); if (sx) { - widget->setScaleX(DICTOOL->getFloatValue_json(options, "scaleX")); + widget->setScaleX(dicHelper->getFloatValue_json(options, "scaleX")); } - bool sy = DICTOOL->checkObjectExist_json(options, "scaleY"); + bool sy = dicHelper->checkObjectExist_json(options, "scaleY"); if (sy) { - widget->setScaleY(DICTOOL->getFloatValue_json(options, "scaleY")); + widget->setScaleY(dicHelper->getFloatValue_json(options, "scaleY")); } - bool rt = DICTOOL->checkObjectExist_json(options, "rotation"); + bool rt = dicHelper->checkObjectExist_json(options, "rotation"); if (rt) { - widget->setRotation(DICTOOL->getFloatValue_json(options, "rotation")); + widget->setRotation(dicHelper->getFloatValue_json(options, "rotation")); } - bool vb = DICTOOL->checkObjectExist_json(options, "visible"); + bool vb = dicHelper->checkObjectExist_json(options, "visible"); if (vb) { - widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); + widget->setVisible(dicHelper->getBooleanValue_json(options, "visible")); } -// widget->setUseMergedTexture(DICTOOL->getBooleanValue_json(options, "useMergedTexture")); - int z = DICTOOL->getIntValue_json(options, "ZOrder"); + int z = dicHelper->getIntValue_json(options, "ZOrder"); widget->setZOrder(z); } -void CCSGUIReader::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) { - bool op = DICTOOL->checkObjectExist_json(options, "opacity"); + DictionaryHelper* dicHelper = DICTOOL; + bool op = dicHelper->checkObjectExist_json(options, "opacity"); if (op) { - widget->setOpacity(DICTOOL->getIntValue_json(options, "opacity")); + widget->setOpacity(dicHelper->getIntValue_json(options, "opacity")); } - bool cr = DICTOOL->checkObjectExist_json(options, "colorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "colorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "colorB"); - int colorR = cr ? DICTOOL->getIntValue_json(options, "colorR") : 255; - int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255; - int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; + bool cr = dicHelper->checkObjectExist_json(options, "colorR"); + bool cg = dicHelper->checkObjectExist_json(options, "colorG"); + bool cb = dicHelper->checkObjectExist_json(options, "colorB"); + int colorR = cr ? dicHelper->getIntValue_json(options, "colorR") : 255; + int colorG = cg ? dicHelper->getIntValue_json(options, "colorG") : 255; + int colorB = cb ? dicHelper->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); - bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : 0.5f; - bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : 0.5f; + bool apx = dicHelper->checkObjectExist_json(options, "anchorPointX"); + float apxf = apx ? dicHelper->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + bool apy = dicHelper->checkObjectExist_json(options, "anchorPointY"); + float apyf = apy ? dicHelper->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); widget->setAnchorPoint(Point(apxf, apyf)); - bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); - bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); + bool flipX = dicHelper->getBooleanValue_json(options, "flipX"); + bool flipY = dicHelper->getBooleanValue_json(options, "flipY"); widget->setFlipX(flipX); widget->setFlipY(flipY); } -void CCSGUIReader::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UIButton* button = (UIButton*)widget; - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - button->setScale9Enabled(scale9Enable); - - std::string tp_n = m_strFilePath; - std::string tp_p = m_strFilePath; - std::string tp_d = m_strFilePath; - - const char* normalFileName = DICTOOL->getStringValue_json(options, "normal"); - const char* pressedFileName = DICTOOL->getStringValue_json(options, "pressed"); - const char* disabledFileName = DICTOOL->getStringValue_json(options, "disabled"); - - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - if (useMergedTexture) - { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - button->setCapInsets(Rect(cx, cy, cw, ch)); - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - button->setSize(Size(swf, shf)); - } - } - else - { - if (useMergedTexture) - { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UIButton* button = (UIButton*)widget; - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - button->setScale9Enabled(scale9Enable); - - JsonDictionary* normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = m_strFilePath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - button->loadTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(normalDic); - JsonDictionary* pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = m_strFilePath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - button->loadTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(pressedDic); - JsonDictionary* disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = m_strFilePath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - button->loadTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(disabledDic); - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - button->setCapInsets(Rect(cx, cy, cw, ch)); - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - button->setSize(Size(swf, shf)); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UICheckBox* checkBox = (UICheckBox*)widget; - const char* backGroundFileName = DICTOOL->getStringValue_json(options, "backGroundBox"); - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(options, "backGroundBoxSelected"); - const char* frontCrossFileName = DICTOOL->getStringValue_json(options, "frontCross"); - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(options, "backGroundBoxDisabled"); - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "frontCrossDisabled"); - - - std::string tp_b = m_strFilePath; - std::string tp_bs = m_strFilePath; - std::string tp_c = m_strFilePath; - std::string tp_bd = m_strFilePath; - std::string tp_cd = m_strFilePath; - - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - - if (useMergedTexture) - { - checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp); - } - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UICheckBox* checkBox = (UICheckBox*)widget; - - JsonDictionary* backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); - int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); - switch (backGroundType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; - checkBox->loadTextureBackGround(backGroundFileName_tp); - break; - } - case 1: - { - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundDic); - - JsonDictionary* backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); - int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); - switch (backGroundSelectedType) - { - case 0: - { - std::string tp_bs = m_strFilePath; - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); - break; - } - case 1: - { - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundSelectedDic); - - JsonDictionary* frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); - int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); - switch (frontCrossType) - { - case 0: - { - std::string tp_c = m_strFilePath; - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; - checkBox->loadTextureFrontCross(frontCrossFileName_tp); - break; - } - case 1: - { - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(frontCrossDic); - - JsonDictionary* backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); - int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); - switch (backGroundDisabledType) - { - case 0: - { - std::string tp_bd = m_strFilePath; - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); - break; - } - case 1: - { - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundDisabledDic); - - JsonDictionary* frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); - int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); - switch (frontCrossDisabledType) - { - case 0: - { - std::string tp_cd = m_strFilePath; - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); - break; - } - case 1: - { - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(frontCrossDisabledDic); - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UIImageView* imageView = (UIImageView*)widget; - const char* imageFileName = DICTOOL->getStringValue_json(options, "fileName"); - bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); - bool scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - } - imageView->setScale9Enabled(scale9Enable); - - std::string tp_i = m_strFilePath; - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - } - - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (scale9Enable) - { - if (useMergedTexture) - { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - imageView->loadTexture(imageFileName_tp); - } - - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - imageView->setSize(Size(swf, shf)); - } - - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - imageView->setCapInsets(Rect(cx, cy, cw, ch)); - - } - else - { - if (useMergedTexture) - { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - imageView->loadTexture(imageFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UIImageView* imageView = (UIImageView*)widget; - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - imageView->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); - bool scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - } - imageView->setScale9Enabled(scale9Enable); - - - if (scale9Enable) - { - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - imageView->setSize(Size(swf, shf)); - } - - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - imageView->setCapInsets(Rect(cx, cy, cw, ch)); - - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILabel* label = (UILabel*)widget; - bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); - label->setTouchScaleChangeEnabled(touchScaleChangeAble); - const char* text = DICTOOL->getStringValue_json(options, "text"); - label->setText(text); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); + UIButton* button = (UIButton*)widget; + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + button->setScale9Enabled(scale9Enable); + + JsonDictionary* normalDic = dicHelper->getSubDictionary_json(options, "normalData"); + int normalType = dicHelper->getIntValue_json(normalDic, "resourceType"); + switch (normalType) + { + case 0: + { + std::string tp_n = m_strFilePath; + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + button->loadTextureNormal(normalFileName_tp); + break; + } + case 1: + { + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(normalDic); + JsonDictionary* pressedDic = dicHelper->getSubDictionary_json(options, "pressedData"); + int pressedType = dicHelper->getIntValue_json(pressedDic, "resourceType"); + switch (pressedType) + { + case 0: + { + std::string tp_p = m_strFilePath; + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + button->loadTexturePressed(pressedFileName_tp); + break; + } + case 1: + { + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(pressedDic); + JsonDictionary* disabledDic = dicHelper->getSubDictionary_json(options, "disabledData"); + int disabledType = dicHelper->getIntValue_json(disabledDic, "resourceType"); + switch (disabledType) + { + case 0: + { + std::string tp_d = m_strFilePath; + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + button->loadTextureDisabled(disabledFileName_tp); + break; + } + case 1: + { + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(disabledDic); + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + button->setCapInsets(Rect(cx, cy, cw, ch)); + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + button->setSize(Size(swf, shf)); + } + } + bool tt = dicHelper->checkObjectExist_json(options, "text"); + if (tt) + { + const char* text = dicHelper->getStringValue_json(options, "text"); + if (text) + { + button->setTitleText(text); + } + } + + bool cr = dicHelper->checkObjectExist_json(options, "textColorR"); + bool cg = dicHelper->checkObjectExist_json(options, "textColorG"); + bool cb = dicHelper->checkObjectExist_json(options, "textColorB"); + int cri = cr?dicHelper->getIntValue_json(options, "textColorR"):255; + int cgi = cg?dicHelper->getIntValue_json(options, "textColorG"):255; + int cbi = cb?dicHelper->getIntValue_json(options, "textColorB"):255; + button->setTitleColor(Color3B(cri,cgi,cbi)); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); if (fs) { - label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); + button->setTitleFontSize(dicHelper->getIntValue_json(options, "fontSize")); } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); if (fn) { - label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); + button->setTitleFontName(dicHelper->getStringValue_json(options, "fontName")); } - bool cro = DICTOOL->checkObjectExist_json(options, "colorR"); - bool cgo = DICTOOL->checkObjectExist_json(options, "colorG"); - bool cbo = DICTOOL->checkObjectExist_json(options, "colorB"); - int cr = cro?DICTOOL->getIntValue_json(options, "colorR"):255; - int cg = cgo?DICTOOL->getIntValue_json(options, "colorG"):255; - int cb = cbo?DICTOOL->getIntValue_json(options, "colorB"):255; - Color3B tc = Color3B(cr, cg, cb); - label->setColor(tc); setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { - if (m_bOlderVersion) + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UICheckBox* checkBox = (UICheckBox*)widget; + + JsonDictionary* backGroundDic = dicHelper->getSubDictionary_json(options, "backGroundBoxData"); + int backGroundType = dicHelper->getIntValue_json(backGroundDic, "resourceType"); + switch (backGroundType) { - setPropsForWidgetFromJsonDictionary(widget, options); - UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; - bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); - bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); - bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); - bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); - bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); - if (sv && cmf && iw && ih && scm && (strcmp(DICTOOL->getStringValue_json(options, "charMapFile"), "") != 0)) + case 0: + { + std::string tp_b = m_strFilePath; + const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path"); + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; + checkBox->loadTextureBackGround(backGroundFileName_tp); + break; + } + case 1: + { + const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path"); + checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundDic); + + JsonDictionary* backGroundSelectedDic = dicHelper->getSubDictionary_json(options, "backGroundBoxSelectedData"); + int backGroundSelectedType = dicHelper->getIntValue_json(backGroundSelectedDic, "resourceType"); + switch (backGroundSelectedType) + { + case 0: + { + std::string tp_bs = m_strFilePath; + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path"); + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; + checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); + break; + } + case 1: + { + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path"); + checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundSelectedDic); + + JsonDictionary* frontCrossDic = dicHelper->getSubDictionary_json(options, "frontCrossData"); + int frontCrossType = dicHelper->getIntValue_json(frontCrossDic, "resourceType"); + switch (frontCrossType) + { + case 0: { std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; - const char* cmft = DICTOOL->getStringValue_json(options, "charMapFile"); - cmf_tp = tp_c.append(cmft).c_str(); - - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"),DICTOOL->getStringValue_json(options, "startCharMap")); + const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path"); + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; + checkBox->loadTextureFrontCross(frontCrossFileName_tp); + break; } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; - bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); - bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); - bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); - bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); - bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); - if (sv && cmf && iw && ih && scm) + case 1: { - - JsonDictionary* cmftDic = DICTOOL->getSubDictionary_json(options, "charMapFileData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); - switch (cmfType) - { - case 0: - { - std::string tp_c = m_strFilePath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); - const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"),DICTOOL->getStringValue_json(options, "startCharMap")); - break; - } - case 1: - CCLOG("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - CC_SAFE_DELETE(cmftDic); + const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path"); + checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); + break; } - setColorPropsForWidgetFromJsonDictionary(widget,options); + default: + break; } + CC_SAFE_DELETE(frontCrossDic); + + JsonDictionary* backGroundDisabledDic = dicHelper->getSubDictionary_json(options, "backGroundBoxDisabledData"); + int backGroundDisabledType = dicHelper->getIntValue_json(backGroundDisabledDic, "resourceType"); + switch (backGroundDisabledType) + { + case 0: + { + std::string tp_bd = m_strFilePath; + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path"); + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); + break; + } + case 1: + { + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path"); + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundDisabledDic); + + JsonDictionary* frontCrossDisabledDic = dicHelper->getSubDictionary_json(options, "frontCrossDisabledData"); + int frontCrossDisabledType = dicHelper->getIntValue_json(frontCrossDisabledDic, "resourceType"); + switch (frontCrossDisabledType) + { + case 0: + { + std::string tp_cd = m_strFilePath; + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path"); + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); + break; + } + case 1: + { + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path"); + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(frontCrossDisabledDic); + + setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForContainerWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILayout* containerWidget = (UILayout*)widget; - if (!dynamic_cast(containerWidget) - && !dynamic_cast(containerWidget)) + + UIImageView* imageView = (UIImageView*)widget; + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "fileNameData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) { - containerWidget->setClippingEnabled(DICTOOL->getBooleanValue_json(options, "clipAble")); + case 0: + { + std::string tp_i = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + imageView->loadTexture(imageFileName_tp); + } + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + bool scale9EnableExist = dicHelper->checkObjectExist_json(options, "scale9Enable"); + bool scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + } + imageView->setScale9Enabled(scale9Enable); + + + if (scale9Enable) + { + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + imageView->setSize(Size(swf, shf)); + } + + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + imageView->setCapInsets(Rect(cx, cy, cw, ch)); + } setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForPanelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForContainerWidgetFromJsonDictionary(widget, options); - UILayout* panel = (UILayout*)widget; - bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); - panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, "bgColorR"); - int cg = DICTOOL->getIntValue_json(options, "bgColorG"); - int cb = DICTOOL->getIntValue_json(options, "bgColorB"); - - int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); - int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); - int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); - - int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); - int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); - int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); - - float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); - float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); - - int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); - - int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); -// float w = DICTOOL->getFloatValue_json(options, "width"); -// float h = DICTOOL->getFloatValue_json(options, "height"); - panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); - panel->setBackGroundColor(Color3B(cr, cg, cb)); - panel->setBackGroundColorOpacity(co); -// panel->setSize(CCSizeMake(w, h)); - - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "backGroundImage"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (backGroundScale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - if (useMergedTexture) - { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - panel->setBackGroundImage(imageFileName_tp); - } - panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); - } - else - { - - if (useMergedTexture) - { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - panel->setBackGroundImage(imageFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForContainerWidgetFromJsonDictionary(widget, options); - UILayout* panel = (UILayout*)widget; - bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); - panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, "bgColorR"); - int cg = DICTOOL->getIntValue_json(options, "bgColorG"); - int cb = DICTOOL->getIntValue_json(options, "bgColorB"); - - int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); - int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); - int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); - - int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); - int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); - int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); - - float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); - float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); - - int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); - - int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); -// float w = DICTOOL->getFloatValue_json(options, "width"); -// float h = DICTOOL->getFloatValue_json(options, "height"); - panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); - panel->setBackGroundColor(Color3B(cr, cg, cb)); - panel->setBackGroundColorOpacity(co); -// panel->setSize(CCSizeMake(w, h)); - - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - panel->setBackGroundImage(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - if (backGroundScale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForPanelFromJsonDictionary(widget, options); - UIScrollView* scrollView = (UIScrollView*)widget; - float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); - float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); - scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); - /* gui mark */ - int direction = DICTOOL->getFloatValue_json(options, "direction"); - scrollView->setDirection((SCROLLVIEW_DIR)direction); - /**/ - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UISlider* slider = (UISlider*)widget; - - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); - slider->setScale9Enabled(barTextureScale9Enable); - bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); - float barLength = DICTOOL->getFloatValue_json(options, "length"); - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (bt) - { - if (barTextureScale9Enable) - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadBarTexture(imageFileName_tp); - } - slider->setSize(Size(barLength, slider->getContentSize().height)); - } - else - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadBarTexture(imageFileName_tp); - } - } - } - std::string tp_n = m_strFilePath; - std::string tp_p = m_strFilePath; - std::string tp_d = m_strFilePath; - - const char* normalFileName = DICTOOL->getStringValue_json(options, "ballNormal"); - const char* pressedFileName = DICTOOL->getStringValue_json(options, "ballPressed"); - const char* disabledFileName = DICTOOL->getStringValue_json(options, "ballDisabled"); - - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); - } - slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "progressBarFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); - } - else - { - slider->loadProgressBarTexture(imageFileName_tp); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UISlider* slider = (UISlider*)widget; - - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); - slider->setScale9Enabled(barTextureScale9Enable); - bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); - float barLength = DICTOOL->getFloatValue_json(options, "length"); - if (bt) - { - if (barTextureScale9Enable) - { - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - slider->setSize(Size(barLength, slider->getContentSize().height)); - CC_SAFE_DELETE(imageFileNameDic); - } - else - { - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - } - } -// std::string tp_n = m_strFilePath; -// std::string tp_p = m_strFilePath; -// std::string tp_d = m_strFilePath; -// -// const char* normalFileName = DICTOOL->getStringValue_json(options, "ballNormal"); -// const char* pressedFileName = DICTOOL->getStringValue_json(options, "ballPressed"); -// const char* disabledFileName = DICTOOL->getStringValue_json(options, "ballDisabled"); -// -// const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; -// const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; -// const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; -// if (useMergedTexture) -// { -// slider->setSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); -// } -// else -// { -// slider->setSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); -// } - - JsonDictionary* normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = m_strFilePath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - slider->loadSlidBallTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(normalDic); - - JsonDictionary* pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = m_strFilePath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - slider->loadSlidBallTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(pressedDic); - - JsonDictionary* disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = m_strFilePath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - slider->loadSlidBallTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(disabledDic); - - slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - JsonDictionary* progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); - int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); - switch (progressBarType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadProgressBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForTextAreaFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILabel* textArea = (UILabel*)widget; - textArea->setText(DICTOOL->getStringValue_json(options, "text")); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); + UILabel* label = (UILabel*)widget; + bool touchScaleChangeAble = dicHelper->getBooleanValue_json(options, "touchScaleEnable"); + label->setTouchScaleChangeEnabled(touchScaleChangeAble); + const char* text = dicHelper->getStringValue_json(options, "text"); + label->setText(text); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); if (fs) { - textArea->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); + label->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); } - int cr = DICTOOL->getIntValue_json(options, "colorR"); - int cg = DICTOOL->getIntValue_json(options, "colorG"); - int cb = DICTOOL->getIntValue_json(options, "colorB"); - textArea->setColor(Color3B(cr, cg, cb)); - textArea->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); - bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + label->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool aw = dicHelper->checkObjectExist_json(options, "areaWidth"); + bool ah = dicHelper->checkObjectExist_json(options, "areaHeight"); if (aw && ah) { - Size size = Size(DICTOOL->getFloatValue_json(options, "areaWidth"),DICTOOL->getFloatValue_json(options,"areaHeight")); - textArea->setTextAreaSize(size); + Size size = Size(dicHelper->getFloatValue_json(options, "areaWidth"),dicHelper->getFloatValue_json(options,"areaHeight")); + label->setTextAreaSize(size); } - bool ha = DICTOOL->checkObjectExist_json(options, "hAlignment"); + bool ha = dicHelper->checkObjectExist_json(options, "hAlignment"); if (ha) { - textArea->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, "hAlignment")); + label->setTextHorizontalAlignment((TextHAlignment)dicHelper->getIntValue_json(options, "hAlignment")); } - bool va = DICTOOL->checkObjectExist_json(options, "vAlignment"); + bool va = dicHelper->checkObjectExist_json(options, "vAlignment"); if (va) { - textArea->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, "vAlignment")); + label->setTextVerticalAlignment((TextVAlignment)dicHelper->getIntValue_json(options, "vAlignment")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForTextButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForButtonFromJsonDictionary(widget, options); - - - UIButton* textButton = (UIButton*)widget; - textButton->setTitleText(DICTOOL->getStringValue_json(options, "text")); - bool cr = DICTOOL->checkObjectExist_json(options, "textColorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "textColorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "textColorB"); - int cri = cr?DICTOOL->getIntValue_json(options, "textColorR"):255; - int cgi = cg?DICTOOL->getIntValue_json(options, "textColorG"):255; - int cbi = cb?DICTOOL->getIntValue_json(options, "textColorB"):255; - textButton->setTitleColor(Color3B(cri,cgi,cbi)); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - textButton->setTitleFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - textButton->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UITextField* textField = (UITextField*)widget; - bool ph = DICTOOL->checkObjectExist_json(options, "placeHolder"); - if (ph) + UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; + bool sv = dicHelper->checkObjectExist_json(options, "stringValue"); + bool cmf = dicHelper->checkObjectExist_json(options, "charMapFile"); + bool iw = dicHelper->checkObjectExist_json(options, "itemWidth"); + bool ih = dicHelper->checkObjectExist_json(options, "itemHeight"); + bool scm = dicHelper->checkObjectExist_json(options, "startCharMap"); + if (sv && cmf && iw && ih && scm) { - textField->setPlaceHolder(DICTOOL->getStringValue_json(options, "placeHolder")); - } - textField->setText(DICTOOL->getStringValue_json(options, "text")); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - textField->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); - bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); - if (tsw && tsh) - { - textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, "touchSizeWidth"), DICTOOL->getFloatValue_json(options,"touchSizeHeight"))); - } - - float dw = DICTOOL->getFloatValue_json(options, "width"); - float dh = DICTOOL->getFloatValue_json(options, "height"); - if (dw > 0.0f || dh > 0.0f) - { - //textField->setSize(CCSizeMake(dw, dh)); - } - bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, "maxLengthEnable"); - textField->setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) - { - int maxLength = DICTOOL->getIntValue_json(options, "maxLength"); - textField->setMaxLength(maxLength); - } - bool passwordEnable = DICTOOL->getBooleanValue_json(options, "passwordEnable"); - textField->setPasswordEnabled(passwordEnable); - if (passwordEnable) - { - textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, "passwordStyleText")); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILoadingBar* loadingBar = (UILoadingBar*)widget; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - std::string tp_b = m_strFilePath; - const char*imageFileName = DICTOOL->getStringValue_json(options, "texture"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - loadingBar->loadTexture(imageFileName_tp); - } - loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILoadingBar* loadingBar = (UILoadingBar*)widget; - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - loadingBar->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - /* gui mark add load bar scale9 parse */ - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - loadingBar->setScale9Enabled(scale9Enable); - - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); - - float width = DICTOOL->getFloatValue_json(options, "width"); - float height = DICTOOL->getFloatValue_json(options, "height"); - loadingBar->setSize(Size(width, height)); - } - /**/ - - loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForListViewFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - setPropsForScrollViewFromJsonDictionary(widget, options); -} - -void CCSGUIReader::setPropsForPageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForPanelFromJsonDictionary(widget, options); - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; - - std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; - const char* cmft = DICTOOL->getStringValue_json(options, "fileName"); - cmf_tp = tp_c.append(cmft).c_str(); - - labelBMFont->setFntFile(cmf_tp); - - const char* text = DICTOOL->getStringValue_json(options, "text"); - labelBMFont->setText(text); - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; - - JsonDictionary* cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); + JsonDictionary* cmftDic = dicHelper->getSubDictionary_json(options, "charMapFileData"); + int cmfType = dicHelper->getIntValue_json(cmftDic, "resourceType"); switch (cmfType) { case 0: { std::string tp_c = m_strFilePath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); + const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelBMFont->setFntFile(cmf_tp); + labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); break; } case 1: @@ -1563,28 +1490,406 @@ void CCSGUIReader::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, Js break; } CC_SAFE_DELETE(cmftDic); - - const char* text = DICTOOL->getStringValue_json(options, "text"); - labelBMFont->setText(text); - - setColorPropsForWidgetFromJsonDictionary(widget,options); } + setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForDragPanelFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { - setPropsForPanelFromJsonDictionary(widget, options); + DictionaryHelper* dicHelper = DICTOOL; - UIScrollView* dragPanel = (UIScrollView*)widget; + setPropsForWidgetFromJsonDictionary(widget, options); + UILayout* panel = (UILayout*)widget; + if (!dynamic_cast(widget) + && !dynamic_cast(widget)) + { + panel->setClippingEnabled(dicHelper->getBooleanValue_json(options, "clipAble")); + } + bool backGroundScale9Enable = dicHelper->getBooleanValue_json(options, "backGroundScale9Enable"); + panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); + int cr = dicHelper->getIntValue_json(options, "bgColorR"); + int cg = dicHelper->getIntValue_json(options, "bgColorG"); + int cb = dicHelper->getIntValue_json(options, "bgColorB"); - bool bounceEnable = DICTOOL->getBooleanValue_json(options, "bounceEnable"); - dragPanel->setBounceEnabled(bounceEnable); + int scr = dicHelper->getIntValue_json(options, "bgStartColorR"); + int scg = dicHelper->getIntValue_json(options, "bgStartColorG"); + int scb = dicHelper->getIntValue_json(options, "bgStartColorB"); - float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); - float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); - dragPanel->setInnerContainerSize(Size(innerWidth, innerHeight)); + int ecr = dicHelper->getIntValue_json(options, "bgEndColorR"); + int ecg = dicHelper->getIntValue_json(options, "bgEndColorG"); + int ecb = dicHelper->getIntValue_json(options, "bgEndColorB"); - setColorPropsForWidgetFromJsonDictionary(widget, options); + float bgcv1 = dicHelper->getFloatValue_json(options, "vectorX"); + float bgcv2 = dicHelper->getFloatValue_json(options, "vectorY"); + panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); + + int co = dicHelper->getIntValue_json(options, "bgColorOpacity"); + + int colorType = dicHelper->getIntValue_json(options, "colorType"); + panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); + panel->setBackGroundColor(Color3B(cr, cg, cb)); + panel->setBackGroundColorOpacity(co); + + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "backGroundImageData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + panel->setBackGroundImage(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + if (backGroundScale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); } +void WidgetPropertiesReader0300::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForLayoutFromJsonDictionary(widget, options); + UIScrollView* scrollView = (UIScrollView*)widget; + float innerWidth = dicHelper->getFloatValue_json(options, "innerWidth"); + float innerHeight = dicHelper->getFloatValue_json(options, "innerHeight"); + scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); + int direction = dicHelper->getFloatValue_json(options, "direction"); + scrollView->setDirection((SCROLLVIEW_DIR)direction); + scrollView->setBounceEnabled(dicHelper->getBooleanValue_json(options, "bounceEnable")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UISlider* slider = (UISlider*)widget; + + bool barTextureScale9Enable = dicHelper->getBooleanValue_json(options, "barTextureScale9Enable"); + slider->setScale9Enabled(barTextureScale9Enable); + bool bt = dicHelper->checkObjectExist_json(options, "barFileName"); + float barLength = dicHelper->getFloatValue_json(options, "length"); + if (bt) + { + if (barTextureScale9Enable) + { + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "barFileNameData"); + int imageFileType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + + slider->setSize(Size(barLength, slider->getContentSize().height)); + CC_SAFE_DELETE(imageFileNameDic); + } + else + { + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "barFileNameData"); + int imageFileType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + } + } + + JsonDictionary* normalDic = dicHelper->getSubDictionary_json(options, "ballNormalData"); + int normalType = dicHelper->getIntValue_json(normalDic, "resourceType"); + switch (normalType) + { + case 0: + { + std::string tp_n = m_strFilePath; + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + slider->loadSlidBallTextureNormal(normalFileName_tp); + break; + } + case 1: + { + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(normalDic); + + JsonDictionary* pressedDic = dicHelper->getSubDictionary_json(options, "ballPressedData"); + int pressedType = dicHelper->getIntValue_json(pressedDic, "resourceType"); + switch (pressedType) + { + case 0: + { + std::string tp_p = m_strFilePath; + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + slider->loadSlidBallTexturePressed(pressedFileName_tp); + break; + } + case 1: + { + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(pressedDic); + + JsonDictionary* disabledDic = dicHelper->getSubDictionary_json(options, "ballDisabledData"); + int disabledType = dicHelper->getIntValue_json(disabledDic, "resourceType"); + switch (disabledType) + { + case 0: + { + std::string tp_d = m_strFilePath; + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + slider->loadSlidBallTextureDisabled(disabledFileName_tp); + break; + } + case 1: + { + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(disabledDic); + + slider->setPercent(dicHelper->getIntValue_json(options, "percent")); + + JsonDictionary* progressBarDic = dicHelper->getSubDictionary_json(options, "progressBarData"); + int progressBarType = dicHelper->getIntValue_json(progressBarDic, "resourceType"); + switch (progressBarType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadProgressBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path"); + slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UITextField* textField = (UITextField*)widget; + bool ph = dicHelper->checkObjectExist_json(options, "placeHolder"); + if (ph) + { + textField->setPlaceHolder(dicHelper->getStringValue_json(options, "placeHolder")); + } + textField->setText(dicHelper->getStringValue_json(options, "text")); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + textField->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + textField->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool tsw = dicHelper->checkObjectExist_json(options, "touchSizeWidth"); + bool tsh = dicHelper->checkObjectExist_json(options, "touchSizeHeight"); + if (tsw && tsh) + { + textField->setTouchSize(Size(dicHelper->getFloatValue_json(options, "touchSizeWidth"), dicHelper->getFloatValue_json(options,"touchSizeHeight"))); + } + + float dw = dicHelper->getFloatValue_json(options, "width"); + float dh = dicHelper->getFloatValue_json(options, "height"); + if (dw > 0.0f || dh > 0.0f) + { + //textField->setSize(Size(dw, dh)); + } + bool maxLengthEnable = dicHelper->getBooleanValue_json(options, "maxLengthEnable"); + textField->setMaxLengthEnabled(maxLengthEnable); + + if (maxLengthEnable) + { + int maxLength = dicHelper->getIntValue_json(options, "maxLength"); + textField->setMaxLength(maxLength); + } + bool passwordEnable = dicHelper->getBooleanValue_json(options, "passwordEnable"); + textField->setPasswordEnabled(passwordEnable); + if (passwordEnable) + { + textField->setPasswordStyleText(dicHelper->getStringValue_json(options, "passwordStyleText")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILoadingBar* loadingBar = (UILoadingBar*)widget; + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "textureData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) + { + case 0: + { + std::string tp_i = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + loadingBar->loadTexture(imageFileName_tp); + } + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + /* gui mark add load bar scale9 parse */ + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + loadingBar->setScale9Enabled(scale9Enable); + + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); + + float width = dicHelper->getFloatValue_json(options, "width"); + float height = dicHelper->getFloatValue_json(options, "height"); + loadingBar->setSize(Size(width, height)); + } + /**/ + + loadingBar->setDirection(LoadingBarType(dicHelper->getIntValue_json(options, "direction"))); + loadingBar->setPercent(dicHelper->getIntValue_json(options, "percent")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + + UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; + + JsonDictionary* cmftDic = dicHelper->getSubDictionary_json(options, "fileNameData"); + int cmfType = dicHelper->getIntValue_json(cmftDic, "resourceType"); + switch (cmfType) + { + case 0: + { + std::string tp_c = m_strFilePath; + const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); + const char* cmf_tp = tp_c.append(cmfPath).c_str(); + labelBMFont->setFntFile(cmf_tp); + break; + } + case 1: + CCLOG("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + CC_SAFE_DELETE(cmftDic); + + const char* text = dicHelper->getStringValue_json(options, "text"); + labelBMFont->setText(text); + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + +} + +void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(UIWidget* widget, JsonDictionary* options) +{ + +} } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 415b7b9e81..19a37292fd 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -31,49 +31,90 @@ namespace cocostudio { #define kCCSVersion 1.0 -class CCSGUIReader : cocos2d::Object +class GUIReader : public cocos2d::Object { public: - CCSGUIReader(); - ~CCSGUIReader(); - static CCSGUIReader* shareReader(); - static void purgeCCSGUIReader(); + GUIReader(); + ~GUIReader(); + static GUIReader* shareReader(); + static void purgeGUIReader(); gui::UIWidget* widgetFromJsonFile(const char* fileName); - gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* data); - int getVersionInteger(const char* str); - - void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForContainerWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextAreaFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForImageButtonFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); - void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); - void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForDragPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void storeFileDesignSize(const char* fileName, const cocos2d::Size &size); - const cocos2d::Size getFileDesignSize(const char* fileName) const; protected: std::string m_strFilePath; - bool m_bOlderVersion; cocos2d::Dictionary* _fileDesignSizes; }; +class WidgetPropertiesReader : public cocos2d::Object +{ +public: + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName)=0; + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic) = 0; +protected: + std::string m_strFilePath; +}; + + +class WidgetPropertiesReader0250 : public WidgetPropertiesReader +{ + + +public: + WidgetPropertiesReader0250(){}; + virtual ~WidgetPropertiesReader0250(){}; + + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName); + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic); + virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); +}; + +class WidgetPropertiesReader0300 : public WidgetPropertiesReader +{ + + +public: + WidgetPropertiesReader0300(){}; + virtual ~WidgetPropertiesReader0300(){}; + + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName); + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic); + virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); +}; + + } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index a2a3ddcf42..10b482311a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -26,7 +26,7 @@ bool UIScene::init() m_pUiLayer = UILayer::create(); addChild(m_pUiLayer); - m_pWidget = dynamic_cast(cocostudio::CCSGUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); + m_pWidget = dynamic_cast(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); m_pUiLayer->addWidget(m_pWidget); m_pSceneTitle = dynamic_cast(m_pUiLayer->getWidgetByName("UItest")); From d75c96443dbf9256c3a992ab906840d3dbec69fa Mon Sep 17 00:00:00 2001 From: boyu0 Date: Mon, 11 Nov 2013 18:28:59 +0800 Subject: [PATCH 104/185] issue #2770: fix some warning --- cocos/editor-support/cocosbuilder/CCBReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index d0a70c225b..b369a564ee 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -387,7 +387,7 @@ bool CCBReader::readHeader() int magicBytes = *((int*)(this->_bytes + this->_currentByte)); this->_currentByte += 4; - if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != 'ccbi') { + if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != (*reinterpret_cast("ccbi"))) { return false; } From df214acb6f062a5f5aa0e06605de89c6b71d157b Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 18:42:39 +0800 Subject: [PATCH 105/185] [develop] Updating bindings-generator, fixing forward declare that generates binding glue codes which is an empty class. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 9797d44032..cad9d9ec4a 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 9797d4403207848f431d5b6456632cc966d84b0d +Subproject commit cad9d9ec4a24bdad1de383c941afa9418501161e From 3472d7ad50be0f61135949f06714f5bc4de9afde Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 11 Nov 2013 10:57:57 +0000 Subject: [PATCH 106/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 5788b25003..ce2f223cd3 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 5788b2500339473ecc19acf1c2e43656a2537a6d +Subproject commit ce2f223cd3b4bffbd564df37c738fc5b18f8d853 From d6446e9b14951fb49764a6fed7d31cb1213f74df Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 16:07:46 -0800 Subject: [PATCH 107/185] calls `delete[]` instead of `delete` calls `delete[]` instead of `delete` --- cocos/2d/platform/ios/CCDevice.mm | 6 ++++-- cocos/physics/CCPhysicsShape.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos/2d/platform/ios/CCDevice.mm b/cocos/2d/platform/ios/CCDevice.mm index 4555b14df2..e8610db653 100644 --- a/cocos/2d/platform/ios/CCDevice.mm +++ b/cocos/2d/platform/ios/CCDevice.mm @@ -37,8 +37,10 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; - (id) init { - _acceleration = new cocos2d::Acceleration(); - _motionManager = [[CMMotionManager alloc] init]; + if( (self = [super init]) ) { + _acceleration = new cocos2d::Acceleration(); + _motionManager = [[CMMotionManager alloc] init]; + } return self; } diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index bb043b027a..91df06d1ea 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -539,7 +539,7 @@ bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMate cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); CC_BREAK_IF(shape == nullptr); @@ -563,7 +563,7 @@ float PhysicsShapePolygon::calculateArea(const Point* points, int count) cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return area; } @@ -574,7 +574,7 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int PhysicsHelper::points2cpvs(points, vecs, count); float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return moment; } From a5eeff4f4fdaec575914470519174e6f89a6e382 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 16:09:32 -0800 Subject: [PATCH 108/185] fixes for android create improves the message. fixes some grammar errors --- build/android-build.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build/android-build.py b/build/android-build.py index c630010ef8..4a65c9e6e2 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -15,11 +15,12 @@ ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES def usage(): - print "%prog [-n ndk-build-parameter] target\n\ - valid target are [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon\ -|crystalcraze|moonwarriors|testjavascript|watermelonwithme], of course you can use 'cpp'\ -to build all cpp samples, 'lua' to build all lua samples, 'jsb' to build all javascript samples,\ - and 'all' for all samples" + print """%s [-n ndk-build-parameter] target. + +Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon + |crystalcraze|moonwarriors|testjavascript|watermelonwithme] + +You can use [all|cpp|lua|jsb], to build all, or all the C++, or all the Lua, or all the JavaScript samples respectevely.""" % sys.argv[0] def check_environment_variables(): ''' Checking the environment NDK_ROOT, which will be used for building From d7a0787336adbdade7f2bb1cd9b42e6eb84dead5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 09:44:07 +0800 Subject: [PATCH 109/185] Up --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d553c07d24..f8e3957968 100644 --- a/AUTHORS +++ b/AUTHORS @@ -642,6 +642,7 @@ Developers: ledyba Fixed a bug that EventListeners can't be removed sometimes. Fixed a bug that the data size has to be specified when parsing XML using TinyXML. + Closed X display after getting DPI on Linux. Luis Parravicini (luisparravicini) Fixed typos in create_project.py. From 412712c5e4737394b8f7a13452c7eec60d695f4b Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 09:45:07 +0800 Subject: [PATCH 110/185] Update CHANGELOG[ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e9e1da977c..e7632e9061 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -34,6 +34,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox. [Linux] [NEW] Used CMake to build linux projects. + [FIX] Closed X display after getting DPI on Linux. [Desktop] [FIX] Trigger onKeyReleased only after the key has been released. [Javascript binding] From be64dd97cf659e50fddbca846da1efabd7b50c5b Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 18:09:47 -0800 Subject: [PATCH 111/185] replaces `delete[]` with `free()` in C-based API API that returns a newly allocated buffer as an output argument (not return value) are error-prone. - Users forget to release the newly allocated buffer - Or the call `delete` instead of `delete[]` But some of those API need to call `realloc` on the buffer. But `realloc` is only valid if the buffer was previously allocated with `malloc`. If a buffer needs to be re-allocated using a C++ API, then `std::vector` should be used instead... So, this patch does: - Migrates the API from `new []` / `delete[]` to `malloc()` / `free()` - Fixes all the memory issues: incorrect deallocs and memory leaks - Updates the documentation - And fixes misc issues with the API: removes `cc` from the ZipUtils class. --- cocos/2d/CCFontFreeType.cpp | 2 +- cocos/2d/CCParticleSystem.cpp | 6 +- cocos/2d/CCTMXXMLParser.cpp | 6 +- cocos/2d/CCTextureCache.cpp | 2 +- cocos/2d/CCUserDefault.cpp | 9 +- cocos/2d/CCUserDefault.mm | 6 +- cocos/2d/CCUserDefaultAndroid.cpp | 18 ++-- cocos/2d/TGAlib.cpp | 2 +- cocos/2d/ZipUtils.cpp | 99 ++++++++++--------- cocos/2d/ZipUtils.h | 49 +++++---- cocos/2d/base64.cpp | 6 +- cocos/2d/base64.h | 4 +- cocos/2d/platform/CCFileUtils.cpp | 4 +- cocos/2d/platform/CCFileUtils.h | 4 +- cocos/2d/platform/CCImageCommon_cpp.h | 8 +- cocos/2d/platform/CCSAXParser.cpp | 2 +- cocos/base/CCString.cpp | 2 +- .../editor-support/cocosbuilder/CCBReader.cpp | 2 +- .../cocosbuilder/CCNodeLoader.cpp | 2 +- .../cocostudio/CCDataReaderHelper.cpp | 5 +- .../cocostudio/CCSGUIReader.cpp | 8 +- .../cocostudio/CCSSceneReader.cpp | 29 +++--- cocos/editor-support/spine/Atlas.cpp | 2 +- cocos/editor-support/spine/SkeletonJson.cpp | 2 +- .../javascript/bindings/ScriptingCore.cpp | 2 +- .../cocos2d_specifics.cpp.REMOVED.git-id | 2 +- .../lua/bindings/Cocos2dxLuaLoader.cpp | 2 +- .../TextureAtlasEncryptionTest.cpp | 8 +- 28 files changed, 150 insertions(+), 143 deletions(-) diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 5e2173204f..77f0b872d0 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -136,7 +136,7 @@ FontFreeType::~FontFreeType() } if (_ttfData) { - delete _ttfData; + free(_ttfData); _ttfData = nullptr; } } diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index cb2c4326f3..dd7bb47dd3 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -396,7 +396,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::strin CCASSERT( buffer != NULL, "CCParticleSystem: error decoding textureImageData"); CC_BREAK_IF(!buffer); - int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated); + int deflatedLen = ZipUtils::inflateMemory(buffer, decodeLen, &deflated); CCASSERT( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData"); CC_BREAK_IF(!deflated); @@ -420,8 +420,8 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::strin bRet = true; } } while (0); - CC_SAFE_DELETE_ARRAY(buffer); - CC_SAFE_DELETE_ARRAY(deflated); + free(buffer); + free(deflated); return bRet; } diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index d981cca6b4..5abe1e6f31 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -66,7 +66,7 @@ TMXLayerInfo::~TMXLayerInfo() CC_SAFE_RELEASE(_properties); if( _ownTiles && _tiles ) { - delete [] _tiles; + free(_tiles); _tiles = NULL; } } @@ -757,12 +757,12 @@ void TMXMapInfo::endElement(void *ctx, const char *name) // int sizeHint = s.width * s.height * sizeof(uint32_t); int sizeHint = (int)(s.width * s.height * sizeof(unsigned int)); - int inflatedLen = ZipUtils::ccInflateMemoryWithHint(buffer, len, &deflated, sizeHint); + int inflatedLen = ZipUtils::inflateMemoryWithHint(buffer, len, &deflated, sizeHint); CCASSERT(inflatedLen == sizeHint, ""); inflatedLen = (size_t)&inflatedLen; // XXX: to avoid warnings in compiler - delete [] buffer; + free(buffer); buffer = NULL; if( ! deflated ) diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index e4c9a0c8aa..15b30ccb6a 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -622,7 +622,7 @@ void VolatileTextureMgr::reloadAllTextures() Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); } - CC_SAFE_DELETE_ARRAY(pBuffer); + free(pBuffer); CC_SAFE_RELEASE(image); } break; diff --git a/cocos/2d/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp index 2104051f76..aa7a12f816 100644 --- a/cocos/2d/CCUserDefault.cpp +++ b/cocos/2d/CCUserDefault.cpp @@ -59,7 +59,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle *doc = xmlDoc; //CCFileData data(UserDefault::getInstance()->getXMLFilePath().c_str(),"rt"); long nSize; - const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize); + char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { @@ -67,7 +67,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle break; } xmlDoc->Parse(pXmlBuffer, nSize); - delete[] pXmlBuffer; + free(pXmlBuffer); // get root node *rootNode = xmlDoc->RootElement(); if (NULL == *rootNode) @@ -323,7 +323,7 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue) if (decodedData) { ret = Data::create(decodedData, decodedDataLen); - delete decodedData; + free(decodedData); } } @@ -408,7 +408,8 @@ void UserDefault::setDataForKey(const char* pKey, const Data& value) { setValueForKey(pKey, encodedData); - if (encodedData) delete encodedData; + if (encodedData) + free(encodedData); } UserDefault* UserDefault::getInstance() diff --git a/cocos/2d/CCUserDefault.mm b/cocos/2d/CCUserDefault.mm index da1c8827fd..e64f339b8d 100644 --- a/cocos/2d/CCUserDefault.mm +++ b/cocos/2d/CCUserDefault.mm @@ -74,7 +74,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; long size; - const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); + char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { @@ -82,7 +82,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc break; } xmlDoc->Parse(pXmlBuffer); - delete[] pXmlBuffer; + free(pXmlBuffer); // get root node rootNode = xmlDoc->RootElement(); if (NULL == rootNode) @@ -394,7 +394,7 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue) // set value in NSUserDefaults setDataForKey(pKey, ret); - delete decodedData; + free(decodedData); flush(); diff --git a/cocos/2d/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp index db18dd2951..510c83c14c 100644 --- a/cocos/2d/CCUserDefaultAndroid.cpp +++ b/cocos/2d/CCUserDefaultAndroid.cpp @@ -83,7 +83,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc break; } xmlDoc->Parse(pXmlBuffer); - delete[] pXmlBuffer; + free(pXmlBuffer); // get root node rootNode = xmlDoc->RootElement(); if (NULL == rootNode) @@ -367,10 +367,7 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue) // set value in NSUserDefaults setDataForKey(pKey, ret); - CC_SAFE_DELETE_ARRAY(decodedData); - - delete decodedData; - + free(decodedData); flush(); // delete xmle node @@ -392,9 +389,8 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue) string encodedStr = getStringForKeyJNI(pKey, encodedDefaultData); - if (encodedDefaultData) { - delete encodedDefaultData; - } + if (encodedDefaultData) + free(encodedDefaultData); CCLOG("ENCODED STRING: --%s--%d", encodedStr.c_str(), encodedStr.length()); @@ -408,6 +404,7 @@ Data* UserDefault::getDataForKey(const char* pKey, Data* defaultValue) if (decodedData && decodedDataLen) { ret = Data::create(decodedData, decodedDataLen); + free(decodedData); } CCLOG("RETURNED %p!", ret); @@ -475,9 +472,8 @@ void UserDefault::setDataForKey(const char* pKey, const Data& value) return setStringForKeyJNI(pKey, encodedData); - if (encodedData) { - delete encodedData; - } + if (encodedData) + free(encodedData); } // XXX: deprecated diff --git a/cocos/2d/TGAlib.cpp b/cocos/2d/TGAlib.cpp index 8725e765cb..160be2a907 100644 --- a/cocos/2d/TGAlib.cpp +++ b/cocos/2d/TGAlib.cpp @@ -270,7 +270,7 @@ tImageTGA * tgaLoad(const char *filename) } } while(0); - CC_SAFE_DELETE_ARRAY(pBuffer); + free(pBuffer); return info; } diff --git a/cocos/2d/ZipUtils.cpp b/cocos/2d/ZipUtils.cpp index 2e5d9fe43f..8bec015765 100644 --- a/cocos/2d/ZipUtils.cpp +++ b/cocos/2d/ZipUtils.cpp @@ -39,7 +39,7 @@ bool ZipUtils::s_bEncryptionKeyIsValid = false; // --------------------- ZipUtils --------------------- -inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, long len) +inline void ZipUtils::decodeEncodedPvr(unsigned int *data, long len) { const int enclen = 1024; const int securelen = 512; @@ -47,10 +47,10 @@ inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, long len) // check if key was set // make sure to call caw_setkey_part() for all 4 key parts - CCASSERT(s_uEncryptedPvrKeyParts[0] != 0, "Cocos2D: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?"); - CCASSERT(s_uEncryptedPvrKeyParts[1] != 0, "Cocos2D: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?"); - CCASSERT(s_uEncryptedPvrKeyParts[2] != 0, "Cocos2D: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?"); - CCASSERT(s_uEncryptedPvrKeyParts[3] != 0, "Cocos2D: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::ccSetPvrEncryptionKeyPart(...)?"); + CCASSERT(s_uEncryptedPvrKeyParts[0] != 0, "Cocos2D: CCZ file is encrypted but key part 0 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); + CCASSERT(s_uEncryptedPvrKeyParts[1] != 0, "Cocos2D: CCZ file is encrypted but key part 1 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); + CCASSERT(s_uEncryptedPvrKeyParts[2] != 0, "Cocos2D: CCZ file is encrypted but key part 2 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); + CCASSERT(s_uEncryptedPvrKeyParts[3] != 0, "Cocos2D: CCZ file is encrypted but key part 3 is not set. Did you call ZipUtils::setPvrEncryptionKeyPart(...)?"); // create long key if(!s_bEncryptionKeyIsValid) @@ -108,7 +108,7 @@ inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, long len) } } -inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, long len) +inline unsigned int ZipUtils::checksumPvr(const unsigned int *data, long len) { unsigned int cs = 0; const int cslen = 128; @@ -127,13 +127,13 @@ inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, long len) // Should buffer factor be 1.5 instead of 2 ? #define BUFFER_INC_FACTOR (2) -int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint) +int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint) { /* ret value */ int err = Z_OK; long bufferSize = outLenghtHint; - *out = new unsigned char[bufferSize]; + *out = (unsigned char*)malloc(bufferSize); z_stream d_stream; /* decompression stream */ d_stream.zalloc = (alloc_func)0; @@ -192,10 +192,10 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned return err; } -int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint) +int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint) { long outLength = 0; - int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint); + int err = inflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint); if (err != Z_OK || *out == NULL) { if (err == Z_MEM_ERROR) @@ -214,22 +214,24 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned { CCLOG("cocos2d: ZipUtils: Unknown error while decompressing map data!"); } - - delete[] *out; - *out = NULL; + + if(*out) { + free(*out); + *out = NULL; + } outLength = 0; } return outLength; } -int ZipUtils::ccInflateMemory(unsigned char *in, long inLength, unsigned char **out) +int ZipUtils::inflateMemory(unsigned char *in, long inLength, unsigned char **out) { // 256k for hint - return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024); + return inflateMemoryWithHint(in, inLength, out, 256 * 1024); } -int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out) +int ZipUtils::inflateGZipFile(const char *path, unsigned char **out) { int len; unsigned int offset = 0; @@ -299,7 +301,7 @@ int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out) return offset; } -bool ZipUtils::ccIsCCZFile(const char *path) +bool ZipUtils::isCCZFile(const char *path) { // load file into memory unsigned char* compressed = NULL; @@ -307,16 +309,19 @@ bool ZipUtils::ccIsCCZFile(const char *path) long fileLen = 0; compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen); - if(NULL == compressed || 0 == fileLen) + if(compressed == NULL || fileLen == 0) { CCLOG("cocos2d: ZipUtils: loading file failed"); return false; } - return ccIsCCZBuffer(compressed, fileLen); + bool ret = isCCZBuffer(compressed, fileLen); + free(compressed); + + return ret; } -bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len) +bool ZipUtils::isCCZBuffer(const unsigned char *buffer, long len) { if (len < sizeof(struct CCZHeader)) { @@ -328,7 +333,7 @@ bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len) } -bool ZipUtils::ccIsGZipFile(const char *path) +bool ZipUtils::isGZipFile(const char *path) { // load file into memory unsigned char* compressed = NULL; @@ -342,10 +347,12 @@ bool ZipUtils::ccIsGZipFile(const char *path) return false; } - return ccIsGZipBuffer(compressed, fileLen); + bool ret = isGZipBuffer(compressed, fileLen); + free(compressed); + return ret; } -bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, long len) +bool ZipUtils::isGZipBuffer(const unsigned char *buffer, long len) { if (len < 2) { @@ -356,7 +363,7 @@ bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, long len) } -int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsigned char **out) +int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsigned char **out) { struct CCZHeader *header = (struct CCZHeader*) buffer; @@ -402,11 +409,11 @@ int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, long bufferLen, un unsigned int* ints = (unsigned int*)(buffer+12); int enclen = (bufferLen-12)/4; - ccDecodeEncodedPvr(ints, enclen); + decodeEncodedPvr(ints, enclen); #if COCOS2D_DEBUG > 0 // verify checksum in debug mode - unsigned int calculated = ccChecksumPvr(ints, enclen); + unsigned int calculated = checksumPvr(ints, enclen); unsigned int required = CC_SWAP_INT32_BIG_TO_HOST( header->reserved ); if(calculated != required) @@ -446,7 +453,7 @@ int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, long bufferLen, un return len; } -int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) +int ZipUtils::inflateCCZFile(const char *path, unsigned char **out) { CCAssert(out, ""); CCAssert(&*out, ""); @@ -463,10 +470,12 @@ int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) return -1; } - return ccInflateCCZBuffer(compressed, fileLen, out); + int ret = inflateCCZBuffer(compressed, fileLen, out); + free(compressed); + return ret; } -void ZipUtils::ccSetPvrEncryptionKeyPart(int index, unsigned int value) +void ZipUtils::setPvrEncryptionKeyPart(int index, unsigned int value) { CCASSERT(index >= 0, "Cocos2d: key part index cannot be less than 0"); CCASSERT(index <= 3, "Cocos2d: key part index cannot be greater than 3"); @@ -478,12 +487,12 @@ void ZipUtils::ccSetPvrEncryptionKeyPart(int index, unsigned int value) } } -void ZipUtils::ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4) +void ZipUtils::setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4) { - ccSetPvrEncryptionKeyPart(0, keyPart1); - ccSetPvrEncryptionKeyPart(1, keyPart2); - ccSetPvrEncryptionKeyPart(2, keyPart3); - ccSetPvrEncryptionKeyPart(3, keyPart4); + setPvrEncryptionKeyPart(0, keyPart1); + setPvrEncryptionKeyPart(1, keyPart2); + setPvrEncryptionKeyPart(2, keyPart3); + setPvrEncryptionKeyPart(3, keyPart4); } // --------------------- ZipFile --------------------- @@ -582,14 +591,12 @@ bool ZipFile::fileExists(const std::string &fileName) const return ret; } -unsigned char *ZipFile::getFileData(const std::string &fileName, long *pSize) +unsigned char *ZipFile::getFileData(const std::string &fileName, long *size) { - unsigned char * pBuffer = NULL; - if (pSize) - { - *pSize = 0; - } - + unsigned char * buffer = NULL; + if (size) + *size = 0; + do { CC_BREAK_IF(!_data->zipFile); @@ -606,18 +613,18 @@ unsigned char *ZipFile::getFileData(const std::string &fileName, long *pSize) nRet = unzOpenCurrentFile(_data->zipFile); CC_BREAK_IF(UNZ_OK != nRet); - pBuffer = new unsigned char[fileInfo.uncompressed_size]; - int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, pBuffer, fileInfo.uncompressed_size); + buffer = (unsigned char*)malloc(fileInfo.uncompressed_size); + int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, buffer, fileInfo.uncompressed_size); CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong"); - if (pSize) + if (size) { - *pSize = fileInfo.uncompressed_size; + *size = fileInfo.uncompressed_size; } unzCloseCurrentFile(_data->zipFile); } while (0); - return pBuffer; + return buffer; } NS_CC_END diff --git a/cocos/2d/ZipUtils.h b/cocos/2d/ZipUtils.h index 48552502b4..b635da18c3 100644 --- a/cocos/2d/ZipUtils.h +++ b/cocos/2d/ZipUtils.h @@ -64,7 +64,7 @@ namespace cocos2d * @since v0.8.1 */ - static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out); + static int inflateMemory(unsigned char *in, long inLength, unsigned char **out); /** * Inflates either zlib or gzip deflated memory. The inflated memory is @@ -76,7 +76,7 @@ namespace cocos2d * @since v1.0.0 */ - static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLenghtHint); + static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLenghtHint); /** inflates a GZip file into memory * @@ -84,7 +84,7 @@ namespace cocos2d * * @since v0.99.5 */ - static int ccInflateGZipFile(const char *filename, unsigned char **out); + static int inflateGZipFile(const char *filename, unsigned char **out); /** test a file is a GZip format file or not * @@ -92,7 +92,7 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsGZipFile(const char *filename); + static bool isGZipFile(const char *filename); /** test the buffer is GZip format or not * @@ -100,7 +100,7 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsGZipBuffer(const unsigned char *buffer, long len); + static bool isGZipBuffer(const unsigned char *buffer, long len); /** inflates a CCZ file into memory * @@ -108,7 +108,7 @@ namespace cocos2d * * @since v0.99.5 */ - static int ccInflateCCZFile(const char *filename, unsigned char **out); + static int inflateCCZFile(const char *filename, unsigned char **out); /** inflates a buffer with CCZ format into memory * @@ -116,7 +116,7 @@ namespace cocos2d * * @since v3.0 */ - static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out); + static int inflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out); /** test a file is a CCZ format file or not * @@ -124,7 +124,7 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsCCZFile(const char *filename); + static bool isCCZFile(const char *filename); /** test the buffer is CCZ format or not * @@ -132,7 +132,7 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsCCZBuffer(const unsigned char *buffer, long len); + static bool isCCZBuffer(const unsigned char *buffer, long len); /** Sets the pvr.ccz encryption key parts separately for added * security. @@ -141,10 +141,10 @@ namespace cocos2d * 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function 4 * different times, preferably from 4 different source files, as follows * - * ZipUtils::ccSetPvrEncryptionKeyPart(0, 0xaaaaaaaa); - * ZipUtils::ccSetPvrEncryptionKeyPart(1, 0xbbbbbbbb); - * ZipUtils::ccSetPvrEncryptionKeyPart(2, 0xcccccccc); - * ZipUtils::ccSetPvrEncryptionKeyPart(3, 0xdddddddd); + * ZipUtils::setPvrEncryptionKeyPart(0, 0xaaaaaaaa); + * ZipUtils::setPvrEncryptionKeyPart(1, 0xbbbbbbbb); + * ZipUtils::setPvrEncryptionKeyPart(2, 0xcccccccc); + * ZipUtils::setPvrEncryptionKeyPart(3, 0xdddddddd); * * Splitting the key into 4 parts and calling the function * from 4 different source files increases the difficulty to @@ -152,15 +152,15 @@ namespace cocos2d * is *never* 100% secure and the key code can be cracked by * knowledgable persons. * - * IMPORTANT: Be sure to call ccSetPvrEncryptionKey or - * ccSetPvrEncryptionKeyPart with all of the key parts *before* loading + * IMPORTANT: Be sure to call setPvrEncryptionKey or + * setPvrEncryptionKeyPart with all of the key parts *before* loading * the spritesheet or decryption will fail and the spritesheet * will fail to load. * * @param index part of the key [0..3] * @param value value of the key part */ - static void ccSetPvrEncryptionKeyPart(int index, unsigned int value); + static void setPvrEncryptionKeyPart(int index, unsigned int value); /** Sets the pvr.ccz encryption key. * @@ -168,14 +168,14 @@ namespace cocos2d * 0xaaaaaaaabbbbbbbbccccccccdddddddd you will call this function with * the key split into 4 parts as follows * - * ZipUtils::ccSetPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd); + * ZipUtils::setPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd); * * Note that using this function makes it easier to reverse engineer and * discover the complete key because the key parts are present in one * function call. * - * IMPORTANT: Be sure to call ccSetPvrEncryptionKey or - * ccSetPvrEncryptionKeyPart with all of the key parts *before* loading + * IMPORTANT: Be sure to call setPvrEncryptionKey or + * setPvrEncryptionKeyPart with all of the key parts *before* loading * the spritesheet or decryption will fail and the spritesheet * will fail to load. * @@ -184,13 +184,12 @@ namespace cocos2d * @param keyPart3 the key value part 3. * @param keyPart4 the key value part 4. */ - static void ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4); + static void setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4); private: - static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, - long outLenghtHint); - static inline void ccDecodeEncodedPvr (unsigned int *data, long len); - static inline unsigned int ccChecksumPvr(const unsigned int *data, long len); + static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint); + static inline void decodeEncodedPvr (unsigned int *data, long len); + static inline unsigned int checksumPvr(const unsigned int *data, long len); static unsigned int s_uEncryptedPvrKeyParts[4]; static unsigned int s_uEncryptionKey[1024]; @@ -249,7 +248,7 @@ namespace cocos2d * @param fileName File name * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. - * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. + * @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned. * * @since v2.0.5 */ diff --git a/cocos/2d/base64.cpp b/cocos/2d/base64.cpp index 131b0d81f7..e9e14ca7bb 100644 --- a/cocos/2d/base64.cpp +++ b/cocos/2d/base64.cpp @@ -141,7 +141,7 @@ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char * unsigned int outLength = 0; //should be enough to store 6-bit buffers in 8-bit buffers - *out = new unsigned char[(size_t)(inLength * 3.0f / 4.0f + 1)]; + *out = (unsigned char*)malloc(inLength * 3.0f / 4.0f + 1); if( *out ) { int ret = _base64Decode(in, inLength, *out, &outLength); @@ -150,7 +150,7 @@ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char * #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) printf("Base64Utils: error decoding"); #endif - delete [] *out; + free(*out); *out = NULL; outLength = 0; } @@ -162,7 +162,7 @@ int base64Encode(const unsigned char *in, unsigned int inLength, char **out) { unsigned int outLength = inLength * 4 / 3 + (inLength % 3 > 0 ? 4 : 0); //should be enough to store 8-bit buffers in 6-bit buffers - *out = new char[outLength+1]; + *out = (char*)malloc(outLength+1); if( *out ) { _base64Encode(in, inLength, *out); } diff --git a/cocos/2d/base64.h b/cocos/2d/base64.h index c00a78c27a..fd95485d9e 100644 --- a/cocos/2d/base64.h +++ b/cocos/2d/base64.h @@ -37,7 +37,7 @@ namespace cocos2d { /** * Decodes a 64base encoded memory. The decoded memory is - * expected to be freed by the caller. + * expected to be freed by the caller by calling `free()` * * @returns the length of the out buffer * @@ -47,7 +47,7 @@ int base64Decode(const unsigned char *in, unsigned int inLength, unsigned char * /** * Encodes bytes into a 64base encoded memory with terminating '\0' character. - * The encoded memory is expected to be freed by the caller. + * The encoded memory is expected to be freed by the caller by calling `free()` * * @returns the length of the out buffer * diff --git a/cocos/2d/platform/CCFileUtils.cpp b/cocos/2d/platform/CCFileUtils.cpp index 6760432cad..ddd9c25dfe 100644 --- a/cocos/2d/platform/CCFileUtils.cpp +++ b/cocos/2d/platform/CCFileUtils.cpp @@ -503,7 +503,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, lo fseek(fp,0,SEEK_END); *size = ftell(fp); fseek(fp,0,SEEK_SET); - buffer = new unsigned char[*size]; + buffer = (unsigned char*)malloc(*size); *size = fread(buffer,sizeof(unsigned char), *size,fp); fclose(fp); } while (0); @@ -543,7 +543,7 @@ unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char nRet = unzOpenCurrentFile(pFile); CC_BREAK_IF(UNZ_OK != nRet); - buffer = new unsigned char[FileInfo.uncompressed_size]; + buffer = (unsigned char*)malloc(FileInfo.uncompressed_size); int CC_UNUSED nSize = unzReadCurrentFile(pFile, buffer, FileInfo.uncompressed_size); CCASSERT(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong"); diff --git a/cocos/2d/platform/CCFileUtils.h b/cocos/2d/platform/CCFileUtils.h index 855f016fe5..1827ba53c7 100644 --- a/cocos/2d/platform/CCFileUtils.h +++ b/cocos/2d/platform/CCFileUtils.h @@ -86,7 +86,7 @@ public: * @param[in] pszMode The read mode of the file. * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. - * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. + * @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned. */ virtual unsigned char* getFileData(const char* filename, const char* mode, long *size); @@ -96,7 +96,7 @@ public: * @param[in] filename The resource file name which contains the relative path of the zip file. * @param[out] size If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. - * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. + * @warning Recall: you are responsible for calling free() on any Non-NULL pointer returned. */ virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, long *size); diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index f2fc7a9a08..c2224b5bda 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -460,13 +460,13 @@ bool Image::initWithImageData(const unsigned char * data, long dataLen) int unpackedLen = 0; //detecgt and unzip the compress file - if (ZipUtils::ccIsCCZBuffer(data, dataLen)) + if (ZipUtils::isCCZBuffer(data, dataLen)) { - unpackedLen = ZipUtils::ccInflateCCZBuffer(data, dataLen, &unpackedData); + unpackedLen = ZipUtils::inflateCCZBuffer(data, dataLen, &unpackedData); } - else if (ZipUtils::ccIsGZipBuffer(data, dataLen)) + else if (ZipUtils::isGZipBuffer(data, dataLen)) { - unpackedLen = ZipUtils::ccInflateMemory(const_cast(data), dataLen, &unpackedData); + unpackedLen = ZipUtils::inflateMemory(const_cast(data), dataLen, &unpackedData); } else { diff --git a/cocos/2d/platform/CCSAXParser.cpp b/cocos/2d/platform/CCSAXParser.cpp index 04201557c1..056a088826 100644 --- a/cocos/2d/platform/CCSAXParser.cpp +++ b/cocos/2d/platform/CCSAXParser.cpp @@ -121,7 +121,7 @@ bool SAXParser::parse(const char *pszFile) { ret = parse(pBuffer, size); } - CC_SAFE_DELETE_ARRAY(pBuffer); + free(pBuffer); return ret; } diff --git a/cocos/base/CCString.cpp b/cocos/base/CCString.cpp index 67193eb52c..046e8f2e7a 100644 --- a/cocos/base/CCString.cpp +++ b/cocos/base/CCString.cpp @@ -260,7 +260,7 @@ String* String::createWithContentsOfFile(const char* filename) String* ret = NULL; data = FileUtils::getInstance()->getFileData(filename, "rb", &size); ret = String::createWithData(data, size); - CC_SAFE_DELETE_ARRAY(data); + free(data); return ret; } diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index 2fec8df55a..f3b24f6b6f 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -248,7 +248,7 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, unsigned char * pBytes = FileUtils::getInstance()->getFileData(strPath.c_str(), "rb", &size); Data *data = new Data(pBytes, size); - CC_SAFE_DELETE_ARRAY(pBytes); + free(pBytes); Node *ret = this->readNodeGraphFromData(data, pOwner, parentSize); diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 7eba8e9340..de28a1a3e5 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -926,7 +926,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader reader->getAnimationManager()->setRootContainerSize(pParent->getContentSize()); Data *data = new Data(pBytes, size); - CC_SAFE_DELETE_ARRAY(pBytes); + free(pBytes); data->retain(); reader->_data = data; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 17f10067ed..41091ce765 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -297,7 +297,7 @@ void DataReaderHelper::addDataFromFile(const char *filePath) long size; std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath); - const char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); + char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); DataInfo dataInfo; dataInfo.filename = filePathStr; @@ -312,6 +312,7 @@ void DataReaderHelper::addDataFromFile(const char *filePath) { DataReaderHelper::addDataFromJsonCache(pFileContent, &dataInfo); } + free(pFileContent); } void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, Object *target, SEL_SCHEDULE selector) @@ -395,6 +396,8 @@ void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *p std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath); long size; + + // XXX fileContent is being leaked data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size); if (str.compare(".xml") == 0) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 3ad788b563..69bc0cf803 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -222,14 +222,14 @@ const cocos2d::Size CCSGUIReader::getFileDesignSize(const char* fileName) const UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) { m_bOlderVersion = false; - const char *des = NULL; + char *des = NULL; std::string jsonpath; JsonDictionary *jsonDict = NULL; jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName); long size = 0; - des = (char*)(FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); - if(NULL == des || strcmp(des, "") == 0) + des = (char*)FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size); + if(des == NULL || strcmp(des, "") == 0) { printf("read json file[%s] error!\n", fileName); return NULL; @@ -288,7 +288,7 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) CC_SAFE_DELETE(widgetTree); CC_SAFE_DELETE(actions); CC_SAFE_DELETE(jsonDict); - CC_SAFE_DELETE_ARRAY(des); + free(des); return widget; } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 25c84fd773..ebe973e7f9 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -48,18 +48,19 @@ namespace cocostudio { cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName) { long size = 0; - const char* pData = 0; + char* pData = 0; cocos2d::Node *pNode = NULL; do { - CC_BREAK_IF(pszFileName == NULL); - pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size)); - CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); - JsonDictionary *jsonDict = new JsonDictionary(); - jsonDict->initWithDescription(pData); - pNode = createObject(jsonDict,NULL); - CC_SAFE_DELETE(jsonDict); + CC_BREAK_IF(pszFileName == NULL); + pData = (char*)cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size); + CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); + JsonDictionary *jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(pData); + pNode = createObject(jsonDict,NULL); + CC_SAFE_DELETE(jsonDict); + free(pData); } while (0); - + return pNode; } @@ -214,10 +215,10 @@ namespace cocostudio { file_path = reDir.substr(0, pos+1); } long size = 0; - const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size)); + char *des = (char*)cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size); JsonDictionary *jsonDict = new JsonDictionary(); jsonDict->initWithDescription(des); - if(NULL == des || strcmp(des, "") == 0) + if(des == NULL || strcmp(des, "") == 0) { CCLOG("read json file[%s] error!\n", pPath.c_str()); } @@ -261,7 +262,7 @@ namespace cocostudio { CC_SAFE_DELETE(jsonDict); CC_SAFE_DELETE(subData); - CC_SAFE_DELETE_ARRAY(des); + free(des); } else if(comName != NULL && strcmp(comName, "CCComAudio") == 0) { @@ -284,12 +285,12 @@ namespace cocostudio { { pAttribute = ComAttribute::create(); long size = 0; - const char* pData = 0; - pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size)); + char* pData = (char*)cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size); if(pData != NULL && strcmp(pData, "") != 0) { pAttribute->getDict()->initWithDescription(pData); } + free(pData); } else { diff --git a/cocos/editor-support/spine/Atlas.cpp b/cocos/editor-support/spine/Atlas.cpp index 1a2293bacb..e3d6d799b4 100644 --- a/cocos/editor-support/spine/Atlas.cpp +++ b/cocos/editor-support/spine/Atlas.cpp @@ -303,7 +303,7 @@ Atlas* Atlas_readAtlasFile (const char* path) { data = _Util_readFile(path, &length); if (data) atlas = Atlas_readAtlas(data, length, dir); - delete [] data; + FREE(data); FREE(dir); return atlas; } diff --git a/cocos/editor-support/spine/SkeletonJson.cpp b/cocos/editor-support/spine/SkeletonJson.cpp index 6bfeeb24e7..6c1e039b10 100644 --- a/cocos/editor-support/spine/SkeletonJson.cpp +++ b/cocos/editor-support/spine/SkeletonJson.cpp @@ -240,7 +240,7 @@ SkeletonData* SkeletonJson_readSkeletonDataFile (SkeletonJson* self, const char* return 0; } skeletonData = SkeletonJson_readSkeletonData(self, json); - delete [] json; + FREE(json); return skeletonData; } diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index 86ddb4bd2e..0f7fca11f4 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -536,7 +536,7 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c if (data) { script = JS_DecodeScript(cx, data, length, NULL, NULL); - CC_SAFE_DELETE_ARRAY(data); + free(data); } // b) no jsc file, check js file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index bbc36bbe5b..024733dad8 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -36a6cc6177c059364c6ccc3b1151b6475219b396 \ No newline at end of file +5bc5339bd77792b57c97cebbe7dfd3b634038e38 \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp index 69967031a8..fa1f7cb01c 100644 --- a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp +++ b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp @@ -56,7 +56,7 @@ extern "C" luaL_error(L, "error loading module %s from file %s :\n\t%s", lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1)); } - delete []codeBuffer; + free(codeBuffer); } else { diff --git a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp index 5aea719250..e7f3d6ddf6 100644 --- a/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp @@ -46,10 +46,10 @@ void TextureAtlasEncryptionDemo::onEnter() // 1) Set the encryption keys or step 2 will fail // In this case the encryption key 0xaaaaaaaabbbbbbbbccccccccdddddddd is // split into four parts. See the header docs for more information. - ZipUtils::ccSetPvrEncryptionKeyPart(0, 0xaaaaaaaa); - ZipUtils::ccSetPvrEncryptionKeyPart(1, 0xbbbbbbbb); - ZipUtils::ccSetPvrEncryptionKeyPart(2, 0xcccccccc); - ZipUtils::ccSetPvrEncryptionKeyPart(3, 0xdddddddd); + ZipUtils::setPvrEncryptionKeyPart(0, 0xaaaaaaaa); + ZipUtils::setPvrEncryptionKeyPart(1, 0xbbbbbbbb); + ZipUtils::setPvrEncryptionKeyPart(2, 0xcccccccc); + ZipUtils::setPvrEncryptionKeyPart(3, 0xdddddddd); // Alternatively, you can call the function that accepts the key in a single // function call. From 8c42e62a3fdd6fb53f8bf3a85331b8458b2cb528 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:32:22 +0800 Subject: [PATCH 112/185] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index f8e3957968..e857757e3c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -650,6 +650,9 @@ Developers: xhcnb Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + bopohaa + Fixed a bug that Webp test crashes. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 0358eae8f03b9f5cf9b0dc0af9cbc0ce0b8e2b47 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:33:18 +0800 Subject: [PATCH 113/185] Update CHANGELOG [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e7632e9061..e06e8d0e37 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support + [FIX] Webp Test Crashes. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From db07c781abdbb672b93f79b2f29e3e92906d99c7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:35:50 +0800 Subject: [PATCH 114/185] #include for std::max, std::min on VS2013. --- cocos/2d/CCTMXTiledMap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 4205adb1fe..7ab6da363b 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. #include "CCTMXXMLParser.h" #include "CCTMXLayer.h" #include "CCSprite.h" +#include NS_CC_BEGIN From e2224d53160a7006136dcc66e014322a3d2019e9 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Nov 2013 11:24:59 +0800 Subject: [PATCH 115/185] [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 938f0c39fb..c5d464e62f 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,8 @@ $ cmake .. $ make ``` - You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. - `install-deps-linux.sh` only has to be run onece. + You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, + you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run onece. * For Windows From 6b29391212c916c5b4fed9e286cea8c85a058bfa Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 20:21:01 -0800 Subject: [PATCH 116/185] Adds markdown comments in the doxstrings Since Doxygen 1.8.0 (we are already using it), it is possible to add markdown comments in the doxygen strings. This will make our comments easier to read. This patch only adds markdown to CCNode.h as a test. If you like, I'll keep adding markdown comments as I see them. Please, encourage the rest of the team to do the same. --- cocos/2d/CCNode.h | 278 ++-- cocos/audio/include/SimpleAudioEngine.h | 2 +- docs/doxygen.config | 1839 ----------------------- docs/doxygen.config.REMOVED.git-id | 1 + 4 files changed, 140 insertions(+), 1980 deletions(-) delete mode 100644 docs/doxygen.config create mode 100644 docs/doxygen.config.REMOVED.git-id diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 5a363c8053..ba9151884b 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -82,22 +82,22 @@ bool nodeComparisonLess(Object* p1, Object* p2); class EventListener; -/** @brief Node is the main element. Anything that gets drawn or contains things that get drawn is a Node. - The most popular Nodes are: Scene, Layer, Sprite, Menu. +/** @brief Node is the base element of the Scene Graph. Element of the Scene Graph must be Node objects or subclasses of it. + The most common Node objects are: Scene, Layer, Sprite, Menu. The main features of a Node are: - - They can contain other Node nodes (addChild, getChildByTag, removeChild, etc) - - They can schedule periodic callback (schedule, unschedule, etc) - - They can execute actions (runAction, stopAction, etc) + - They can contain other Node objects (`addChild`, `getChildByTag`, `removeChild`, etc) + - They can schedule periodic callback (`schedule`, `unschedule`, etc) + - They can execute actions (`runAction`, `stopAction`, etc) - Some Node nodes provide extra functionality for them or their children. + Some Node objects provide extra functionality for them or their children. Subclassing a Node usually means (one/all) of: - overriding init to initialize resources and schedule callbacks - create callbacks to handle the advancement of time - overriding draw to render the node - Features of Node: + Properties of Node: - position - scale (x, y) - rotation (in degrees, clockwise) @@ -117,7 +117,7 @@ class EventListener; - anchorPoint: (x=0,y=0) Limitations: - - A Node is a "void" object. It doesn't have a texture + - A Node is a "invisible" object. If you want to draw something on the screen, you should use a Sprite instead. Or subclass Node and override `draw`. Order in transformations with grid disabled -# The node will be translated (position) @@ -189,15 +189,15 @@ public: /** * Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array. * - * The Z order of node is relative to its "brothers": children of the same parent. - * It's nothing to do with OpenGL's z vertex. This one only affects the draw order of nodes in cocos2d. - * The larger number it is, the later this node will be drawn in each message loop. - * Please refer to setVertexZ(float) for the difference. + * The Z order of node is relative to its siblings. + * It is not related to the OpenGL's z property. This one only affects the draw order of itself and its siblings. + * Lower Z order number are drawn before higher numbers. + * Please refer to `setVertexZ(float)` for the difference. * * @param zOrder Z order of this node. */ virtual void setZOrder(int zOrder); - /** + /* * Sets the z order which stands for the drawing order * * This is an internal method. Don't call it outside the framework. @@ -209,7 +209,7 @@ public: /** * Gets the Z order of this node. * - * @see setZOrder(int) + * @see `setZOrder(int)` * * @return The Z order. */ @@ -221,7 +221,7 @@ public: * Differences between openGL Z vertex and cocos2d Z order: * - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children * - OpenGL Z might require to set 2D projection - * - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 + * - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: `vertexZ = 0` * * @warning Use it at your own risk since it might break the cocos2d parent-children z order * @@ -267,7 +267,7 @@ public: /** * Returns the scale factor on Y axis of this node * - * @see setScaleY(float) + * @see `setScaleY(float)` * * @return The scale factor on Y axis. */ @@ -285,7 +285,7 @@ public: /** * Gets the scale factor of the node, when X and Y have the same scale factor. * - * @warning Assert when _scaleX != _scaleY. + * @warning Assert when `_scaleX != _scaleY` * @see setScale(float) * * @return The scale factor of the node. @@ -305,13 +305,13 @@ public: /** * Changes the position (x,y) of the node in OpenGL coordinates * - * Usually we use Point(x,y) to compose Point object. + * Usually we use `Point(x,y)` to compose Point object. * The original point (0,0) is at the left-bottom corner of screen. * For example, this codesnip sets the node in the center of screen. - * @code - * Size size = Director::getInstance()->getWinSize(); - * node->setPosition( Point(size.width/2, size.height/2) ) - * @endcode + @code + Size size = Director::getInstance()->getWinSize(); + node->setPosition( Point(size.width/2, size.height/2) ) + @endcode * * @param position The position (x,y) of the node in OpenGL coordinates */ @@ -334,11 +334,11 @@ public: * This method is binded to lua and javascript. * Passing a number is 10 times faster than passing a object from lua to c++ * - * @code - * // sample code in lua - * local pos = node::getPosition() -- returns Point object from C++ - * node:setPosition(x, y) -- pass x, y coordinate to C++ - * @endcode + @code + // sample code in lua + local pos = node::getPosition() -- returns Point object from C++ + node:setPosition(x, y) -- pass x, y coordinate to C++ + @endcode * * @param x X coordinate for position * @param y Y coordinate for position @@ -347,10 +347,8 @@ public: /** * Gets position in a more efficient way, returns two number instead of a Point object * - * @see setPosition(float, float) - * @code + * @see `setPosition(float, float)` * In js,out value not return - * @endcode */ virtual void getPosition(float* x, float* y) const; /** @@ -376,7 +374,7 @@ public: /** * Returns the X skew angle of the node in degrees. * - * @see setSkewX(float) + * @see `setSkewX(float)` * * @return The X skew angle of the node in degrees. */ @@ -396,7 +394,7 @@ public: /** * Returns the Y skew angle of the node in degrees. * - * @see setSkewY(float) + * @see `setSkewY(float)` * * @return The Y skew angle of the node in degrees. */ @@ -418,7 +416,7 @@ public: /** * Returns the anchor point in percent. * - * @see setAnchorPoint(const Point&) + * @see `setAnchorPoint(const Point&)` * * @return The anchor point of node. */ @@ -427,7 +425,7 @@ public: * Returns the anchorPoint in absolute pixels. * * @warning You can only read it. If you wish to modify it, use anchorPoint instead. - * @see getAnchorPoint() + * @see `getAnchorPoint()` * * @return The anchor point in absolute pixels. */ @@ -446,7 +444,7 @@ public: /** * Returns the untransformed size of the node. * - * @see setContentSize(const Size&) + * @see `setContentSize(const Size&)` * * @return The untransformed size of the node. */ @@ -464,7 +462,7 @@ public: /** * Determines if the node is visible * - * @see setVisible(bool) + * @see `setVisible(bool)` * * @return true if the node is visible, false if the node is hidden. */ @@ -483,7 +481,7 @@ public: /** * Returns the rotation of the node in degrees. * - * @see setRotation(float) + * @see `setRotation(float)` * * @return The rotation of the node in degrees. */ @@ -502,7 +500,7 @@ public: /** * Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew. * - * @see setRotationX(float) + * @see `setRotationX(float)` * * @return The X rotation in degrees. */ @@ -521,7 +519,7 @@ public: /** * Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew. * - * @see setRotationY(float) + * @see `setRotationY(float)` * * @return The Y rotation in degrees. */ @@ -542,7 +540,7 @@ public: /** * Returns the arrival order, indecates which children is added previously. * - * @see setOrderOfArrival(unsigned int) + * @see `setOrderOfArrival(unsigned int)` * * @return The arrival order. */ @@ -573,7 +571,7 @@ public: /** * Gets whether the anchor point will be (0,0) when you position this node. * - * @see ignoreAnchorPointForPosition(bool) + * @see `ignoreAnchorPointForPosition(bool)` * * @return true if the anchor point will be (0,0) when you position this node. */ @@ -625,13 +623,13 @@ public: * * Composing a "tree" structure is a very important feature of Node * Here's a sample code of traversing children array: - * @code - * Node* node = NULL; - * CCARRAY_FOREACH(parent->getChildren(), node) - * { - * node->setPosition(0,0); - * } - * @endcode + @code + Node* node = NULL; + CCARRAY_FOREACH(parent->getChildren(), node) + { + node->setPosition(0,0); + } + @endcode * This sample code traverses all children nodes, and set their position to (0,0) * * @return An array of children @@ -655,7 +653,7 @@ public: /** * Returns a pointer to the parent node * - * @see setParent(Node*) + * @see `setParent(Node*)` * * @returns A pointer to the parnet node */ @@ -668,7 +666,7 @@ public: /** * Removes this node itself from its parent node with a cleanup. * If the node orphan, then nothing happens. - * @see removeFromParentAndCleanup(bool) + * @see `removeFromParentAndCleanup(bool)` */ virtual void removeFromParent(); /** @@ -698,7 +696,7 @@ public: /** * Removes all children from the container with a cleanup. * - * @see removeAllChildrenWithCleanup(bool) + * @see `removeAllChildrenWithCleanup(bool)` */ virtual void removeAllChildren(); /** @@ -761,32 +759,32 @@ public: * Returns a tag that is used to identify the node easily. * * You can set tags to node then identify them easily. - * @code - * #define TAG_PLAYER 1 - * #define TAG_MONSTER 2 - * #define TAG_BOSS 3 - * // set tags - * node1->setTag(TAG_PLAYER); - * node2->setTag(TAG_MONSTER); - * node3->setTag(TAG_BOSS); - * parent->addChild(node1); - * parent->addChild(node2); - * parent->addChild(node3); - * // identify by tags - * Node* node = NULL; - * CCARRAY_FOREACH(parent->getChildren(), node) - * { - * switch(node->getTag()) - * { - * case TAG_PLAYER: - * break; - * case TAG_MONSTER: - * break; - * case TAG_BOSS: - * break; - * } - * } - * @endcode + @code + #define TAG_PLAYER 1 + #define TAG_MONSTER 2 + #define TAG_BOSS 3 + // set tags + node1->setTag(TAG_PLAYER); + node2->setTag(TAG_MONSTER); + node3->setTag(TAG_BOSS); + parent->addChild(node1); + parent->addChild(node2); + parent->addChild(node3); + // identify by tags + Node* node = NULL; + CCARRAY_FOREACH(parent->getChildren(), node) + { + switch(node->getTag()) + { + case TAG_PLAYER: + break; + case TAG_MONSTER: + break; + case TAG_BOSS: + break; + } + } + @endcode * * @return A interger that identifies the node. */ @@ -820,7 +818,7 @@ public: * Sets a custom user data pointer * * You can set everything in UserData pointer, a data block, a structure or an object, etc. - * @warning Don't forget to release the memroy manually, + * @warning Don't forget to release the memory manually, * especially before you change this data pointer, and before this node is autoreleased. * * @param userData A custom user data pointer @@ -875,9 +873,9 @@ public: * * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. - * @code - * node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - * @endcode + @code + node->setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + @endcode * * @param shaderProgram The shader program which fetchs from ShaderCache. */ @@ -888,11 +886,11 @@ public: /** * Returns a camera object that lets you move the node using a gluLookAt * - * @code - * Camera* camera = node->getCamera(); - * camera->setEye(0, 0, 415/2); - * camera->setCenter(0, 0, 0); - * @endcode + @code + Camera* camera = node->getCamera(); + camera->setEye(0, 0, 415/2); + camera->setCenter(0, 0, 0); + @endcode * * @return A Camera object that lets you move the node using a gluLookAt */ @@ -966,10 +964,10 @@ public: /** * Override this method to draw your own node. * The following GL states will be enabled by default: - * - glEnableClientState(GL_VERTEX_ARRAY); - * - glEnableClientState(GL_COLOR_ARRAY); - * - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - * - glEnable(GL_TEXTURE_2D); + * - `glEnableClientState(GL_VERTEX_ARRAY);` + * - `glEnableClientState(GL_COLOR_ARRAY);` + * - `glEnableClientState(GL_TEXTURE_COORD_ARRAY);` + * - `glEnable(GL_TEXTURE_2D);` * AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE * But if you enable any other GL state, you should disable it after drawing your node. */ @@ -986,7 +984,7 @@ public: * The returned box is relative only to its parent. * * @note This method returns a temporaty variable, so it can't returns const Rect& - * @todo Rename to getBoundingBox() in the future versions. + * @todo Rename to `getBoundingBox()` in the future versions. * * @return A "local" axis aligned boudning box of the node. */ @@ -1049,7 +1047,7 @@ public: /** * Gets an action from the running action list by its tag. * - * @see setTag(int), getTag(). + * @see `setTag(int)`, `getTag()`. * * @return The action object with the given tag. */ @@ -1135,12 +1133,12 @@ public: * Schedules a custom selector. * * If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. - * @code - * // firstly, implement a schedule function - * void MyNode::TickMe(float dt); - * // wrap this function into a selector via schedule_selector marco. - * this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0); - * @endcode + @code + // firstly, implement a schedule function + void MyNode::TickMe(float dt); + // wrap this function into a selector via schedule_selector marco. + this->schedule(schedule_selector(MyNode::TickMe), 0, 0, 0); + @endcode * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param interval Tick interval in seconds. 0 means tick every frame. If interval = 0, it's recommended to use scheduleUpdate() instead. @@ -1152,7 +1150,7 @@ public: /** * Schedules a custom selector with an interval time in seconds. - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) + * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param interval Callback interval time in seconds. 0 means tick every frame, @@ -1162,7 +1160,7 @@ public: /** * Schedules a selector that runs only once, with a delay of 0 or larger - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) + * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector The SEL_SCHEDULE selector to be scheduled. * @param delay The amount of time that the first tick will wait before execution. @@ -1181,7 +1179,7 @@ public: /** * Unschedules a custom selector. - * @see schedule(SEL_SCHEDULE, float, unsigned int, float) + * @see `schedule(SEL_SCHEDULE, float, unsigned int, float)` * * @param selector A function wrapped as a selector * @lua NA @@ -1242,7 +1240,7 @@ public: * * This method is moved from Sprite, so it's no longer specific to Sprite. * As the result, you apply SpriteBatchNode's optimization on your customed Node. - * e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before. + * e.g., `batchNode->addChild(myCustomNode)`, while you can only addChild(sprite) before. */ virtual void updateTransform(); @@ -1323,48 +1321,48 @@ public: * * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). - * @code - // create a batchNode - SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png"); - this->addChild(batch); - - // create two sprites, spriteA will be added to batchNode, they are using different textures. - Sprite* spriteA = Sprite::createWithTexture(batch->getTexture()); - Sprite* spriteB = Sprite::create("Icon-72.png"); + @code + // create a batchNode + SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png"); + this->addChild(batch); - batch->addChild(spriteA); - - // We can't make spriteB as spriteA's child since they use different textures. So just add it to layer. - // But we want to simulate `parent-child` relationship for these two node. - this->addChild(spriteB); + // create two sprites, spriteA will be added to batchNode, they are using different textures. + Sprite* spriteA = Sprite::createWithTexture(batch->getTexture()); + Sprite* spriteB = Sprite::create("Icon-72.png"); - //position - spriteA->setPosition(Point(200, 200)); - - // Gets the spriteA's transform. - AffineTransform t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); + batch->addChild(spriteA); - //scale - spriteA->setScale(2); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); + // We can't make spriteB as spriteA's child since they use different textures. So just add it to layer. + // But we want to simulate `parent-child` relationship for these two node. + this->addChild(spriteB); - //rotation - spriteA->setRotation(20); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - * @endcode + //position + spriteA->setPosition(Point(200, 200)); + + // Gets the spriteA's transform. + AffineTransform t = spriteA->getNodeToParentTransform(); + + // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. + spriteB->setAdditionalTransform(t); + + //scale + spriteA->setScale(2); + + // Gets the spriteA's transform. + t = spriteA->getNodeToParentTransform(); + + // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. + spriteB->setAdditionalTransform(t); + + //rotation + spriteA->setRotation(20); + + // Gets the spriteA's transform. + t = spriteA->getNodeToParentTransform(); + + // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. + spriteB->setAdditionalTransform(t); + @endcode */ void setAdditionalTransform(const AffineTransform& additionalTransform); diff --git a/cocos/audio/include/SimpleAudioEngine.h b/cocos/audio/include/SimpleAudioEngine.h index 875f9ad12e..29e2f2c05f 100644 --- a/cocos/audio/include/SimpleAudioEngine.h +++ b/cocos/audio/include/SimpleAudioEngine.h @@ -64,7 +64,7 @@ public: /** @brief Release the shared Engine object - @warning It must be called before the application exit, or a memroy leak will be casued. + @warning It must be called before the application exit, or a memory leak will be casued. */ static void end(); diff --git a/docs/doxygen.config b/docs/doxygen.config deleted file mode 100644 index 5adc36c084..0000000000 --- a/docs/doxygen.config +++ /dev/null @@ -1,1839 +0,0 @@ -# Doxyfile 1.8.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = cocos2d-x - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 2.1.0 - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ./ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = YES - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = YES - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = YES - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = NO - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = YES - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = YES - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = YES - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = YES - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ../cocos2dx \ - ../cocos2dx/platform \ - ../CocosDenshion/include \ - ../document \ - ../extensions \ - ../scripting/lua/cocos2dx_support - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = ../cocos2dx/platform/third_party - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = .svn \ - kazmath \ - FontLabel \ - proj.ios \ - data_support \ - image_support \ - zip_support - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = ccArray \ - ccCArray - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = ./ - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = YES - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = "CC_PROPERTY_READONLY(varType, varName, funName)=protected: varType varName;\n /** get##funName*/\n public: virtual varType get##funName(void);" \ - "CC_PROPERTY_READONLY_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName*/\n public: virtual const varType& get##funName(void);" \ - "CC_PROPERTY(varType, varName, funName)=protected: varType varName;\n /** get##funName*/\n public: virtual varType get##funName(void);\n/** set##funName*/\n public: virtual void set##funName(varType var);" \ - "CC_PROPERTY_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName*/\n public: virtual const varType& get##funName(void);\n/** set##funName*/\n public: virtual void set##funName(const varType& var);" \ - "CC_SYNTHESIZE(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual varType get##funName(void)\n /** set##funName */ \n public: virtual void set##funName(varType var);" \ - "CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual const varType& get##funName(void);\n /** set#funName */\n public: virtual void set##funName(const varType& var);" \ - "CC_SYNTHESIZE_RETAIN(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual varType get##funName(void);\n /** set##funName */\n public: virtual void set##funName(varType var);" \ - "CC_SYNTHESIZE_READONLY(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual varType get##funName(void);" \ - "CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName */ \n public: virtual const varType& get##funName(void);" \ - "NS_CC_BEGIN=namespace cocos2d {" \ - "NS_CC_END=}" \ - "USING_NS_CC=using namsspace cocos2d" \ - "NS_CC_EXT_BEGIN=namespace cocos2d { namespace extension {" \ - "NS_CC_EXT_END=}}" \ - "USING_NS_CC_EXT=using namespace cocos2d::extension" - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = NO - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = FreeSans.ttf - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/docs/doxygen.config.REMOVED.git-id b/docs/doxygen.config.REMOVED.git-id new file mode 100644 index 0000000000..a634c4480b --- /dev/null +++ b/docs/doxygen.config.REMOVED.git-id @@ -0,0 +1 @@ +3bc6566e5802e181c4baf91b8346473653c6d4ea \ No newline at end of file From 482ee5d47f902039b080898c4e406b12d5184ccd Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 15:25:47 +0800 Subject: [PATCH 117/185] issue #2868:Add more ccs lua test samples --- .../cocostudio/CCSSceneReader.h | 2 +- cocos/scripting/CMakeLists.txt | 2 + cocos/scripting/lua/bindings/Android.mk | 4 +- cocos/scripting/lua/bindings/liblua.vcxproj | 8 +- .../lua/bindings/liblua.vcxproj.filters | 12 + .../lua_cocos2dx_coco_studio_manual.cpp | 2 +- .../scripting/lua/script/StudioConstants.lua | 55 +- .../CocoStudioGUITest/CocoStudioGUITest.lua | 1818 ----------------- .../CocoStudioGUITest.lua.REMOVED.git-id | 1 + .../CocoStudioSceneTest.lua | 75 + .../CocoStudioTest/CocoStudioTest.lua | 3 +- samples/Lua/TestLua/proj.ios/AppController.mm | 2 +- tools/tolua/cocos2dx_studio.ini | 9 +- 13 files changed, 147 insertions(+), 1846 deletions(-) delete mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index f548a2573f..3c59adfcb8 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -41,7 +41,7 @@ public: * @js NA * @lua NA */ - ~SceneReader(void); + virtual ~SceneReader(void); public: static SceneReader* getInstance(); diff --git a/cocos/scripting/CMakeLists.txt b/cocos/scripting/CMakeLists.txt index 612d728162..2d175903a3 100644 --- a/cocos/scripting/CMakeLists.txt +++ b/cocos/scripting/CMakeLists.txt @@ -14,6 +14,7 @@ set(LUABINDING_SRC lua/bindings/LuaBasicConversions.cpp lua/bindings/lua_cocos2dx_manual.cpp lua/bindings/lua_cocos2dx_extension_manual.cpp + lua/bindings/lua_cocos2dx_coco_studio_manual.cpp lua/bindings/lua_cocos2dx_deprecated.cpp lua/bindings/lua_xml_http_request.cpp ) @@ -23,6 +24,7 @@ include_directories( lua/bindings ../../cocos/editor-support/cocosbuilder ../../cocos/editor-support/cocostudio + ../../cocos/gui ../../external/lua/lua ../../external/lua/tolua ) diff --git a/cocos/scripting/lua/bindings/Android.mk b/cocos/scripting/lua/bindings/Android.mk index f198157af9..bb3602191a 100644 --- a/cocos/scripting/lua/bindings/Android.mk +++ b/cocos/scripting/lua/bindings/Android.mk @@ -20,6 +20,7 @@ LOCAL_SRC_FILES := CCLuaBridge.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \ lua_cocos2dx_manual.cpp \ lua_cocos2dx_extension_manual.cpp \ + lua_cocos2dx_coco_studio_manual.cpp \ lua_cocos2dx_deprecated.cpp \ lua_xml_http_request.cpp \ platform/android/CCLuaJavaBridge.cpp \ @@ -37,7 +38,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \ $(LOCAL_PATH)/platform/android/jni \ $(LOCAL_PATH)/../../../../extensions \ $(LOCAL_PATH)/../../../editor-support/cocosbuilder \ - $(LOCAL_PATH)/../../../editor-support/cocostudio + $(LOCAL_PATH)/../../../editor-support/cocostudio \ + $(LOCAL_PATH)/../../../gui LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj b/cocos/scripting/lua/bindings/liblua.vcxproj index 1f6f39d5c8..7f5c6e4894 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj +++ b/cocos/scripting/lua/bindings/liblua.vcxproj @@ -64,7 +64,7 @@ Disabled - $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -96,7 +96,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ MaxSpeed true - $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\..\..;$(EngineRoot);$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)extensions\network;$(EngineRoot)external;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\gui;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -131,6 +131,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + @@ -140,6 +141,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + @@ -156,6 +158,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + @@ -165,6 +168,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj.filters b/cocos/scripting/lua/bindings/liblua.vcxproj.filters index d323cdf804..78d323eeb6 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj.filters +++ b/cocos/scripting/lua/bindings/liblua.vcxproj.filters @@ -84,6 +84,12 @@ cocos2dx_support + + cocos2dx_support\generated + + + cocos2dx_support + @@ -155,6 +161,12 @@ cocos2dx_support + + cocos2dx_support\generated + + + cocos2dx_support + diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 0788252cdc..845020a538 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -603,7 +603,7 @@ tolua_lerror: static void extendLayoutParameter(lua_State* L) { - lua_pushstring(L, "LayoutParameter"); + lua_pushstring(L, "UILayoutParameter"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua index 5b38ac6f69..b98714dd1d 100644 --- a/cocos/scripting/lua/script/StudioConstants.lua +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -15,7 +15,7 @@ ccs.WidgetType = { widget = 0, --control container = 1, --container -}; +} -- ccs.TextureResType = -- { @@ -35,18 +35,18 @@ ccs.SizeType = { absolute = 0, percent = 1, -}; +} ccs.PositionType = { absolute = 0, percent = 1, -}; +} ccs.CheckBoxEventType = { selected = 0, unselected = 1, -}; +} ccs.TextFiledEventType = { @@ -54,14 +54,14 @@ ccs.TextFiledEventType = detach_with_ime = 1, insert_text = 2, delete_backward = 3, -}; +} ccs.LayoutBackGroundColorType = { none = 0, solid = 1, gradient = 2, -}; +} ccs.LayoutType = { @@ -69,14 +69,14 @@ ccs.LayoutType = linearVertical = 1, linearHorizontal = 2, relative = 3, -}; +} ccs.UILayoutParameterType = { none = 0, linear = 1, relative = 2, -}; +} ccs.UILinearGravity = { @@ -87,7 +87,7 @@ ccs.UILinearGravity = bottom = 4, centerVertical = 5, centerHorizontal = 6, -}; +} ccs.UIRelativeAlign = { @@ -113,17 +113,18 @@ ccs.UIRelativeAlign = locationBelowLeftAlign = 19, locationBelowCenter = 20, locationBelowRightAlign = 21, -}; +} -ccs.SliderEventType = {percent_changed = 0}; +ccs.SliderEventType = {percent_changed = 0} -ccs.LoadingBarType = { left = 0, right = 1}; +ccs.LoadingBarType = { left = 0, right = 1} ccs.SCROLLVIEW_DIR = { none = 0, vertical = 1, horizontal = 2, -}; + both = 3, +} ccs.SCROLLVIEW_MOVE_DIR = { none = 0, @@ -131,20 +132,20 @@ ccs.SCROLLVIEW_MOVE_DIR = { down = 2, left = 3, right = 4, -}; +} ccs.ScrollviewEventType = { top = 0, bottom = 1, left = 2, right = 3, -}; +} ccs.ListViewDirection = { none = 0, vertical = 1, horizontal = 2, -}; +} ccs.ListViewMoveDirection = { none = 0, @@ -152,9 +153,27 @@ ccs.ListViewMoveDirection = { down = 2, left = 3, right = 4, -}; +} ccs.ListViewEventType = { init_child = 0, update_child = 1, -} \ No newline at end of file +} + +ccs.PageViewEventType = { + turning = 0, +} + +ccs.PVTouchDir = { + touch_left = 0, + touch_right = 1, +} + +ccs.ListViewGravity = { + left = 0, + right = 1, + center_horizontal = 2, + top = 3, + bottom = 4 , + center_vertical = 5, +} diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua deleted file mode 100644 index de25ec354b..0000000000 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ /dev/null @@ -1,1818 +0,0 @@ -require "luaScript/CocoStudioTest/CocoStudioGUITest/UIScene" - -local guiSceneManager = {} -guiSceneManager.currentUISceneIdx = 1 - -local UIScene = class("UIScene") -UIScene.__index = UIScene -UIScene._uiLayer= nil -UIScene._widget = nil -UIScene._sceneTitle = nil - -function UIScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIScene) - return target -end - -function UIScene:init() - self._uiLayer = ccs.UILayer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - back_label:setVisible(false) - - local function previousCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = self._uiLayer:getWidgetByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = self._uiLayer:getWidgetByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccs.TouchEventType.ended then - self._uiLayer:removeFromParent() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - -function UIScene.create() - local scene = UIScene.extend(cc.Scene:create()) - scene:init() - return scene -end - -local UIButtonTest = class("UIButtonTest",UIScene) -UIButtonTest._displayValueLabel = nil - -function UIButtonTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonTest) - return target -end - -function UIButtonTest:initExtend() - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("Button") - alert:setFontName(font_UIButtonTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function touchEvent(sender,eventType) - if eventType == ccs.TouchEventType.began then - self._displayValueLabel:setText("Touch Down") - elseif eventType == ccs.TouchEventType.moved then - self._displayValueLabel:setText("Touch Move") - elseif eventType == ccs.TouchEventType.ended then - self._displayValueLabel:setText("Touch Up") - elseif eventType == ccs.TouchEventType.canceled then - self._displayValueLabel:setText("Touch Cancelled") - end - end - local button = ccs.UIButton:create() - button:setTouchEnabled(true) - button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addWidget(button) -end - -function UIButtonTest.create() - local scene = UIButtonTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - - -local UIButtonScale9Test = class("UIButtonScale9Test",UIScene) -UIButtonScale9Test._displayValueLabel = nil - -function UIButtonScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonScale9Test) - return target -end - -function UIButtonScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("Button scale9 render") - alert:setFontName(font_UIButtonTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function touchEvent(sender,eventType) - if eventType == ccs.TouchEventType.began then - self._displayValueLabel:setText("Touch Down") - elseif eventType == ccs.TouchEventType.moved then - self._displayValueLabel:setText("Touch Move") - elseif eventType == ccs.TouchEventType.ended then - self._displayValueLabel:setText("Touch Up") - elseif eventType == ccs.TouchEventType.canceled then - self._displayValueLabel:setText("Touch Cancelled") - end - end - - local button = ccs.UIButton:create() - button:setTouchEnabled(true) - button:setScale9Enabled(true) - button:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:setSize(cc.size(150, button:getContentSize().height * 1.5)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addWidget(button) -end - -function UIButtonScale9Test.create() - local scene = UIButtonScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UIButtonPressedActionTest = class("UIButtonPressedActionTest",UIScene) -UIButtonPressedActionTest._displayValueLabel = nil - -function UIButtonPressedActionTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIButtonPressedActionTest) - return target -end - -function UIButtonPressedActionTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("Button Pressed Action") - alert:setFontName(font_UIButtonTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function touchEvent(sender,eventType) - if eventType == ccs.TouchEventType.began then - self._displayValueLabel:setText("Touch Down") - elseif eventType == ccs.TouchEventType.moved then - self._displayValueLabel:setText("Touch Move") - elseif eventType == ccs.TouchEventType.ended then - self._displayValueLabel:setText("Touch Up") - elseif eventType == ccs.TouchEventType.canceled then - self._displayValueLabel:setText("Touch Cancelled") - end - end - - local button = ccs.UIButton:create() - button:setTouchEnabled(true) - button:setPressedActionEnabled(true) - button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") - button:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - button:addTouchEventListener(touchEvent) - self._uiLayer:addWidget(button) -end - -function UIButtonPressedActionTest.create() - local scene = UIButtonPressedActionTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextButtonTest = class("UITextButtonTest",UIScene) -UITextButtonTest._displayValueLabel = nil - -function UITextButtonTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextButtonTest) - return target -end - -function UITextButtonTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("TextButton") - alert:setFontName(font_UIButtonTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function touchEvent(sender,eventType) - if eventType == ccs.TouchEventType.began then - self._displayValueLabel:setText("Touch Down") - elseif eventType == ccs.TouchEventType.moved then - self._displayValueLabel:setText("Touch Move") - elseif eventType == ccs.TouchEventType.ended then - self._displayValueLabel:setText("Touch Up") - elseif eventType == ccs.TouchEventType.canceled then - self._displayValueLabel:setText("Touch Cancelled") - end - end - - local textButton = ccs.UIButton:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosgui/backtotopnormal.png", "cocosgui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addWidget(textButton) -end - -function UITextButtonTest.create() - local scene = UITextButtonTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextButtonScale9Test = class("UITextButtonScale9Test",UIScene) -UITextButtonScale9Test._displayValueLabel = nil - -function UITextButtonScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextButtonScale9Test) - return target -end - -function UITextButtonScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("TextButton scale9 render") - alert:setFontName(font_UIButtonTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function touchEvent(sender,eventType) - if eventType == ccs.TouchEventType.began then - self._displayValueLabel:setText("Touch Down") - elseif eventType == ccs.TouchEventType.moved then - self._displayValueLabel:setText("Touch Move") - elseif eventType == ccs.TouchEventType.ended then - self._displayValueLabel:setText("Touch Up") - elseif eventType == ccs.TouchEventType.canceled then - self._displayValueLabel:setText("Touch Cancelled") - end - end - - local textButton = ccs.UIButton:create() - textButton:setTouchEnabled(true) - textButton:setScale9Enabled(true) - textButton:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") - textButton:setSize(cc.size(180, textButton:getContentSize().height * 1.5)) - textButton:setTitleText("Text Button scale9 render") - textButton:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textButton:addTouchEventListener(touchEvent) - self._uiLayer:addWidget(textButton) -end - -function UITextButtonScale9Test.create() - local scene = UITextButtonScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UICheckBoxTest = class("UICheckBoxTest",UIScene) -UICheckBoxTest._displayValueLabel = nil - -function UICheckBoxTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UICheckBoxTest) - return target -end - -function UICheckBoxTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UIButtonTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("CheckBox") - alert:setFontName(font_UICheckBoxTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function selectedEvent(sender,eventType) - if eventType == ccs.CheckBoxEventType.selected then - self._displayValueLabel:setText("Selected") - elseif eventType == ccs.CheckBoxEventType.unselected then - self._displayValueLabel:setText("Unselected") - end - end - - local checkBox = ccs.UICheckBox:create() - checkBox:setTouchEnabled(true) - checkBox:loadTextures("cocosgui/check_box_normal.png", - "cocosgui/check_box_normal_press.png", - "cocosgui/check_box_active.png", - "cocosgui/check_box_normal_disable.png", - "cocosgui/check_box_active_disable.png") - checkBox:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - - checkBox:addEventListener(selectedEvent) - - self._uiLayer:addWidget(checkBox) -end - -function UICheckBoxTest.create() - local scene = UICheckBoxTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UISliderTest = class("UISliderTest",UIScene) -UISliderTest._displayValueLabel = nil - -function UISliderTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UISliderTest) - return target -end - -function UISliderTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("Move the slider thumb") - self._displayValueLabel:setFontName(font_UISliderTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("Slider") - alert:setFontName(font_UISliderTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function percentChangedEvent(sender,eventType) - if eventType == ccs.SliderEventType.percent_changed then - local slider = tolua.cast(sender,"UISlider") - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setText(percent) - end - end - - local slider = ccs.UISlider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosgui/sliderTrack.png") - slider:loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosgui/sliderProgress.png") - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addWidget(slider) -end - -function UISliderTest.create() - local scene = UISliderTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UISliderScale9Test = class("UISliderScale9Test",UIScene) -UISliderScale9Test._displayValueLabel = nil - -function UISliderScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UISliderScale9Test) - return target -end - -function UISliderScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("Move the slider thumb") - self._displayValueLabel:setFontName(font_UISliderTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("Slider scale9 render") - alert:setFontName(font_UISliderTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function percentChangedEvent(sender,eventType) - if eventType == ccs.SliderEventType.percent_changed then - local slider = tolua.cast(sender,"UISlider") - local percent = "Percent " .. slider:getPercent() - self._displayValueLabel:setText(percent) - end - end - - local slider = ccs.UISlider:create() - slider:setTouchEnabled(true) - slider:loadBarTexture("cocosgui/sliderTrack2.png") - slider:loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "") - slider:loadProgressBarTexture("cocosgui/slider_bar_active_9patch.png") - slider:setScale9Enabled(true) - slider:setCapInsets(cc.rect(0, 0, 0, 0)) - slider:setSize(cc.size(250, 10)) - slider:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - slider:addEventListener(percentChangedEvent) - - self._uiLayer:addWidget(slider) -end - -function UISliderScale9Test.create() - local scene = UISliderScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UIImageViewTest = class("UIImageViewTest",UIScene) - -function UIImageViewTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIImageViewTest) - return target -end - -function UIImageViewTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("ImageView") - alert:setFontName(font_UIImageViewTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local imageView = ccs.UIImageView:create() - imageView:loadTexture("cocosgui/ccicon.png") - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getSize().height / 4.0)) - self._uiLayer:addWidget(imageView) -end - -function UIImageViewTest.create() - local scene = UIImageViewTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - - -local UIImageViewScale9Test = class("UIImageViewScale9Test",UIScene) - -function UIImageViewScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIImageViewScale9Test) - return target -end - -function UIImageViewScale9Test:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("ImageView scale9 render") - alert:setFontName(font_UIImageViewTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local imageView = ccs.UIImageView:create() - imageView:setScale9Enabled(true) - imageView:loadTexture("cocosgui/buttonHighlighted.png") - imageView:setSize(cc.size(200, 85)) - imageView:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + imageView:getSize().height / 4.0)) - self._uiLayer:addWidget(imageView) -end - -function UIImageViewScale9Test.create() - local scene = UIImageViewScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILoadingBarLeftTest = class("UILoadingBarLeftTest",UIScene) -UILoadingBarLeftTest._count = 0 - -function UILoadingBarLeftTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarLeftTest) - return target -end - -function UILoadingBarLeftTest:initExtend() - - self._uiLayer = ccs.UILayer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - back_label:setVisible(false) - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LoadingBar") - alert:setFontName(font_UILoadingBarTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local loadingBar = ccs.UILoadingBar:create() - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosgui/sliderProgress.png") - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) - self._uiLayer:addWidget(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = self._uiLayer:getWidgetByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = self._uiLayer:getWidgetByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - -function UILoadingBarLeftTest.create() - local scene = UILoadingBarLeftTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILoadingBarRightTest = class("UILoadingBarRightTest",UIScene) -UILoadingBarRightTest._count = 0 - -function UILoadingBarRightTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarRightTest) - return target -end - -function UILoadingBarRightTest:initExtend() - - self._uiLayer = ccs.UILayer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - back_label:setVisible(false) - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LoadingBar") - alert:setFontName(font_UILoadingBarTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local loadingBar = ccs.UILoadingBar:create() - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosgui/sliderProgress.png") - loadingBar:setDirection(ccs.LoadingBarType.right) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) - self._uiLayer:addWidget(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = self._uiLayer:getWidgetByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = self._uiLayer:getWidgetByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - -function UILoadingBarRightTest.create() - local scene = UILoadingBarRightTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILoadingBarLeftScale9Test = class("UILoadingBarLeftScale9Test",UIScene) -UILoadingBarLeftScale9Test._count = 0 - -function UILoadingBarLeftScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarLeftScale9Test) - return target -end - -function UILoadingBarLeftScale9Test:initExtend() - - self._uiLayer = ccs.UILayer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - back_label:setVisible(false) - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LoadingBar Scale9 Render") - alert:setFontName(font_UILoadingBarTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local loadingBar = ccs.UILoadingBar:create() - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosgui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setSize(cc.size(300, 30)) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) - self._uiLayer:addWidget(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = self._uiLayer:getWidgetByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = self._uiLayer:getWidgetByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - -function UILoadingBarLeftScale9Test.create() - local scene = UILoadingBarLeftScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILoadingBarRightScale9Test = class("UILoadingBarRightScale9Test",UIScene) -UILoadingBarRightScale9Test._count = 0 - -function UILoadingBarRightScale9Test.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILoadingBarRightScale9Test) - return target -end - -function UILoadingBarRightScale9Test:initExtend() - - self._uiLayer = ccs.UILayer:create() - self:addChild(self._uiLayer) - - self._widget = ccs.CCSGUIReader:getInstance():widgetFromJsonFile("cocosgui/UITest/UITest.json") - self._uiLayer:addWidget(self._widget) - - self._sceneTitle = self._uiLayer:getWidgetByName("UItest") - - local back_label = self._uiLayer:getWidgetByName("back") - back_label:setVisible(false) - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LoadingBar Scale9 Render") - alert:setFontName(font_UILoadingBarTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local loadingBar = ccs.UILoadingBar:create() - loadingBar:setName("LoadingBar") - loadingBar:loadTexture("cocosgui/slider_bar_active_9patch.png") - loadingBar:setScale9Enabled(true) - loadingBar:setCapInsets(cc.rect(0, 0, 0, 0)) - loadingBar:setSize(cc.size(300, 30)) - loadingBar:setDirection(ccs.LoadingBarType.right) - loadingBar:setPercent(0) - - loadingBar:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + loadingBar:getSize().height / 4.0)) - self._uiLayer:addWidget(loadingBar) - - local function update(delta) - self._count = self._count + 1 - if self._count > 100 then - self._count = 0 - end - - if self._uiLayer ~= nil then - local loadingBar = tolua.cast(self._uiLayer:getWidgetByName("LoadingBar"), "UILoadingBar") - loadingBar:setPercent(self._count) - end - end - - self:scheduleUpdateWithPriorityLua(update, 0) - - local function onNodeEvent(tag) - if tag == "exit" then - self:unscheduleUpdate() - end - end - - self:registerScriptHandler(onNodeEvent) - - local function previousCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene()) - end - end - - local left_button = self._uiLayer:getWidgetByName("left_Button") - left_button:addTouchEventListener(previousCallback) - - local function restartCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.currentUIScene()) - end - end - - local middle_button = self._uiLayer:getWidgetByName("middle_Button") - middle_button:addTouchEventListener(restartCallback) - - local function nextCallback(sender, eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - cc.Director:getInstance():replaceScene(guiSceneManager.nextUIScene()) - end - end - - local right_button = self._uiLayer:getWidgetByName("right_Button") - right_button:addTouchEventListener(nextCallback) - - local function menuCloseCallback( sender,eventType) - if eventType == ccs.TouchEventType.ended then - self:unscheduleUpdate() - self._uiLayer:removeFromParent() - local scene = CocoStudioTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end - end - end - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - -function UILoadingBarRightScale9Test.create() - local scene = UILoadingBarRightScale9Test.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILabelAtlasTest = class("UILabelAtlasTest",UIScene) - -function UILabelAtlasTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelAtlasTest) - return target -end - -function UILabelAtlasTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LabelAtlas") - alert:setFontName(font_UILabelAtlasTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - - local labelAtlas = ccs.UILabelAtlas:create() - labelAtlas:setProperty("1234567890", "cocosgui/labelatlas.png", 17, 22, "0") - labelAtlas:setPosition(cc.p((widgetSize.width) / 2, widgetSize.height / 2.0)) - - self._uiLayer:addWidget(labelAtlas) -end - -function UILabelAtlasTest.create() - local scene = UILabelAtlasTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILabelBMFontTest = class("UILabelBMFontTest",UIScene) - -function UILabelBMFontTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelBMFontTest) - return target -end - -function UILabelBMFontTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("LabelBMFont") - alert:setFontName(font_UILabelBMFontTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - - local labelBMFont = ccs.UILabelBMFont:create() - labelBMFont:setFntFile("cocosgui/bitmapFontTest2.fnt") - labelBMFont:setText("BMFont") - labelBMFont:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2.0 + labelBMFont:getSize().height / 8.0)) - - self._uiLayer:addWidget(labelBMFont) -end - -function UILabelBMFontTest.create() - local scene = UILabelBMFontTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UILabelTest = class("UILabelTest",UIScene) - -function UILabelTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UILabelTest) - return target -end - -function UILabelTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("Label") - alert:setFontName(font_UILabelTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local label = ccs.UILabel:create() - label:setText("Label") - label:setFontName("AmericanTypewriter") - label:setFontSize(30) - label:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + label:getSize().height / 4)) - self._uiLayer:addWidget(label) -end - -function UILabelTest.create() - local scene = UILabelTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextAreaTest = class("UITextAreaTest",UIScene) - -function UITextAreaTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextAreaTest) - return target -end - -function UITextAreaTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("TextArea") - alert:setFontName(font_UITextAreaTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local textArea = ccs.UILabel:create() - textArea:setTextAreaSize(cc.size(280, 150)) - textArea:setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER) - textArea:setText("TextArea widget can line wrap") - textArea:setFontName("AmericanTypewriter") - textArea:setFontSize(32) - textArea:setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - textArea:getSize().height / 8)) - self._uiLayer:addWidget(textArea) -end - -function UITextAreaTest.create() - local scene = UITextAreaTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextFieldTest = class("UITextFieldTest",UIScene) -UITextFieldTest._displayValueLabel = nil - -function UITextFieldTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldTest) - return target -end - -function UITextFieldTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UITextFieldTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("TextField") - alert:setFontName(font_UITextFieldTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccs.TextFiledEventType.attach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0))) - self._displayValueLabel:setText("attach with IME") - elseif eventType == ccs.TextFiledEventType.detach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) - self._displayValueLabel:setText("detach with IME") - elseif eventType == ccs.TextFiledEventType.insert_text then - self._displayValueLabel:setText("insert words") - elseif eventType == ccs.TextFiledEventType.delete_backward then - self._displayValueLabel:setText("delete word") - end - end - - local textField = ccs.UITextField:create() - textField:setTouchEnabled(true) - textField:setFontName(font_UITextFieldTest) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addWidget(textField) -end - -function UITextFieldTest.create() - local scene = UITextFieldTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextFieldMaxLengthTest = class("UITextFieldMaxLengthTest",UIScene) -UITextFieldMaxLengthTest._displayValueLabel = nil - -function UITextFieldMaxLengthTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldMaxLengthTest) - return target -end - -function UITextFieldMaxLengthTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UITextFieldTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("TextField max length") - alert:setFontName(font_UITextFieldTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccs.TextFiledEventType.attach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.225,cc.p(screenSize.width / 2.0, screenSize.height / 2.0 + textField:getContentSize().height / 2.0))) - local info = string.format("attach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setText(info) - elseif eventType == ccs.TextFiledEventType.detach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) - local info = string.format("detach with IME max length %d",textField:getMaxLength()) - self._displayValueLabel:setText(info) - elseif eventType == ccs.TextFiledEventType.insert_text then - local textField = tolua.cast(sender,"UITextField") - local info = string.format("insert words max length %d",textField:getMaxLength()) - self._displayValueLabel:setText(info) - elseif eventType == ccs.TextFiledEventType.delete_backward then - local textField = tolua.cast(sender,"UITextField") - local info = string.format("delete word max length %d",textField:getMaxLength()) - self._displayValueLabel:setText(info) - end - end - - local textField = ccs.UITextField:create() - textField:setMaxLengthEnabled(true) - textField:setMaxLength(3) - textField:setTouchEnabled(true) - textField:setFontName(font_UITextFieldTest) - textField:setFontSize(30) - textField:setPlaceHolder("input words here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addWidget(textField) -end - -function UITextFieldMaxLengthTest.create() - local scene = UITextFieldMaxLengthTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UITextFieldPasswordTest = class("UITextFieldPasswordTest",UIScene) -UITextFieldPasswordTest._displayValueLabel = nil - -function UITextFieldPasswordTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UITextFieldPasswordTest) - return target -end - -function UITextFieldPasswordTest:initExtend() - - self:init() - local widgetSize = self._widget:getSize() - - self._displayValueLabel = ccs.UILabel:create() - self._displayValueLabel:setText("No Event") - self._displayValueLabel:setFontName(font_UITextFieldTest) - self._displayValueLabel:setFontSize(32) - self._displayValueLabel:setAnchorPoint(cc.p(0.5, -1)) - self._displayValueLabel:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 + self._displayValueLabel:getSize().height * 1.5)) - self._uiLayer:addWidget(self._displayValueLabel) - - local alert = ccs.UILabel:create() - alert:setText("TextField password") - alert:setFontName(font_UITextFieldTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local function textFieldEvent(sender, eventType) - if eventType == ccs.TextFiledEventType.attach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) - self._displayValueLabel:setText("detach with IME password") - elseif eventType == ccs.TextFiledEventType.detach_with_ime then - local textField = tolua.cast(sender,"UITextField") - local screenSize = cc.Director:getInstance():getWinSize() - textField:runAction(cc.MoveTo:create(0.175, cc.p(screenSize.width / 2.0, screenSize.height / 2.0))) - self._displayValueLabel:setText("detach with IME password") - elseif eventType == ccs.TextFiledEventType.insert_text then - self._displayValueLabel:setText("insert words password") - elseif eventType == ccs.TextFiledEventType.delete_backward then - self._displayValueLabel:setText("delete word password") - end - end - - local textField = ccs.UITextField:create() - textField:setPasswordEnabled(true) - textField:setPasswordStyleText("*") - textField:setTouchEnabled(true) - textField:setFontName(font_UITextFieldTest) - textField:setFontSize(30) - textField:setPlaceHolder("input password here") - textField:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0)) - textField:addEventListener(textFieldEvent) - self._uiLayer:addWidget(textField) -end - -function UITextFieldPasswordTest.create() - local scene = UITextFieldPasswordTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local UIPanelTest = class("UIPanelTest",UIScene) - -function UIPanelTest.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, UIPanelTest) - return target -end - -function UIPanelTest:initExtend() - - self:init() - - local widgetSize = self._widget:getSize() - - local alert = ccs.UILabel:create() - alert:setText("Panel") - alert:setFontName(font_UIPanelTest) - alert:setFontSize(30) - alert:setColor(cc.c3b(159, 168, 176)) - alert:setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert:getSize().height * 1.75)) - self._uiLayer:addWidget(alert) - - local background = self._uiLayer:getWidgetByName("background_Panel") - - local layout = ccs.UILayout:create() - layout:setSize(cc.size(280, 150)) - local backgroundSize = background:getSize() - layout:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - layout:getSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - layout:getSize().height) / 2)) - self._uiLayer:addWidget(layout) - - local button = ccs.UIButton:create() - button:setTouchEnabled(true) - button:loadTextures("cocosgui/animationbuttonnormal.png", "cocosgui/animationbuttonpressed.png", "") - button:setPosition(cc.p(button:getSize().width / 2, layout:getSize().height - button:getSize().height / 2)) - layout:addChild(button) - - local textButton = UIButton:create() - textButton:setTouchEnabled(true) - textButton:loadTextures("cocosgui/backtotopnormal.png", "cocosgui/backtotoppressed.png", "") - textButton:setTitleText("Text Button") - textButton:setPosition(cc.p(layout:getSize().width / 2, layout:getSize().height / 2)) - layout:addChild(textButton) - - local button_scale9 = UIButton:create() - button_scale9:setTouchEnabled(true) - button_scale9:loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", "") - button_scale9:setScale9Enabled(true) - button_scale9:setSize(cc.size(100, button_scale9:getContentSize().height)) - button_scale9:setPosition(cc.p(layout:getSize().width - button_scale9:getSize().width / 2, button_scale9:getSize().height / 2)) - layout:addChild(button_scale9) -end - -function UIPanelTest.create() - local scene = UIPanelTest.extend(cc.Scene:create()) - scene:initExtend() - return scene -end - -local cocoStudioGuiArray = -{ - { - title = "UIButtonTest", - func = function () - return UIButtonTest.create() - end, - }, - - { - title = "UIButtonScale9Test", - func = function () - return UIButtonScale9Test.create() - end, - }, - - { - title = "ButtonPressedActionTest", - func = function () - return UIButtonPressedActionTest.create() - end, - }, - - { - title = "UITextButtonTest", - func = function () - return UITextButtonTest.create() - end, - }, - - { - title = "UITextButtonScale9Test", - func = function () - return UITextButtonScale9Test.create() - end, - }, - - { - title = "UICheckBoxTest", - func = function () - return UICheckBoxTest.create() - end, - }, - - { - title = "UISliderTest", - func = function () - return UISliderTest.create() - end, - }, - - { - title = "UISliderScale9Test", - func = function () - return UISliderScale9Test.create() - end, - }, - - { - title = "UIImageViewTest", - func = function ( ) - return UIImageViewTest.create() - end, - }, - - { - title = "UIImageViewScale9Test", - func = function ( ) - return UIImageViewScale9Test.create() - end, - }, - - { - title = "UILoadingBarLeftTest", - func = function ( ) - return UILoadingBarLeftTest.create() - end, - }, - - { - title = "UILoadingBarRightTest", - func = function ( ) - return UILoadingBarRightTest.create() - end, - }, - - { - title = "UILoadingBarLeftScale9Test", - func = function ( ) - return UILoadingBarLeftScale9Test.create() - end, - }, - - { - title = "UILoadingBarRightScale9Test", - func = function ( ) - return UILoadingBarRightScale9Test.create() - end, - }, - - { - title = "UILabelAtlasTest", - func = function ( ) - return UILabelAtlasTest.create() - end, - }, - - { - title = "UILabelBMFontTest", - func = function ( ) - return UILabelBMFontTest.create() - end, - }, - - { - title = "UILabelTest", - func = function ( ) - return UILabelTest.create() - end, - }, - - { - title = "UITextAreaTest", - func = function ( ) - return UITextAreaTest.create() - end, - }, - - { - title = "UITextFieldTest", - func = function ( ) - return UITextFieldTest.create() - end, - }, - - { - title = "UITextFieldMaxLengthTest", - func = function ( ) - return UITextFieldMaxLengthTest.create() - end, - }, - - { - title = "UITextFieldPasswordTest", - func = function ( ) - return UITextFieldPasswordTest.create() - end, - }, - - { - title = "UIPanelTest", - func = function ( ) - return UIPanelTest.create() - end, - }, - - { - title = "UIPanelColorTest", - func = function ( ) - return UIPanelColorTest.create() - end, - }, - - { - title = "UIPanelGradientTest", - func = function ( ) - return UIPanelGradientTest.create() - end, - }, -} - -function guiSceneManager.nextUIScene() - guiSceneManager.currentUISceneIdx = (guiSceneManager.currentUISceneIdx + 1) % table.getn(cocoStudioGuiArray) - if 0 == guiSceneManager.currentUISceneIdx then - guiSceneManager.currentUISceneIdx = table.getn(cocoStudioGuiArray) - end - - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - -function guiSceneManager.previousUIScene() - - guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx - 1 - if guiSceneManager.currentUISceneIdx <= 0 then - guiSceneManager.currentUISceneIdx = guiSceneManager.currentUISceneIdx + table.getn(cocoStudioGuiArray) - end - - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - -function guiSceneManager.currentUIScene() - return cocoStudioGuiArray[guiSceneManager.currentUISceneIdx].func() -end - - - -function runCocosGUITestScene() - local scene = guiSceneManager.currentUIScene() - cc.Director:getInstance():replaceScene(scene) -end diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id new file mode 100644 index 0000000000..0321ef2e8f --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -0,0 +1 @@ +f6747c1223734554b4f7eeff72714b4457758e00 \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua new file mode 100644 index 0000000000..b6a59eb9ce --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -0,0 +1,75 @@ +local SceneEditorTestLayer = class("SceneEditorTestLayer") +SceneEditorTestLayer._curNode = nil + +function SceneEditorTestLayer.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, SceneEditorTestLayer) + return target +end + +function SceneEditorTestLayer:init() + + + local mainMenuLabel = ccs.UILabel:create() + mainMenuLabel:setText("MainMenu") + mainMenuLabel:setFontSize(20) + mainMenuLabel:setTouchScaleChangeEnabled(true) + mainMenuLabel:setPosition(cc.p(430,30)) + mainMenuLabel:setTouchEnabled(true) + mainMenuLabel:addTouchEventListener(menuCloseCallback) + self._uiLayer:addWidget(mainMenuLabel) +end + +function SceneEditorTestLayer:createGameScene() + local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/FishJoy2.json") + if nil == node then + return + end + self._curNode = node + + local function menuCloseCallback( sender ) + local backMusic = tolua.cast(self._curNode:getComponent("CCBackgroundAudio"),"ComAudio") + backMusic:stopBackgroundMusic(); + ccs.SceneReader:getInstance():purgeSceneReader(); + ccs.ActionManagerEx:getInstance():purgeActionManager(); + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end + end + + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local itemBack = cc.MenuItemFont:create("Back") + itemBack:setColor(cc.c3b(255, 255, 255)) + itemBack:setPosition(cc.p(VisibleRect:bottom().x - 50, VisibleRect:bottom().y + 25)) + itemBack:registerScriptTapHandler(menuCloseCallback) + local menuBack = cc.Menu:create() + menuBack:setPosition(cc.p(0.0, 0.0)) + menuBack:setZOrder(4) + menuBack:addChild(itemBack) + + node:addChild(menuBack) + + ccs.ActionManagerEx:getInstance():playActionByName("startMenu_1.json","Animation1") + + return node +end + +function SceneEditorTestLayer.create() + local scene = cc.Scene:create() + local layer = SceneEditorTestLayer.extend(cc.LayerColor:create()) + --layer:initWithColor(cc.c4b(0,0,0,255)) + layer:addChild(layer:createGameScene(), 0, 1) + scene:addChild(layer) + return scene +end + +function runCocosSceneTestScene() + local scene = SceneEditorTestLayer.create() + cc.Director:getInstance():replaceScene(scene) +end \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua index dce016a69c..2c2e355870 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua @@ -1,4 +1,5 @@ require "luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest" +require "luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest" local LINE_SPACE = 40 local ITEM_TAG_BASIC = 1000 @@ -26,7 +27,7 @@ local cocoStudioTestItemNames = { itemTitle = "CocoStudioSceneTest", testScene = function () - --runSceneEditorTestLayer() + runCocosSceneTestScene() end } } diff --git a/samples/Lua/TestLua/proj.ios/AppController.mm b/samples/Lua/TestLua/proj.ios/AppController.mm index 5e7ebbefcc..7ba8b26843 100644 --- a/samples/Lua/TestLua/proj.ios/AppController.mm +++ b/samples/Lua/TestLua/proj.ios/AppController.mm @@ -45,7 +45,7 @@ static AppDelegate s_sharedApplication; window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; CCEAGLView *__glView = [CCEAGLView viewWithFrame: [window bounds] pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16 + depthFormat: GL_DEPTH24_STENCIL8_OES preserveBackbuffer: NO sharegroup: nil multiSampling: NO diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 5c40f4fade..53dfc1d7a4 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -23,11 +23,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s/cocos/gui/CocosGUI.h +headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter CCSGUIReader +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter CCSGUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio # 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 @@ -49,7 +49,10 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* rename_functions = UIHelper::[instance=getInstance], ArmatureDataManager::[sharedArmatureDataManager=getInstance], - CCSGUIReader::[shareReader=getInstance] + CCSGUIReader::[shareReader=getInstance], + ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager], + SceneReader::[purgeSceneReader=destroySceneReader] + rename_classes = From e182328d5101b934ac2c227c7ac55b1c514b4ff2 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 12 Nov 2013 16:25:39 +0800 Subject: [PATCH 118/185] fix incomplete copy resource --- build/android-build.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/build/android-build.py b/build/android-build.py index 4a65c9e6e2..7670e03dd2 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -109,6 +109,7 @@ def copy_files(src, dst): if os.path.isdir(path): new_dst = os.path.join(dst, item) os.mkdir(new_dst) + print new_dst copy_files(path, new_dst) def copy_resources(target, app_android_root): @@ -133,13 +134,26 @@ def copy_resources(target, app_android_root): resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android") if target == "crystalcraze": resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android") - if target == "moonwarriors": - resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res") if target == "testjavascript": resources_dir = os.path.join(app_android_root, "../../Shared/tests/") if target == "watermelonwithme": resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe") - copy_files(resources_dir, assets_dir) + if target != "moonwarriors": + copy_files(resources_dir, assets_dir) + else: + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res") + dst_dir = os.path.join(assets_dir, "res") + os.mkdir(dst_dir) + copy_files(resources_dir, dst_dir) + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/src") + dst_dir = os.path.join(assets_dir, "src") + os.mkdir(dst_dir) + copy_files(resources_dir, dst_dir) + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors") + for item in os.listdir(resources_dir): + path = os.path.join(resources_dir, item) + if item.endswith('.js') and os.path.isfile(path): + shutil.copy(path, assets_dir) # AssetsManager test should also copy javascript files if target == "assetsmanager": From c1d256c159f7b2a70a6b18500291e9d85f480753 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 16:52:03 +0800 Subject: [PATCH 119/185] issue #2868:modify ccs lua test samples --- .../lua_cocos2dx_coco_studio_manual.cpp | 186 +++++++++--------- samples/Lua/TestLua/Classes/AppDelegate.cpp | 8 + .../CocoStudioGUITest.lua.REMOVED.git-id | 2 +- .../CocoStudioSceneTest.lua | 6 +- tools/tolua/cocos2dx_studio.ini | 6 +- 5 files changed, 106 insertions(+), 102 deletions(-) diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 845020a538..63396d5e9e 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -132,7 +132,7 @@ static void extendUIWidget(lua_State* L) } } -static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) +static int lua_cocos2dx_UICheckBox_addEventListenerCheckBox(lua_State* L) { if (nullptr == L) return 0; @@ -149,7 +149,7 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListener'\n", NULL); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListenerCheckBox'\n", NULL); return 0; } #endif @@ -174,17 +174,17 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->setUserObject(listener); - self->addEventListener(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'addEventListenerCheckBox' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err); return 0; #endif } @@ -196,11 +196,11 @@ static void extendUICheckBox(lua_State* L) lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "addEventListener", lua_cocos2dx_UICheckBox_addEventListener); + tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_UICheckBox_addEventListenerCheckBox); } } -static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) +static int lua_cocos2dx_UISlider_addEventListenerSlider(lua_State* L) { if (nullptr == L) return 0; @@ -217,7 +217,7 @@ static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListener'\n", NULL); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListenerSlider'\n", NULL); return 0; } #endif @@ -242,18 +242,18 @@ static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->setUserObject(listener); - self->addEventListener(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'addEventListenerSlider' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err); return 0; #endif } @@ -264,11 +264,11 @@ static void extendUISlider(lua_State* L) lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "addEventListener", lua_cocos2dx_UISlider_addEventListener); + tolua_function(L, "addEventListenerSlider", lua_cocos2dx_UISlider_addEventListenerSlider); } } -static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) +static int lua_cocos2dx_UITextField_addEventListenerTextField(lua_State* L) { if (nullptr == L) return 0; @@ -285,7 +285,7 @@ static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListener'\n", NULL); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListenerTextField'\n", NULL); return 0; } #endif @@ -310,18 +310,18 @@ static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->setUserObject(listener); - self->addEventListener(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'addEventListenerTextField' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); return 0; #endif } @@ -332,11 +332,11 @@ static void extendUITextField(lua_State* L) lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "addEventListener", lua_cocos2dx_UITextField_addEventListener); + tolua_function(L, "addEventListenerTextField", lua_cocos2dx_UITextField_addEventListenerTextField); } } -static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) +static int lua_cocos2dx_UIPageView_addEventListenerPageView(lua_State* L) { if (nullptr == L) return 0; @@ -353,7 +353,7 @@ static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListener'\n", NULL); + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListenerPageView'\n", NULL); return 0; } #endif @@ -378,18 +378,18 @@ static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->setUserObject(listener); - self->addEventListener(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0; } - CCLOG("'addEventListener' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); + CCLOG("'addEventListenerPageView' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); + tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err); return 0; #endif } @@ -400,79 +400,77 @@ static void extendUIPageView(lua_State* L) lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { - tolua_function(L, "addEventListener", lua_cocos2dx_UIPageView_addEventListener); + tolua_function(L, "addEventListenerPageView", lua_cocos2dx_UIPageView_addEventListenerPageView); } } -//static int lua_cocos2dx_UIListView_addEventListener(lua_State* L) -//{ -// if (nullptr == L) -// return 0; -// -// int argc = 0; -// UIListView* self = nullptr; -// -//#if COCOS2D_DEBUG >= 1 -// tolua_Error tolua_err; -// if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror; -//#endif -// -// self = static_cast(tolua_tousertype(L,1,0)); -// -//#if COCOS2D_DEBUG >= 1 -// if (nullptr == self) { -// tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListener'\n", NULL); -// return 0; -// } -//#endif -// argc = lua_gettop(L) - 1; -// if (2 == argc) -// { -//#if COCOS2D_DEBUG >= 1 -// if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || -// !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) -// { -// goto tolua_lerror; -// } -//#endif -// LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); -// if (nullptr == listern) -// { -// tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); -// return 0; -// } -// -// LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); -// Object* obj = static_cast(tolua_tousertype(L, 3, nullptr)); -// -// listern->setObjToLua(obj); -// ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); -// -// self->addEventListener(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); -// -// return 0; -// } -// -// CCLOG("'addEventListener' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 2); -// -// return 0; -// -//#if COCOS2D_DEBUG >= 1 -//tolua_lerror: -// tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); -// return 0; -//#endif -//} -// -//static void extendUIListView(lua_State* L) -//{ -// lua_pushstring(L, "UIListView"); -// lua_rawget(L, LUA_REGISTRYINDEX); -// if (lua_istable(L,-1)) -// { -// tolua_function(L, "addEventListener", lua_cocos2dx_UIListView_addEventListener); -// } -//} +static int lua_cocos2dx_UIListView_addEventListenerListView(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + UIListView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListenerListView'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->setUserObject(listern); + self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerListView' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err); + return 0; +#endif +} + +static void extendUIListView(lua_State* L) +{ + lua_pushstring(L, "UIListView"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerListView", lua_cocos2dx_UIListView_addEventListenerListView); + } +} static int lua_cocos2dx_UILayoutParameter_setMargin(lua_State* L) { @@ -907,7 +905,7 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L) extendUISlider(L); extendUITextField(L); extendUIPageView(L); -// extendUIListView(L); + extendUIListView(L); extendLayoutParameter(L); extendArmatureAnimation(L); extendArmatureDataManager(L); diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index deefa14f40..d07fb61f22 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -59,6 +59,14 @@ bool AppDelegate::applicationDidFinishLaunching() std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), "Images"); searchPaths.insert(searchPaths.begin(), "cocosbuilderRes"); + if (screenSize.height > 320) + { + searchPaths.insert(searchPaths.begin(), "hd/scenetest"); + } + else + { + searchPaths.insert(searchPaths.begin(), "scenetest"); + } #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY searchPaths.push_back("TestCppResources"); diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id index 0321ef2e8f..ca5791ada7 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -1 +1 @@ -f6747c1223734554b4f7eeff72714b4457758e00 \ No newline at end of file +63707dd119d9dad00da66996544c1892162dab08 \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index b6a59eb9ce..2b7fd6905d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -32,10 +32,8 @@ function SceneEditorTestLayer:createGameScene() self._curNode = node local function menuCloseCallback( sender ) - local backMusic = tolua.cast(self._curNode:getComponent("CCBackgroundAudio"),"ComAudio") - backMusic:stopBackgroundMusic(); - ccs.SceneReader:getInstance():purgeSceneReader(); - ccs.ActionManagerEx:getInstance():purgeActionManager(); + ccs.SceneReader:getInstance():destroySceneReader() + ccs.ActionManagerEx:destroyActionManager() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 53dfc1d7a4..734bf0f02b 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/co # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter CCSGUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -45,11 +45,11 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* UILayer::[getInputManager], UILayoutParameter::[(s|g)etMargin], UIHelper::[init], - CCSGUIReader::[setPropsForImageButtonFromJsonDictionary] + GUIReader::[setPropsForImageButtonFromJsonDictionary] rename_functions = UIHelper::[instance=getInstance], ArmatureDataManager::[sharedArmatureDataManager=getInstance], - CCSGUIReader::[shareReader=getInstance], + GUIReader::[shareReader=getInstance], ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager], SceneReader::[purgeSceneReader=destroySceneReader] From 18bc96096c389df1946db7652d0b86c8a47ecd09 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 17:18:51 +0800 Subject: [PATCH 120/185] Resolve some warning and modify uint32_t to long --- cocos/scripting/lua/bindings/LuaBasicConversions.cpp | 2 +- cocos/scripting/lua/bindings/LuaBasicConversions.h | 2 +- tools/bindings-generator | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 4c91daa42b..6fe9afcd00 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -32,7 +32,7 @@ extern "C" { } #endif -std::map g_luaType; +std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 2e2e525993..6861d1a056 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -10,7 +10,7 @@ extern "C" { using namespace cocos2d; -extern std::map g_luaType; +extern std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); diff --git a/tools/bindings-generator b/tools/bindings-generator index 7ccbabbaa6..5f62d1fbcf 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 7ccbabbaa677607048c511b33cb6d83b2081220e +Subproject commit 5f62d1fbcf526dce6135e3829682b421bf794823 From cb51df7d65df708ccc63e9aec11b35a4bce8f4bb Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 17:31:24 +0800 Subject: [PATCH 121/185] Update bindings-generator --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 5f62d1fbcf..2f3c19e01d 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5f62d1fbcf526dce6135e3829682b421bf794823 +Subproject commit 2f3c19e01d5043485d0887ad69a3f02e312ad690 From 0acaa1f76e4c44477fcf88d52f18189ff9a75581 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 12 Nov 2013 09:50:13 +0000 Subject: [PATCH 122/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index ce2f223cd3..3fa10c3f8f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit ce2f223cd3b4bffbd564df37c738fc5b18f8d853 +Subproject commit 3fa10c3f8f9fe083ef05cb401924d31740da9719 From d43bc3f75d92026f66c871bb47192daec9491676 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 12 Nov 2013 17:53:23 +0800 Subject: [PATCH 123/185] remove unnecessary print --- build/android-build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/build/android-build.py b/build/android-build.py index 7670e03dd2..34ac6010d9 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -109,7 +109,6 @@ def copy_files(src, dst): if os.path.isdir(path): new_dst = os.path.join(dst, item) os.mkdir(new_dst) - print new_dst copy_files(path, new_dst) def copy_resources(target, app_android_root): From 706eeaaff9b0154746da99245decdc20e37a732d Mon Sep 17 00:00:00 2001 From: bmanGH Date: Mon, 7 Oct 2013 00:01:56 +0800 Subject: [PATCH 124/185] fix direct delete touch object without use release crash bug; --- cocos2dx/platform/CCEGLViewProtocol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index 870146a2f9..985cbb51c7 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -351,8 +351,8 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode for (auto& touch : touchEvent._touches) { - // delete the touch object. - delete touch; + // release the touch object. + touch->release(); } } From 06ca84ba68b11e45ade678f0ae3fa2fc208f8330 Mon Sep 17 00:00:00 2001 From: bmanGH Date: Sun, 13 Oct 2013 11:47:51 +0800 Subject: [PATCH 125/185] use Configuration::getInstance()->supportsShareableVAO() in place of CC_TEXTURE_ATLAS_USE_VAO; --- cocos2dx/CCConfiguration.cpp | 4 + cocos2dx/draw_nodes/CCDrawNode.cpp | 50 +++--- .../particle_nodes/CCParticleSystemQuad.cpp | 122 +++++++-------- .../particle_nodes/CCParticleSystemQuad.h | 5 - cocos2dx/platform/android/CCEGLView.cpp | 7 - cocos2dx/shaders/ccGLStateCache.cpp | 21 ++- cocos2dx/textures/CCTextureAtlas.cpp | 146 +++++++++--------- cocos2dx/textures/CCTextureAtlas.h | 5 - 8 files changed, 171 insertions(+), 189 deletions(-) diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index cf88679366..75293a6f3f 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -259,7 +259,11 @@ bool Configuration::supportsDiscardFramebuffer() const bool Configuration::supportsShareableVAO() const { +#if CC_TEXTURE_ATLAS_USE_VAO return _supportsShareableVAO; +#else + return false; +#endif } // diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index 541bd8974c..10f2b1d19e 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -25,6 +25,7 @@ #include "CCGL.h" #include "support/CCNotificationCenter.h" #include "CCEventType.h" +#include "CCConfiguration.h" NS_CC_BEGIN @@ -114,11 +115,11 @@ DrawNode::~DrawNode() glDeleteBuffers(1, &_vbo); _vbo = 0; -#if CC_TEXTURE_ATLAS_USE_VAO - glDeleteVertexArrays(1, &_vao); - GL::bindVAO(0); - _vao = 0; -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + glDeleteVertexArrays(1, &_vao); + GL::bindVAO(0); + _vao = 0; + } #if CC_ENABLE_CACHE_TEXTURE_DATA NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); @@ -159,10 +160,10 @@ bool DrawNode::init() ensureCapacity(512); -#if CC_TEXTURE_ATLAS_USE_VAO - glGenVertexArrays(1, &_vao); - GL::bindVAO(_vao); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + glGenVertexArrays(1, &_vao); + GL::bindVAO(_vao); + } glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); @@ -179,9 +180,9 @@ bool DrawNode::init() glBindBuffer(GL_ARRAY_BUFFER, 0); -#if CC_TEXTURE_ATLAS_USE_VAO - GL::bindVAO(0); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + GL::bindVAO(0); + } CHECK_GL_ERROR_DEBUG(); @@ -206,21 +207,22 @@ void DrawNode::render() glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); _dirty = false; } -#if CC_TEXTURE_ATLAS_USE_VAO - GL::bindVAO(_vao); -#else - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + if (Configuration::getInstance()->supportsShareableVAO()) { + GL::bindVAO(_vao); + } + else { + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - // vertex - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + // vertex + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - // color - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + // color + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - // texcood - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); -#endif + // texcood + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); + } glDrawArrays(GL_TRIANGLES, 0, _bufferCount); glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 5a8912b203..2d637feb4a 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "support/TransformUtils.h" #include "support/CCNotificationCenter.h" #include "CCEventType.h" +#include "CCConfiguration.h" // extern #include "kazmath/GL/matrix.h" @@ -57,11 +58,12 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) } initIndices(); -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + setupVBOandVAO(); + } + else { + setupVBO(); + } setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); @@ -81,9 +83,7 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) ParticleSystemQuad::ParticleSystemQuad() :_quads(NULL) ,_indices(NULL) -#if CC_TEXTURE_ATLAS_USE_VAO ,_VAOname(0) -#endif { memset(_buffersVBO, 0, sizeof(_buffersVBO)); } @@ -95,10 +95,10 @@ ParticleSystemQuad::~ParticleSystemQuad() CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); glDeleteBuffers(2, &_buffersVBO[0]); -#if CC_TEXTURE_ATLAS_USE_VAO - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + glDeleteVertexArrays(1, &_VAOname); + GL::bindVAO(0); + } } #if CC_ENABLE_CACHE_TEXTURE_DATA @@ -355,47 +355,46 @@ void ParticleSystemQuad::draw() CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); -#if CC_TEXTURE_ATLAS_USE_VAO - // - // Using VBO and VAO - // - GL::bindVAO(_VAOname); + if (Configuration::getInstance()->supportsShareableVAO()) { + // + // Using VBO and VAO + // + GL::bindVAO(_VAOname); #if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); #endif - glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); + glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); #if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif + } + else { + // + // Using VBO without VAO + // -#else - // - // Using VBO without VAO - // + #define kQuadSize sizeof(_quads[0].bl) - #define kQuadSize sizeof(_quads[0].bl) + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); + // vertices + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); + // colors + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); + // tex coords + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - // vertices - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); - // colors - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); - // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); - glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - -#endif + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } CC_INCREMENT_GL_DRAWS(1); CHECK_GL_ERROR_DEBUG(); @@ -454,11 +453,12 @@ void ParticleSystemQuad::setTotalParticles(int tp) } initIndices(); -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + setupVBOandVAO(); + } + else { + setupVBO(); + } } else { @@ -468,7 +468,6 @@ void ParticleSystemQuad::setTotalParticles(int tp) resetSystem(); } -#if CC_TEXTURE_ATLAS_USE_VAO void ParticleSystemQuad::setupVBOandVAO() { // clean VAO @@ -508,7 +507,6 @@ void ParticleSystemQuad::setupVBOandVAO() CHECK_GL_ERROR_DEBUG(); } -#else void ParticleSystemQuad::setupVBO() { @@ -527,15 +525,14 @@ void ParticleSystemQuad::setupVBO() CHECK_GL_ERROR_DEBUG(); } -#endif - void ParticleSystemQuad::listenBackToForeground(Object *obj) { -#if CC_TEXTURE_ATLAS_USE_VAO + if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); -#else + } + else { setupVBO(); -#endif + } } bool ParticleSystemQuad::allocMemory() @@ -578,11 +575,12 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) allocMemory(); initIndices(); setTexture(oldBatch->getTexture()); -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + setupVBOandVAO(); + } + else { + setupVBO(); + } } // OLD: was it self render ? cleanup else if( !oldBatch ) @@ -597,11 +595,11 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) glDeleteBuffers(2, &_buffersVBO[0]); memset(_buffersVBO, 0, sizeof(_buffersVBO)); -#if CC_TEXTURE_ATLAS_USE_VAO - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); - _VAOname = 0; -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + glDeleteVertexArrays(1, &_VAOname); + GL::bindVAO(0); + _VAOname = 0; + } } } } diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 0106118b43..594810cf96 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -135,20 +135,15 @@ public: virtual void setTotalParticles(int tp) override; private: -#if CC_TEXTURE_ATLAS_USE_VAO void setupVBOandVAO(); -#else void setupVBO(); -#endif bool allocMemory(); protected: V3F_C4B_T2F_Quad *_quads; // quads to be rendered GLushort *_indices; // indices -#if CC_TEXTURE_ATLAS_USE_VAO GLuint _VAOname; -#endif GLuint _buffersVBO[2]; //0: vertex 1: indices }; diff --git a/cocos2dx/platform/android/CCEGLView.cpp b/cocos2dx/platform/android/CCEGLView.cpp index 384773f119..f062973e6d 100644 --- a/cocos2dx/platform/android/CCEGLView.cpp +++ b/cocos2dx/platform/android/CCEGLView.cpp @@ -33,23 +33,16 @@ THE SOFTWARE. #include - -#if CC_TEXTURE_ATLAS_USE_VAO - // exists since android 2.3 #include PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0; PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0; -#endif - void initExtensions() { -#if CC_TEXTURE_ATLAS_USE_VAO glGenVertexArraysOESEXT = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES"); glBindVertexArrayOESEXT = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); glDeleteVertexArraysOESEXT = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); -#endif } NS_CC_BEGIN diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index 0e8054bd40..71a880c984 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "CCGLProgram.h" #include "CCDirector.h" #include "ccConfig.h" +#include "CCConfiguration.h" // extern #include "kazmath/GL/matrix.h" @@ -50,9 +51,7 @@ static GLuint s_uCurrentBoundTexture[kMaxActiveTexture] = {(GLuint)-1,(GLuin static GLenum s_eBlendingSource = -1; static GLenum s_eBlendingDest = -1; static int s_eGLServerState = 0; -#if CC_TEXTURE_ATLAS_USE_VAO static GLuint s_uVAO = 0; -#endif #endif // CC_ENABLE_GL_STATE_CACHE // GL State Cache functions @@ -78,9 +77,7 @@ void invalidateStateCache( void ) s_eBlendingSource = -1; s_eBlendingDest = -1; s_eGLServerState = 0; -#if CC_TEXTURE_ATLAS_USE_VAO s_uVAO = 0; -#endif #endif // CC_ENABLE_GL_STATE_CACHE } @@ -187,19 +184,19 @@ void deleteTextureN(GLuint textureUnit, GLuint textureId) void bindVAO(GLuint vaoId) { -#if CC_TEXTURE_ATLAS_USE_VAO + if (Configuration::getInstance()->supportsShareableVAO()) { #if CC_ENABLE_GL_STATE_CACHE - if (s_uVAO != vaoId) - { - s_uVAO = vaoId; - glBindVertexArray(vaoId); - } + if (s_uVAO != vaoId) + { + s_uVAO = vaoId; + glBindVertexArray(vaoId); + } #else - glBindVertexArray(vaoId); + glBindVertexArray(vaoId); #endif // CC_ENABLE_GL_STATE_CACHE -#endif + } } //#pragma mark - GL Vertex Attrib functions diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 239294e7a3..3f45f4e75c 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -33,6 +33,7 @@ THE SOFTWARE. #include "support/CCNotificationCenter.h" #include "CCEventType.h" #include "CCGL.h" +#include "CCConfiguration.h" // support #include "CCTexture2D.h" #include "cocoa/CCString.h" @@ -60,10 +61,10 @@ TextureAtlas::~TextureAtlas() glDeleteBuffers(2, _buffersVBO); -#if CC_TEXTURE_ATLAS_USE_VAO - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + glDeleteVertexArrays(1, &_VAOname); + GL::bindVAO(0); + } CC_SAFE_RELEASE(_texture); #if CC_ENABLE_CACHE_TEXTURE_DATA @@ -190,12 +191,13 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity) this->setupIndices(); -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif - + if (Configuration::getInstance()->supportsShareableVAO()) { + setupVBOandVAO(); + } + else { + setupVBO(); + } + _dirty = true; return true; @@ -203,11 +205,12 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity) void TextureAtlas::listenBackToForeground(Object *obj) { -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) { + setupVBOandVAO(); + } + else { + setupVBO(); + } // set _dirty to true to force it rebinding buffer _dirty = true; @@ -248,7 +251,6 @@ void TextureAtlas::setupIndices() //TextureAtlas - VAO / VBO specific -#if CC_TEXTURE_ATLAS_USE_VAO void TextureAtlas::setupVBOandVAO() { glGenVertexArrays(1, &_VAOname); @@ -283,14 +285,13 @@ void TextureAtlas::setupVBOandVAO() CHECK_GL_ERROR_DEBUG(); } -#else // CC_TEXTURE_ATLAS_USE_VAO + void TextureAtlas::setupVBO() { glGenBuffers(2, &_buffersVBO[0]); mapBuffers(); } -#endif // ! // CC_TEXTURE_ATLAS_USE_VAO void TextureAtlas::mapBuffers() { @@ -603,90 +604,87 @@ void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) GL::bindTexture2D(_texture->getName()); -#if CC_TEXTURE_ATLAS_USE_VAO + if (Configuration::getInstance()->supportsShareableVAO()) { + // + // Using VBO and VAO + // - // - // Using VBO and VAO - // + // XXX: update is done in draw... perhaps it should be done in a timer + if (_dirty) + { + glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); + // option 1: subdata + //glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); + + // option 2: data + // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); + + // option 3: orphaning + glMapBuffer + glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW); + void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start)); + glUnmapBuffer(GL_ARRAY_BUFFER); + + glBindBuffer(GL_ARRAY_BUFFER, 0); - // XXX: update is done in draw... perhaps it should be done in a timer - if (_dirty) - { - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - // option 1: subdata - //glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); - - // option 2: data - // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); - - // option 3: orphaning + glMapBuffer - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW); - void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start)); - glUnmapBuffer(GL_ARRAY_BUFFER); - - glBindBuffer(GL_ARRAY_BUFFER, 0); + _dirty = false; + } - _dirty = false; - } - - GL::bindVAO(_VAOname); + GL::bindVAO(_VAOname); #if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); #endif #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); + glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); #else - glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); + glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP #if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif // glBindVertexArray(0); - -#else // ! CC_TEXTURE_ATLAS_USE_VAO - - // - // Using VBO without VAO - // + } + else { + // + // Using VBO without VAO + // #define kQuadSize sizeof(_quads[0].bl) - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); + glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - // XXX: update is done in draw... perhaps it should be done in a timer - if (_dirty) - { - glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] ); - _dirty = false; - } + // XXX: update is done in draw... perhaps it should be done in a timer + if (_dirty) + { + glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] ); + _dirty = false; + } - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - // vertices - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); + // vertices + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); - // colors - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); + // colors + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); - // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); + // tex coords + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); #if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); + glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); #else - glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); + glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); #endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - -#endif // CC_TEXTURE_ATLAS_USE_VAO + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } CC_INCREMENT_GL_DRAWS(1); CHECK_GL_ERROR_DEBUG(); diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index afed7e16dc..9e1bca0381 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -217,17 +217,12 @@ public: private: void setupIndices(); void mapBuffers(); -#if CC_TEXTURE_ATLAS_USE_VAO void setupVBOandVAO(); -#else void setupVBO(); -#endif protected: GLushort* _indices; -#if CC_TEXTURE_ATLAS_USE_VAO GLuint _VAOname; -#endif GLuint _buffersVBO[2]; //0: vertex 1: indices bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated /** quantity of quads that are going to be drawn */ From 83c99b5b1c3bdb0a779c79426c8fe109b6d8b6b9 Mon Sep 17 00:00:00 2001 From: bmanGH Date: Sun, 13 Oct 2013 14:01:56 +0800 Subject: [PATCH 126/185] fix GL_EXT_discard_framebuffer always disable in EAGLView.mm; --- cocos2dx/platform/ios/EAGLView.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index 188172e73a..9f8f4c8331 100644 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -237,8 +237,7 @@ static CCEAGLView *view = 0; context_ = [renderer_ context]; - - //discardFramebufferSupported_ = [[Configuration sharedConfiguration] supportsDiscardFramebuffer]; + discardFramebufferSupported_ = (BOOL)GL_EXT_discard_framebuffer; CHECK_GL_ERROR(); @@ -288,7 +287,7 @@ static CCEAGLView *view = 0; glResolveMultisampleFramebufferAPPLE(); } - if( discardFramebufferSupported_) + if(discardFramebufferSupported_) { if (multiSampling_) { From 408b81173de47dcac5559df80060b26974a65128 Mon Sep 17 00:00:00 2001 From: bmanGH Date: Sun, 13 Oct 2013 14:05:51 +0800 Subject: [PATCH 127/185] fix GL_EXT_discard_framebuffer always disable in EAGLView.mm (fix compile fail on early iOS SDK 4.0); --- cocos2dx/platform/ios/EAGLView.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index 9f8f4c8331..64ea03991e 100644 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -237,7 +237,11 @@ static CCEAGLView *view = 0; context_ = [renderer_ context]; - discardFramebufferSupported_ = (BOOL)GL_EXT_discard_framebuffer; +#if GL_EXT_discard_framebuffer == 1 + discardFramebufferSupported_ = YES; +#else + discardFramebufferSupported_ = NO; +#endif CHECK_GL_ERROR(); From f540131320eda32ad29974e2ea5a3ea358a54e73 Mon Sep 17 00:00:00 2001 From: bmanGH Date: Mon, 28 Oct 2013 00:58:57 +0800 Subject: [PATCH 128/185] add setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv mothed in GLProgram class. --- cocos/2d/CCGLProgram.cpp | 18 ++++++++++++++++++ cocos/2d/CCGLProgram.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 61fd7aaa66..81afbdc09f 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -515,6 +515,24 @@ void GLProgram::setUniformLocationWith4fv(GLint location, GLfloat* floats, unsig } } +void GLProgram::setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { + bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*4*numberOfMatrices); + + if( updated ) + { + glUniformMatrix2fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); + } +} + +void GLProgram::setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { + bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*9*numberOfMatrices); + + if( updated ) + { + glUniformMatrix3fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); + } +} + void GLProgram::setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index f218f7181e..c7b6b2728c 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -198,6 +198,12 @@ public: /** calls glUniform4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith4fv(GLint location, GLfloat* floats, unsigned int numberOfArrays); + /** calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. */ + void setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices); + + /** calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. */ + void setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices); + /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices); From 3b9348bfc0afe1815c615f714f9c488921312162 Mon Sep 17 00:00:00 2001 From: bmanGH Date: Tue, 12 Nov 2013 20:21:30 +0800 Subject: [PATCH 129/185] remove conflicts files; --- cocos2dx/CCConfiguration.cpp | 390 -------- cocos2dx/draw_nodes/CCDrawNode.cpp | 465 --------- .../particle_nodes/CCParticleSystemQuad.cpp | 618 ------------ cocos2dx/platform/android/CCEGLView.cpp | 92 -- cocos2dx/platform/ios/EAGLView.mm | 919 ------------------ cocos2dx/textures/CCTextureAtlas.cpp | 695 ------------- cocos2dx/textures/CCTextureAtlas.h | 245 ----- 7 files changed, 3424 deletions(-) delete mode 100644 cocos2dx/CCConfiguration.cpp delete mode 100644 cocos2dx/draw_nodes/CCDrawNode.cpp delete mode 100644 cocos2dx/particle_nodes/CCParticleSystemQuad.cpp delete mode 100644 cocos2dx/platform/android/CCEGLView.cpp delete mode 100644 cocos2dx/platform/ios/EAGLView.mm delete mode 100644 cocos2dx/textures/CCTextureAtlas.cpp delete mode 100644 cocos2dx/textures/CCTextureAtlas.h diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp deleted file mode 100644 index 75293a6f3f..0000000000 --- a/cocos2dx/CCConfiguration.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2010 Ricardo Quesada - -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 "CCConfiguration.h" -#include -#include "ccMacros.h" -#include "ccConfig.h" -#include "cocoa/CCDictionary.h" -#include "cocoa/CCInteger.h" -#include "cocoa/CCBool.h" -#include "cocos2d.h" -#include "platform/CCFileUtils.h" - -using namespace std; - -NS_CC_BEGIN - - -Configuration* Configuration::s_sharedConfiguration = nullptr; - -Configuration::Configuration() -: _maxTextureSize(0) -, _maxModelviewStackDepth(0) -, _supportsPVRTC(false) -, _supportsETC1(false) -, _supportsS3TC(false) -, _supportsATITC(false) -, _supportsNPOT(false) -, _supportsBGRA8888(false) -, _supportsDiscardFramebuffer(false) -, _supportsShareableVAO(false) -, _maxSamplesAllowed(0) -, _maxTextureUnits(0) -, _glExtensions(nullptr) -, _valueDict(nullptr) -{ -} - -bool Configuration::init() -{ - _valueDict = Dictionary::create(); - _valueDict->retain(); - - _valueDict->setObject(String::create( cocos2dVersion() ), "cocos2d.x.version"); - - -#if CC_ENABLE_PROFILERS - _valueDict->setObject(Bool::create(true), "cocos2d.x.compiled_with_profiler"); -#else - _valueDict->setObject(Bool::create(false), "cocos2d.x.compiled_with_profiler"); -#endif - -#if CC_ENABLE_GL_STATE_CACHE == 0 - _valueDict->setObject(Bool::create(false), "cocos2d.x.compiled_with_gl_state_cache"); -#else - _valueDict->setObject(Bool::create(true), "cocos2d.x.compiled_with_gl_state_cache"); -#endif - - return true; -} - -Configuration::~Configuration() -{ - _valueDict->release(); -} - -void Configuration::dumpInfo() const -{ - // Dump - PrettyPrinter visitor(0); - _valueDict->acceptVisitor(visitor); - - CCLOG("%s", visitor.getResult().c_str()); - - - // And Dump some warnings as well -#if CC_ENABLE_PROFILERS - CCLOG("cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.h)"); - printf("\n"); -#endif - -#if CC_ENABLE_GL_STATE_CACHE == 0 - CCLOG(""); - CCLOG("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it (from ccConfig.h)"); - printf("\n"); -#endif - -} - -void Configuration::gatherGPUInfo() -{ - _valueDict->setObject(String::create((const char*)glGetString(GL_VENDOR)), "gl.vendor"); - _valueDict->setObject(String::create((const char*)glGetString(GL_RENDERER)), "gl.renderer"); - _valueDict->setObject(String::create((const char*)glGetString(GL_VERSION)), "gl.version"); - - _glExtensions = (char *)glGetString(GL_EXTENSIONS); - - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize); - _valueDict->setObject(Integer::create((int)_maxTextureSize), "gl.max_texture_size"); - - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits); - _valueDict->setObject(Integer::create((int)_maxTextureUnits), "gl.max_texture_units"); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - glGetIntegerv(GL_MAX_SAMPLES_APPLE, &_maxSamplesAllowed); - _valueDict->setObject(Integer::create((int)_maxSamplesAllowed), "gl.max_samples_allowed"); -#endif - - _supportsETC1 = checkForGLExtension("GL_OES_compressed_ETC1_RGB8_texture"); - _valueDict->setObject(Bool::create(_supportsETC1), "gl.supports_ETC1"); - - _supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc"); - _valueDict->setObject(Bool::create(_supportsS3TC), "gl.supports_S3TC"); - - _supportsATITC = checkForGLExtension("GL_AMD_compressed_ATC_texture"); - _valueDict->setObject(Bool::create(_supportsATITC), "gl.supports_ATITC"); - - _supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc"); - _valueDict->setObject(Bool::create(_supportsPVRTC), "gl.supports_PVRTC"); - - _supportsNPOT = true; - _valueDict->setObject(Bool::create(_supportsNPOT), "gl.supports_NPOT"); - - _supportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888"); - _valueDict->setObject(Bool::create(_supportsBGRA8888), "gl.supports_BGRA8888"); - - _supportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer"); - _valueDict->setObject(Bool::create(_supportsDiscardFramebuffer), "gl.supports_discard_framebuffer"); - - _supportsShareableVAO = checkForGLExtension("vertex_array_object"); - _valueDict->setObject(Bool::create(_supportsShareableVAO), "gl.supports_vertex_array_object"); - - CHECK_GL_ERROR_DEBUG(); -} - -Configuration* Configuration::getInstance() -{ - if (! s_sharedConfiguration) - { - s_sharedConfiguration = new Configuration(); - s_sharedConfiguration->init(); - } - - return s_sharedConfiguration; -} - -void Configuration::destroyInstance() -{ - CC_SAFE_RELEASE_NULL(s_sharedConfiguration); -} - -// XXX: deprecated -Configuration* Configuration::sharedConfiguration() -{ - return Configuration::getInstance(); -} - -// XXX: deprecated -void Configuration::purgeConfiguration() -{ - Configuration::destroyInstance(); -} - - -bool Configuration::checkForGLExtension(const string &searchName) const -{ - bool ret = false; - const char *kSearchName = searchName.c_str(); - - if (_glExtensions && - strstr(_glExtensions, kSearchName)) - { - ret = true; - } - - return ret; -} - -// -// getters for specific variables. -// Mantained for backward compatiblity reasons only. -// -int Configuration::getMaxTextureSize() const -{ - return _maxTextureSize; -} - -int Configuration::getMaxModelviewStackDepth() const -{ - return _maxModelviewStackDepth; -} - -int Configuration::getMaxTextureUnits() const -{ - return _maxTextureUnits; -} - -bool Configuration::supportsNPOT() const -{ - return _supportsNPOT; -} - -bool Configuration::supportsPVRTC() const -{ - return _supportsPVRTC; -} - -bool Configuration::supportsETC() const -{ - //GL_ETC1_RGB8_OES is not defined in old opengl version -#ifdef GL_ETC1_RGB8_OES - return _supportsETC1; -#else - return false; -#endif -} - -bool Configuration::supportsS3TC() const -{ - return _supportsS3TC; -} - -bool Configuration::supportsATITC() const -{ - return _supportsATITC; -} - -bool Configuration::supportsBGRA8888() const -{ - return _supportsBGRA8888; -} - -bool Configuration::supportsDiscardFramebuffer() const -{ - return _supportsDiscardFramebuffer; -} - -bool Configuration::supportsShareableVAO() const -{ -#if CC_TEXTURE_ATLAS_USE_VAO - return _supportsShareableVAO; -#else - return false; -#endif -} - -// -// generic getters for properties -// -const char *Configuration::getCString(const char *key, const char *defaultValue) const -{ - Object *ret = _valueDict->objectForKey(key); - if (ret) - { - if (String *str=dynamic_cast(ret)) - return str->getCString(); - - CCASSERT(false, "Key found, but from different type"); - } - - // XXX: Should it throw an exception ? - return defaultValue; -} - -/** returns the value of a given key as a boolean */ -bool Configuration::getBool(const char *key, bool defaultValue) const -{ - Object *ret = _valueDict->objectForKey(key); - if (ret) - { - if (Bool *boolobj=dynamic_cast(ret)) - return boolobj->getValue(); - if (String *strobj=dynamic_cast(ret)) - return strobj->boolValue(); - CCASSERT(false, "Key found, but from different type"); - } - - // XXX: Should it throw an exception ? - return defaultValue; -} - -/** returns the value of a given key as a double */ -double Configuration::getNumber( const char *key, double defaultValue ) const -{ - Object *ret = _valueDict->objectForKey(key); - if( ret ) - { - if (Double *obj=dynamic_cast(ret)) - return obj->getValue(); - - if (Integer *obj=dynamic_cast(ret)) - return obj->getValue(); - - if (String *strobj=dynamic_cast(ret)) - return strobj->doubleValue(); - - CCASSERT(false, "Key found, but from different type"); - } - - // XXX: Should it throw an exception ? - return defaultValue; -} - -Object * Configuration::getObject(const char *key) const -{ - return _valueDict->objectForKey(key); -} - -void Configuration::setObject(const char *key, Object *value) -{ - _valueDict->setObject(value, key); -} - - -// -// load file -// -void Configuration::loadConfigFile(const char *filename) -{ - Dictionary *dict = Dictionary::createWithContentsOfFile(filename); - CCASSERT(dict, "cannot create dictionary"); - - // search for metadata - bool validMetadata = false; - Object *metadata = dict->objectForKey("metadata"); - if (metadata && dynamic_cast(metadata)) - { - Object *format_o = static_cast(metadata)->objectForKey("format"); - - // XXX: cocos2d-x returns Strings when importing from .plist. This bug will be addressed in cocos2d-x v3.x - if (format_o && dynamic_cast(format_o)) - { - int format = static_cast(format_o)->intValue(); - - // Support format: 1 - if (format == 1) - { - validMetadata = true; - } - } - } - - if (! validMetadata) - { - CCLOG("Invalid config format for file: %s", filename); - return; - } - - Object *data = dict->objectForKey("data"); - if (!data || !dynamic_cast(data)) - { - CCLOG("Expected 'data' dict, but not found. Config file: %s", filename); - return; - } - - // Add all keys in the existing dictionary - Dictionary *data_dict = static_cast(data); - DictElement* element; - CCDICT_FOREACH(data_dict, element) - { - if(! _valueDict->objectForKey( element->getStrKey() )) - _valueDict->setObject(element->getObject(), element->getStrKey()); - else - CCLOG("Key already present. Ignoring '%s'", element->getStrKey()); - } -} - -NS_CC_END diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp deleted file mode 100644 index 10f2b1d19e..0000000000 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software - * Copyright (c) 2012 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 "CCDrawNode.h" -#include "shaders/CCShaderCache.h" -#include "CCGL.h" -#include "support/CCNotificationCenter.h" -#include "CCEventType.h" -#include "CCConfiguration.h" - -NS_CC_BEGIN - -// Vertex2F == CGPoint in 32-bits, but not in 64-bits (OS X) -// that's why the "v2f" functions are needed -static Vertex2F v2fzero(0.0f,0.0f); - -static inline Vertex2F v2f(float x, float y) -{ - Vertex2F ret(x, y); - return ret; -} - -static inline Vertex2F v2fadd(const Vertex2F &v0, const Vertex2F &v1) -{ - return v2f(v0.x+v1.x, v0.y+v1.y); -} - -static inline Vertex2F v2fsub(const Vertex2F &v0, const Vertex2F &v1) -{ - return v2f(v0.x-v1.x, v0.y-v1.y); -} - -static inline Vertex2F v2fmult(const Vertex2F &v, float s) -{ - return v2f(v.x * s, v.y * s); -} - -static inline Vertex2F v2fperp(const Vertex2F &p0) -{ - return v2f(-p0.y, p0.x); -} - -static inline Vertex2F v2fneg(const Vertex2F &p0) -{ - return v2f(-p0.x, - p0.y); -} - -static inline float v2fdot(const Vertex2F &p0, const Vertex2F &p1) -{ - return p0.x * p1.x + p0.y * p1.y; -} - -static inline Vertex2F v2fforangle(float _a_) -{ - return v2f(cosf(_a_), sinf(_a_)); -} - -static inline Vertex2F v2fnormalize(const Vertex2F &p) -{ - Point r = Point(p.x, p.y).normalize(); - return v2f(r.x, r.y); -} - -static inline Vertex2F __v2f(const Point &v) -{ -//#ifdef __LP64__ - return v2f(v.x, v.y); -// #else -// return * ((Vertex2F*) &v); -// #endif -} - -static inline Tex2F __t(const Vertex2F &v) -{ - return *(Tex2F*)&v; -} - -// implementation of DrawNode - -DrawNode::DrawNode() -: _vao(0) -, _vbo(0) -, _bufferCapacity(0) -, _bufferCount(0) -, _buffer(NULL) -, _dirty(false) -{ - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; -} - -DrawNode::~DrawNode() -{ - free(_buffer); - _buffer = NULL; - - glDeleteBuffers(1, &_vbo); - _vbo = 0; - - if (Configuration::getInstance()->supportsShareableVAO()) { - glDeleteVertexArrays(1, &_vao); - GL::bindVAO(0); - _vao = 0; - } - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif -} - -DrawNode* DrawNode::create() -{ - DrawNode* pRet = new DrawNode(); - if (pRet && pRet->init()) - { - pRet->autorelease(); - } - else - { - CC_SAFE_DELETE(pRet); - } - - return pRet; -} - -void DrawNode::ensureCapacity(int count) -{ - CCASSERT(count>=0, "capacity must be >= 0"); - - if(_bufferCount + count > _bufferCapacity) - { - _bufferCapacity += MAX(_bufferCapacity, count); - _buffer = (V2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(V2F_C4B_T2F)); - } -} - -bool DrawNode::init() -{ - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); - - ensureCapacity(512); - - if (Configuration::getInstance()->supportsShareableVAO()) { - glGenVertexArrays(1, &_vao); - GL::bindVAO(_vao); - } - - glGenBuffers(1, &_vbo); - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); - - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - - if (Configuration::getInstance()->supportsShareableVAO()) { - GL::bindVAO(0); - } - - CHECK_GL_ERROR_DEBUG(); - - _dirty = true; - -#if CC_ENABLE_CACHE_TEXTURE_DATA - // Need to listen the event only when not use batchnode, because it will use VBO - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(DrawNode::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); -#endif - - return true; -} - -void DrawNode::render() -{ - if (_dirty) - { - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); - _dirty = false; - } - if (Configuration::getInstance()->supportsShareableVAO()) { - GL::bindVAO(_vao); - } - else { - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - glBindBuffer(GL_ARRAY_BUFFER, _vbo); - // vertex - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - - // color - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - - // texcood - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); - } - - glDrawArrays(GL_TRIANGLES, 0, _bufferCount); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - CC_INCREMENT_GL_DRAWS(1); - CHECK_GL_ERROR_DEBUG(); -} - -void DrawNode::draw() -{ - CC_NODE_DRAW_SETUP(); - GL::blendFunc(_blendFunc.src, _blendFunc.dst); - - render(); -} - -void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color) -{ - unsigned int vertex_count = 2*3; - ensureCapacity(vertex_count); - - V2F_C4B_T2F a = {Vertex2F(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) }; - V2F_C4B_T2F b = {Vertex2F(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) }; - V2F_C4B_T2F c = {Vertex2F(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) }; - V2F_C4B_T2F d = {Vertex2F(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) }; - - V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); - V2F_C4B_T2F_Triangle triangle0 = {a, b, c}; - V2F_C4B_T2F_Triangle triangle1 = {a, c, d}; - triangles[0] = triangle0; - triangles[1] = triangle1; - - _bufferCount += vertex_count; - - _dirty = true; -} - -void DrawNode::drawSegment(const Point &from, const Point &to, float radius, const Color4F &color) -{ - unsigned int vertex_count = 6*3; - ensureCapacity(vertex_count); - - Vertex2F a = __v2f(from); - Vertex2F b = __v2f(to); - - - Vertex2F n = v2fnormalize(v2fperp(v2fsub(b, a))); - Vertex2F t = v2fperp(n); - - Vertex2F nw = v2fmult(n, radius); - Vertex2F tw = v2fmult(t, radius); - Vertex2F v0 = v2fsub(b, v2fadd(nw, tw)); - Vertex2F v1 = v2fadd(b, v2fsub(nw, tw)); - Vertex2F v2 = v2fsub(b, nw); - Vertex2F v3 = v2fadd(b, nw); - Vertex2F v4 = v2fsub(a, nw); - Vertex2F v5 = v2fadd(a, nw); - Vertex2F v6 = v2fsub(a, v2fsub(nw, tw)); - Vertex2F v7 = v2fadd(a, v2fadd(nw, tw)); - - - V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); - - V2F_C4B_T2F_Triangle triangles0 = { - {v0, Color4B(color), __t(v2fneg(v2fadd(n, t)))}, - {v1, Color4B(color), __t(v2fsub(n, t))}, - {v2, Color4B(color), __t(v2fneg(n))}, - }; - triangles[0] = triangles0; - - V2F_C4B_T2F_Triangle triangles1 = { - {v3, Color4B(color), __t(n)}, - {v1, Color4B(color), __t(v2fsub(n, t))}, - {v2, Color4B(color), __t(v2fneg(n))}, - }; - triangles[1] = triangles1; - - V2F_C4B_T2F_Triangle triangles2 = { - {v3, Color4B(color), __t(n)}, - {v4, Color4B(color), __t(v2fneg(n))}, - {v2, Color4B(color), __t(v2fneg(n))}, - }; - triangles[2] = triangles2; - - V2F_C4B_T2F_Triangle triangles3 = { - {v3, Color4B(color), __t(n)}, - {v4, Color4B(color), __t(v2fneg(n))}, - {v5, Color4B(color), __t(n) }, - }; - triangles[3] = triangles3; - - V2F_C4B_T2F_Triangle triangles4 = { - {v6, Color4B(color), __t(v2fsub(t, n))}, - {v4, Color4B(color), __t(v2fneg(n)) }, - {v5, Color4B(color), __t(n)}, - }; - triangles[4] = triangles4; - - V2F_C4B_T2F_Triangle triangles5 = { - {v6, Color4B(color), __t(v2fsub(t, n))}, - {v7, Color4B(color), __t(v2fadd(n, t))}, - {v5, Color4B(color), __t(n)}, - }; - triangles[5] = triangles5; - - _bufferCount += vertex_count; - - _dirty = true; -} - -void DrawNode::drawPolygon(Point *verts, unsigned int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor) -{ - struct ExtrudeVerts {Vertex2F offset, n;}; - struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count); - memset(extrude, 0, sizeof(struct ExtrudeVerts)*count); - - for(unsigned int i = 0; i < count; i++) - { - Vertex2F v0 = __v2f(verts[(i-1+count)%count]); - Vertex2F v1 = __v2f(verts[i]); - Vertex2F v2 = __v2f(verts[(i+1)%count]); - - Vertex2F n1 = v2fnormalize(v2fperp(v2fsub(v1, v0))); - Vertex2F n2 = v2fnormalize(v2fperp(v2fsub(v2, v1))); - - Vertex2F offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0)); - struct ExtrudeVerts tmp = {offset, n2}; - extrude[i] = tmp; - } - - bool outline = (borderColor.a > 0.0 && borderWidth > 0.0); - - unsigned int triangle_count = 3*count - 2; - unsigned int vertex_count = 3*triangle_count; - ensureCapacity(vertex_count); - - V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); - V2F_C4B_T2F_Triangle *cursor = triangles; - - float inset = (outline == false ? 0.5 : 0.0); - for(unsigned int i = 0; i < count-2; i++) - { - Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset)); - Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset)); - Vertex2F v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset)); - - V2F_C4B_T2F_Triangle tmp = { - {v0, Color4B(fillColor), __t(v2fzero)}, - {v1, Color4B(fillColor), __t(v2fzero)}, - {v2, Color4B(fillColor), __t(v2fzero)}, - }; - - *cursor++ = tmp; - } - - for(unsigned int i = 0; i < count; i++) - { - int j = (i+1)%count; - Vertex2F v0 = __v2f(verts[i]); - Vertex2F v1 = __v2f(verts[j]); - - Vertex2F n0 = extrude[i].n; - - Vertex2F offset0 = extrude[i].offset; - Vertex2F offset1 = extrude[j].offset; - - if(outline) - { - Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, borderWidth)); - Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, borderWidth)); - Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, borderWidth)); - Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, borderWidth)); - - V2F_C4B_T2F_Triangle tmp1 = { - {inner0, Color4B(borderColor), __t(v2fneg(n0))}, - {inner1, Color4B(borderColor), __t(v2fneg(n0))}, - {outer1, Color4B(borderColor), __t(n0)} - }; - *cursor++ = tmp1; - - V2F_C4B_T2F_Triangle tmp2 = { - {inner0, Color4B(borderColor), __t(v2fneg(n0))}, - {outer0, Color4B(borderColor), __t(n0)}, - {outer1, Color4B(borderColor), __t(n0)} - }; - *cursor++ = tmp2; - } - else { - Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, 0.5)); - Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, 0.5)); - Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, 0.5)); - Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, 0.5)); - - V2F_C4B_T2F_Triangle tmp1 = { - {inner0, Color4B(fillColor), __t(v2fzero)}, - {inner1, Color4B(fillColor), __t(v2fzero)}, - {outer1, Color4B(fillColor), __t(n0)} - }; - *cursor++ = tmp1; - - V2F_C4B_T2F_Triangle tmp2 = { - {inner0, Color4B(fillColor), __t(v2fzero)}, - {outer0, Color4B(fillColor), __t(n0)}, - {outer1, Color4B(fillColor), __t(n0)} - }; - *cursor++ = tmp2; - } - } - - _bufferCount += vertex_count; - - _dirty = true; - - free(extrude); -} - -void DrawNode::clear() -{ - _bufferCount = 0; - _dirty = true; -} - -const BlendFunc& DrawNode::getBlendFunc() const -{ - return _blendFunc; -} - -void DrawNode::setBlendFunc(const BlendFunc &blendFunc) -{ - _blendFunc = blendFunc; -} - -/** listen the event that coming to foreground on Android - */ -void DrawNode::listenBackToForeground(Object *obj) -{ - init(); -} - -NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp deleted file mode 100644 index 2d637feb4a..0000000000 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ /dev/null @@ -1,618 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2009 Leonardo Kasperavičius -Copyright (c) 2011 Zynga 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 "CCGL.h" -#include "CCParticleSystemQuad.h" -#include "sprite_nodes/CCSpriteFrame.h" -#include "CCDirector.h" -#include "CCParticleBatchNode.h" -#include "textures/CCTextureAtlas.h" -#include "shaders/CCShaderCache.h" -#include "shaders/ccGLStateCache.h" -#include "shaders/CCGLProgram.h" -#include "support/TransformUtils.h" -#include "support/CCNotificationCenter.h" -#include "CCEventType.h" -#include "CCConfiguration.h" - -// extern -#include "kazmath/GL/matrix.h" - -NS_CC_BEGIN - -//implementation ParticleSystemQuad -// overriding the init method -bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) -{ - // base initialization - if( ParticleSystem::initWithTotalParticles(numberOfParticles) ) - { - // allocating data space - if( ! this->allocMemory() ) { - this->release(); - return false; - } - - initIndices(); - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } - - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); - -#if CC_ENABLE_CACHE_TEXTURE_DATA - // Need to listen the event only when not use batchnode, because it will use VBO - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(ParticleSystemQuad::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); -#endif - - return true; - } - return false; -} - -ParticleSystemQuad::ParticleSystemQuad() -:_quads(NULL) -,_indices(NULL) -,_VAOname(0) -{ - memset(_buffersVBO, 0, sizeof(_buffersVBO)); -} - -ParticleSystemQuad::~ParticleSystemQuad() -{ - if (NULL == _batchNode) - { - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - glDeleteBuffers(2, &_buffersVBO[0]); - if (Configuration::getInstance()->supportsShareableVAO()) { - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); - } - } - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif -} - -// implementation ParticleSystemQuad - -ParticleSystemQuad * ParticleSystemQuad::create(const char *plistFile) -{ - ParticleSystemQuad *pRet = new ParticleSystemQuad(); - if (pRet && pRet->initWithFile(plistFile)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return pRet; -} - -ParticleSystemQuad * ParticleSystemQuad::createWithTotalParticles(unsigned int numberOfParticles) { - ParticleSystemQuad *pRet = new ParticleSystemQuad(); - if (pRet && pRet->initWithTotalParticles(numberOfParticles)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return pRet; -} - - -// pointRect should be in Texture coordinates, not pixel coordinates -void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect) -{ - // convert to Tex coords - - Rect rect = Rect( - pointRect.origin.x * CC_CONTENT_SCALE_FACTOR(), - pointRect.origin.y * CC_CONTENT_SCALE_FACTOR(), - pointRect.size.width * CC_CONTENT_SCALE_FACTOR(), - pointRect.size.height * CC_CONTENT_SCALE_FACTOR()); - - GLfloat wide = (GLfloat) pointRect.size.width; - GLfloat high = (GLfloat) pointRect.size.height; - - if (_texture) - { - wide = (GLfloat)_texture->getPixelsWide(); - high = (GLfloat)_texture->getPixelsHigh(); - } - -#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - GLfloat left = (rect.origin.x*2+1) / (wide*2); - GLfloat bottom = (rect.origin.y*2+1) / (high*2); - GLfloat right = left + (rect.size.width*2-2) / (wide*2); - GLfloat top = bottom + (rect.size.height*2-2) / (high*2); -#else - GLfloat left = rect.origin.x / wide; - GLfloat bottom = rect.origin.y / high; - GLfloat right = left + rect.size.width / wide; - GLfloat top = bottom + rect.size.height / high; -#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - - // Important. Texture in cocos2d are inverted, so the Y component should be inverted - CC_SWAP( top, bottom, float); - - V3F_C4B_T2F_Quad *quads = NULL; - unsigned int start = 0, end = 0; - if (_batchNode) - { - quads = _batchNode->getTextureAtlas()->getQuads(); - start = _atlasIndex; - end = _atlasIndex + _totalParticles; - } - else - { - quads = _quads; - start = 0; - end = _totalParticles; - } - - for(unsigned int i=start; igetName() != _texture->getName() ) - { - ParticleSystem::setTexture(texture); - } - - this->initTexCoordsWithRect(rect); -} -void ParticleSystemQuad::setTexture(Texture2D* texture) -{ - const Size& s = texture->getContentSize(); - this->setTextureWithRect(texture, Rect(0, 0, s.width, s.height)); -} -void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame) -{ - CCASSERT(spriteFrame->getOffsetInPixels().equals(Point::ZERO), - "QuadParticle only supports SpriteFrames with no offsets"); - - // update texture before updating texture rect - if ( !_texture || spriteFrame->getTexture()->getName() != _texture->getName()) - { - this->setTexture(spriteFrame->getTexture()); - } -} - -void ParticleSystemQuad::initIndices() -{ - for(int i = 0; i < _totalParticles; ++i) - { - const unsigned int i6 = i*6; - const unsigned int i4 = i*4; - _indices[i6+0] = (GLushort) i4+0; - _indices[i6+1] = (GLushort) i4+1; - _indices[i6+2] = (GLushort) i4+2; - - _indices[i6+5] = (GLushort) i4+1; - _indices[i6+4] = (GLushort) i4+2; - _indices[i6+3] = (GLushort) i4+3; - } -} - -void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point& newPosition) -{ - V3F_C4B_T2F_Quad *quad; - - if (_batchNode) - { - V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads(); - quad = &(batchQuads[_atlasIndex+particle->atlasIndex]); - } - else - { - quad = &(_quads[_particleIdx]); - } - Color4B color = (_opacityModifyRGB) - ? Color4B( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) - : Color4B( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); - - quad->bl.colors = color; - quad->br.colors = color; - quad->tl.colors = color; - quad->tr.colors = color; - - // vertices - GLfloat size_2 = particle->size/2; - if (particle->rotation) - { - GLfloat x1 = -size_2; - GLfloat y1 = -size_2; - - GLfloat x2 = size_2; - GLfloat y2 = size_2; - GLfloat x = newPosition.x; - GLfloat y = newPosition.y; - - GLfloat r = (GLfloat)-CC_DEGREES_TO_RADIANS(particle->rotation); - GLfloat cr = cosf(r); - GLfloat sr = sinf(r); - GLfloat ax = x1 * cr - y1 * sr + x; - GLfloat ay = x1 * sr + y1 * cr + y; - GLfloat bx = x2 * cr - y1 * sr + x; - GLfloat by = x2 * sr + y1 * cr + y; - GLfloat cx = x2 * cr - y2 * sr + x; - GLfloat cy = x2 * sr + y2 * cr + y; - GLfloat dx = x1 * cr - y2 * sr + x; - GLfloat dy = x1 * sr + y2 * cr + y; - - // bottom-left - quad->bl.vertices.x = ax; - quad->bl.vertices.y = ay; - - // bottom-right vertex: - quad->br.vertices.x = bx; - quad->br.vertices.y = by; - - // top-left vertex: - quad->tl.vertices.x = dx; - quad->tl.vertices.y = dy; - - // top-right vertex: - quad->tr.vertices.x = cx; - quad->tr.vertices.y = cy; - } - else - { - // bottom-left vertex: - quad->bl.vertices.x = newPosition.x - size_2; - quad->bl.vertices.y = newPosition.y - size_2; - - // bottom-right vertex: - quad->br.vertices.x = newPosition.x + size_2; - quad->br.vertices.y = newPosition.y - size_2; - - // top-left vertex: - quad->tl.vertices.x = newPosition.x - size_2; - quad->tl.vertices.y = newPosition.y + size_2; - - // top-right vertex: - quad->tr.vertices.x = newPosition.x + size_2; - quad->tr.vertices.y = newPosition.y + size_2; - } -} -void ParticleSystemQuad::postStep() -{ - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - - // Option 1: Sub Data - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(_quads[0])*_totalParticles, _quads); - - // Option 2: Data - // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * particleCount, quads_, GL_DYNAMIC_DRAW); - - // Option 3: Orphaning + glMapBuffer - // glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0])*_totalParticles, NULL, GL_STREAM_DRAW); - // void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - // memcpy(buf, _quads, sizeof(_quads[0])*_totalParticles); - // glUnmapBuffer(GL_ARRAY_BUFFER); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -// overriding draw method -void ParticleSystemQuad::draw() -{ - CCASSERT(!_batchNode,"draw should not be called when added to a particleBatchNode"); - - CC_NODE_DRAW_SETUP(); - - GL::bindTexture2D( _texture->getName() ); - GL::blendFunc( _blendFunc.src, _blendFunc.dst ); - - CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); - - if (Configuration::getInstance()->supportsShareableVAO()) { - // - // Using VBO and VAO - // - GL::bindVAO(_VAOname); - -#if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); -#endif - - glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); - -#if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -#endif - } - else { - // - // Using VBO without VAO - // - - #define kQuadSize sizeof(_quads[0].bl) - - GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - // vertices - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); - // colors - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); - // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - - glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - - CC_INCREMENT_GL_DRAWS(1); - CHECK_GL_ERROR_DEBUG(); -} - -void ParticleSystemQuad::setTotalParticles(int tp) -{ - // If we are setting the total number of particles to a number higher - // than what is allocated, we need to allocate new arrays - if( tp > _allocatedParticles ) - { - // Allocate new memory - size_t particlesSize = tp * sizeof(tParticle); - size_t quadsSize = sizeof(_quads[0]) * tp * 1; - size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1; - - tParticle* particlesNew = (tParticle*)realloc(_particles, particlesSize); - V3F_C4B_T2F_Quad* quadsNew = (V3F_C4B_T2F_Quad*)realloc(_quads, quadsSize); - GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize); - - if (particlesNew && quadsNew && indicesNew) - { - // Assign pointers - _particles = particlesNew; - _quads = quadsNew; - _indices = indicesNew; - - // Clear the memory - // XXX: Bug? If the quads are cleared, then drawing doesn't work... WHY??? XXX - memset(_particles, 0, particlesSize); - memset(_quads, 0, quadsSize); - memset(_indices, 0, indicesSize); - - _allocatedParticles = tp; - } - else - { - // Out of memory, failed to resize some array - if (particlesNew) _particles = particlesNew; - if (quadsNew) _quads = quadsNew; - if (indicesNew) _indices = indicesNew; - - CCLOG("Particle system: out of memory"); - return; - } - - _totalParticles = tp; - - // Init particles - if (_batchNode) - { - for (int i = 0; i < _totalParticles; i++) - { - _particles[i].atlasIndex=i; - } - } - - initIndices(); - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } - } - else - { - _totalParticles = tp; - } - - resetSystem(); -} - -void ParticleSystemQuad::setupVBOandVAO() -{ - // clean VAO - glDeleteBuffers(2, &_buffersVBO[0]); - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); - - glGenVertexArrays(1, &_VAOname); - GL::bindVAO(_VAOname); - -#define kQuadSize sizeof(_quads[0].bl) - - glGenBuffers(2, &_buffersVBO[0]); - - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); - - // vertices - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); - - // colors - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); - - // tex coords - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); - - // Must unbind the VAO before changing the element buffer. - GL::bindVAO(0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -void ParticleSystemQuad::setupVBO() -{ - glDeleteBuffers(2, &_buffersVBO[0]); - - glGenBuffers(2, &_buffersVBO[0]); - - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -void ParticleSystemQuad::listenBackToForeground(Object *obj) -{ - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } -} - -bool ParticleSystemQuad::allocMemory() -{ - CCASSERT( ( !_quads && !_indices), "Memory already alloced"); - CCASSERT( !_batchNode, "Memory should not be alloced when not using batchNode"); - - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - - _quads = (V3F_C4B_T2F_Quad*)malloc(_totalParticles * sizeof(V3F_C4B_T2F_Quad)); - _indices = (GLushort*)malloc(_totalParticles * 6 * sizeof(GLushort)); - - if( !_quads || !_indices) - { - CCLOG("cocos2d: Particle system: not enough memory"); - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - - return false; - } - - memset(_quads, 0, _totalParticles * sizeof(V3F_C4B_T2F_Quad)); - memset(_indices, 0, _totalParticles * 6 * sizeof(GLushort)); - - return true; -} - -void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) -{ - if( _batchNode != batchNode ) - { - ParticleBatchNode* oldBatch = _batchNode; - - ParticleSystem::setBatchNode(batchNode); - - // NEW: is self render ? - if( ! batchNode ) - { - allocMemory(); - initIndices(); - setTexture(oldBatch->getTexture()); - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } - } - // OLD: was it self render ? cleanup - else if( !oldBatch ) - { - // copy current state to batch - V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads(); - V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] ); - memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) ); - - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - - glDeleteBuffers(2, &_buffersVBO[0]); - memset(_buffersVBO, 0, sizeof(_buffersVBO)); - if (Configuration::getInstance()->supportsShareableVAO()) { - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); - _VAOname = 0; - } - } - } -} - -ParticleSystemQuad * ParticleSystemQuad::create() { - ParticleSystemQuad *pParticleSystemQuad = new ParticleSystemQuad(); - if (pParticleSystemQuad && pParticleSystemQuad->init()) - { - pParticleSystemQuad->autorelease(); - return pParticleSystemQuad; - } - CC_SAFE_DELETE(pParticleSystemQuad); - return NULL; -} - -NS_CC_END diff --git a/cocos2dx/platform/android/CCEGLView.cpp b/cocos2dx/platform/android/CCEGLView.cpp deleted file mode 100644 index f062973e6d..0000000000 --- a/cocos2dx/platform/android/CCEGLView.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "CCEGLView.h" -#include "cocoa/CCSet.h" -#include "CCDirector.h" -#include "ccMacros.h" -#include "jni/IMEJni.h" -#include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" -#include "CCGL.h" - -#include -#include - - -// exists since android 2.3 -#include -PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; -PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0; -PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0; - -void initExtensions() { - glGenVertexArraysOESEXT = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES"); - glBindVertexArrayOESEXT = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES"); - glDeleteVertexArraysOESEXT = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES"); -} - -NS_CC_BEGIN - -EGLView::EGLView() -{ - initExtensions(); -} - -EGLView::~EGLView() -{ - -} - -bool EGLView::isOpenGLReady() -{ - return (_screenSize.width != 0 && _screenSize.height != 0); -} - -void EGLView::end() -{ - terminateProcessJNI(); -} - -void EGLView::swapBuffers() -{ -} - -EGLView* EGLView::getInstance() -{ - static EGLView instance; - return &instance; -} - -// XXX: deprecated -EGLView* EGLView::sharedOpenGLView() -{ - return EGLView::getInstance(); -} - -void EGLView::setIMEKeyboardState(bool bOpen) -{ - setKeyboardStateJNI((int)bOpen); -} - -NS_CC_END - diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm deleted file mode 100644 index 64ea03991e..0000000000 --- a/cocos2dx/platform/ios/EAGLView.mm +++ /dev/null @@ -1,919 +0,0 @@ -/* - -===== IMPORTANT ===== - -This is sample code demonstrating API, technology or techniques in development. -Although this sample code has been reviewed for technical accuracy, it is not -final. Apple is supplying this information to help you plan for the adoption of -the technologies and programming interfaces described herein. This information -is subject to change, and software implemented based on this sample code should -be tested with final operating system software and final documentation. Newer -versions of this sample code may be provided with future seeds of the API or -technology. For information about updates to this and other developer -documentation, view the New & Updated sidebars in subsequent documentation -seeds. - -===================== - -File: EAGLView.m -Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a -UIView subclass. - -Version: 1.3 - -Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. -("Apple") in consideration of your agreement to the following terms, and your -use, installation, modification or redistribution of this Apple software -constitutes acceptance of these terms. If you do not agree with these terms, -please do not use, install, modify or redistribute this Apple software. - -In consideration of your agreement to abide by the following terms, and subject -to these terms, Apple grants you a personal, non-exclusive license, under -Apple's copyrights in this original Apple software (the "Apple Software"), to -use, reproduce, modify and redistribute the Apple Software, with or without -modifications, in source and/or binary forms; provided that if you redistribute -the Apple Software in its entirety and without modifications, you must retain -this notice and the following text and disclaimers in all such redistributions -of the Apple Software. -Neither the name, trademarks, service marks or logos of Apple Inc. may be used -to endorse or promote products derived from the Apple Software without specific -prior written permission from Apple. Except as expressly stated in this notice, -no other rights or licenses, express or implied, are granted by Apple herein, -including but not limited to any patent rights that may be infringed by your -derivative works or by other works in which the Apple Software may be -incorporated. - -The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED -WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN -COMBINATION WITH YOUR PRODUCTS. - -IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR -DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF -CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Copyright (C) 2008 Apple Inc. All Rights Reserved. - -*/ - -#import -#import "CCEGLView.h" -#import "EAGLView.h" -#import "CCES2Renderer.h" -#import "CCDirector.h" -#import "CCSet.h" -#import "CCTouch.h" -#import "CCIMEDispatcher.h" -#import "OpenGL_Internal.h" -#import "CCEGLView.h" -//CLASS IMPLEMENTATIONS: - -#define IOS_MAX_TOUCHES_COUNT 10 - -static CCEAGLView *view = 0; - -@interface CCEAGLView (Private) -- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup; -- (unsigned int) convertPixelFormat:(NSString*) pixelFormat; -@end - -@implementation CCEAGLView - -@synthesize surfaceSize=size_; -@synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_; -@synthesize context=context_; -@synthesize multiSampling=multiSampling_; -@synthesize isKeyboardShown=isKeyboardShown_; -@synthesize keyboardShowNotification = keyboardShowNotification_; -+ (Class) layerClass -{ - return [CAEAGLLayer class]; -} - -+ (id) viewWithFrame:(CGRect)frame -{ - return [[[self alloc] initWithFrame:frame] autorelease]; -} - -+ (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format -{ - return [[[self alloc]initWithFrame:frame pixelFormat:format] autorelease]; -} - -+ (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth -{ - return [[[self alloc] initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0] autorelease]; -} - -+ (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples -{ - return [[[self alloc]initWithFrame:frame pixelFormat:format depthFormat:depth preserveBackbuffer:retained sharegroup:sharegroup multiSampling:multisampling numberOfSamples:samples] autorelease]; -} - -+ (id) sharedEGLView -{ - return view; -} - -- (id) initWithFrame:(CGRect)frame -{ - return [self initWithFrame:frame pixelFormat:kEAGLColorFormatRGB565 depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; -} - -- (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format -{ - return [self initWithFrame:frame pixelFormat:format depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; -} - -- (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples; -{ - if((self = [super initWithFrame:frame])) - { - isUseUITextField = YES; - pixelformat_ = format; - depthFormat_ = depth; - multiSampling_ = sampling; - requestedSamples_ = nSamples; - preserveBackbuffer_ = retained; - markedText_ = nil; - if( ! [self setupSurfaceWithSharegroup:sharegroup] ) { - [self release]; - return nil; - } - - - view = self; - - originalRect_ = self.frame; - self.keyboardShowNotification = nil; - - if ([view respondsToSelector:@selector(setContentScaleFactor:)]) - { - view.contentScaleFactor = [[UIScreen mainScreen] scale]; - } - } - - return self; -} - --(id) initWithCoder:(NSCoder *)aDecoder -{ - if( (self = [super initWithCoder:aDecoder]) ) { - - CAEAGLLayer* eaglLayer = (CAEAGLLayer*)[self layer]; - - pixelformat_ = kEAGLColorFormatRGB565; - depthFormat_ = 0; // GL_DEPTH_COMPONENT24_OES; - multiSampling_= NO; - requestedSamples_ = 0; - size_ = [eaglLayer bounds].size; - markedText_ = nil; - - if( ! [self setupSurfaceWithSharegroup:nil] ) { - [self release]; - return nil; - } - } - - view = self; - return self; -} - -- (void)didMoveToWindow; -{ - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardWillShowNotification object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardDidShowNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardWillHideNotification object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(onUIKeyboardNotification:) - name:UIKeyboardDidHideNotification object:nil]; -} - --(int) getWidth -{ - CGSize bound = [self bounds].size; - return bound.width * self.contentScaleFactor; -} - --(int) getHeight -{ - CGSize bound = [self bounds].size; - return bound.height * self.contentScaleFactor; -} - - --(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup -{ - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:preserveBackbuffer_], kEAGLDrawablePropertyRetainedBacking, - pixelformat_, kEAGLDrawablePropertyColorFormat, nil]; - - - renderer_ = [[CCES2Renderer alloc] initWithDepthFormat:depthFormat_ - withPixelFormat:[self convertPixelFormat:pixelformat_] - withSharegroup:sharegroup - withMultiSampling:multiSampling_ - withNumberOfSamples:requestedSamples_]; - - NSAssert(renderer_, @"OpenGL ES 2.O is required."); - if (!renderer_) - return NO; - - context_ = [renderer_ context]; - -#if GL_EXT_discard_framebuffer == 1 - discardFramebufferSupported_ = YES; -#else - discardFramebufferSupported_ = NO; -#endif - - CHECK_GL_ERROR(); - - return YES; -} - -- (void) dealloc -{ - [renderer_ release]; - self.keyboardShowNotification = NULL; // implicit release - [super dealloc]; -} - -- (void) layoutSubviews -{ - [renderer_ resizeFromLayer:(CAEAGLLayer*)self.layer]; - size_ = [renderer_ backingSize]; - - // Issue #914 #924 -// Director *director = [Director sharedDirector]; -// [director reshapeProjection:size_]; - cocos2d::Size size; - size.width = size_.width; - size.height = size_.height; - //cocos2d::Director::getInstance()->reshapeProjection(size); - - // Avoid flicker. Issue #350 - //[director performSelectorOnMainThread:@selector(drawScene) withObject:nil waitUntilDone:YES]; - cocos2d::Director::getInstance()->drawScene(); -} - -- (void) swapBuffers -{ - // IMPORTANT: - // - preconditions - // -> context_ MUST be the OpenGL context - // -> renderbuffer_ must be the the RENDER BUFFER - -#ifdef __IPHONE_4_0 - - if (multiSampling_) - { - /* Resolve from msaaFramebuffer to resolveFramebuffer */ - //glDisable(GL_SCISSOR_TEST); - glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, [renderer_ msaaFrameBuffer]); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, [renderer_ defaultFrameBuffer]); - glResolveMultisampleFramebufferAPPLE(); - } - - if(discardFramebufferSupported_) - { - if (multiSampling_) - { - if (depthFormat_) - { - GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT}; - glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 2, attachments); - } - else - { - GLenum attachments[] = {GL_COLOR_ATTACHMENT0}; - glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments); - } - - glBindRenderbuffer(GL_RENDERBUFFER, [renderer_ colorRenderBuffer]); - - } - - // not MSAA - else if (depthFormat_ ) { - GLenum attachments[] = { GL_DEPTH_ATTACHMENT}; - glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments); - } - } - -#endif // __IPHONE_4_0 - - if(![context_ presentRenderbuffer:GL_RENDERBUFFER]) - { -// CCLOG(@"cocos2d: Failed to swap renderbuffer in %s\n", __FUNCTION__); - } - -#if COCOS2D_DEBUG - CHECK_GL_ERROR(); -#endif - - // We can safely re-bind the framebuffer here, since this will be the - // 1st instruction of the new main loop - if( multiSampling_ ) - glBindFramebuffer(GL_FRAMEBUFFER, [renderer_ msaaFrameBuffer]); -} - -- (unsigned int) convertPixelFormat:(NSString*) pixelFormat -{ - // define the pixel format - GLenum pFormat; - - - if([pixelFormat isEqualToString:@"EAGLColorFormat565"]) - pFormat = GL_RGB565; - else - pFormat = GL_RGBA8_OES; - - return pFormat; -} - -#pragma mark CCEAGLView - Point conversion - -- (CGPoint) convertPointFromViewToSurface:(CGPoint)point -{ - CGRect bounds = [self bounds]; - - CGPoint ret; - ret.x = (point.x - bounds.origin.x) / bounds.size.width * size_.width; - ret.y = (point.y - bounds.origin.y) / bounds.size.height * size_.height; - - return ret; -} - -- (CGRect) convertRectFromViewToSurface:(CGRect)rect -{ - CGRect bounds = [self bounds]; - - CGRect ret; - ret.origin.x = (rect.origin.x - bounds.origin.x) / bounds.size.width * size_.width; - ret.origin.y = (rect.origin.y - bounds.origin.y) / bounds.size.height * size_.height; - ret.size.width = rect.size.width / bounds.size.width * size_.width; - ret.size.height = rect.size.height / bounds.size.height * size_.height; - - return ret; -} - - --(void) handleTouchesAfterKeyboardShow -{ - NSArray *subviews = self.subviews; - - for(UIView* view in subviews) - { - if([view isKindOfClass:NSClassFromString(@"CustomUITextField")]) - { - if ([view isFirstResponder]) - { - [view resignFirstResponder]; - return; - } - } - } -} - -// Pass the touches to the superview -#pragma mark CCEAGLView - Touch Delegate -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - if (isKeyboardShown_) - { - [self handleTouchesAfterKeyboardShow]; - return; - } - - int ids[IOS_MAX_TOUCHES_COUNT] = {0}; - float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - - int i = 0; - for (UITouch *touch in touches) { - ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; - ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; - ++i; - } - cocos2d::EGLView::getInstance()->handleTouchesBegin(i, ids, xs, ys); -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - if (isKeyboardShown_) - { - return; - } - int ids[IOS_MAX_TOUCHES_COUNT] = {0}; - float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - - int i = 0; - for (UITouch *touch in touches) { - ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; - ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; - ++i; - } - cocos2d::EGLView::getInstance()->handleTouchesMove(i, ids, xs, ys); -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - if (isKeyboardShown_) - { - return; - } - - int ids[IOS_MAX_TOUCHES_COUNT] = {0}; - float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - - int i = 0; - for (UITouch *touch in touches) { - ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; - ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; - ++i; - } - cocos2d::EGLView::getInstance()->handleTouchesEnd(i, ids, xs, ys); -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - if (isKeyboardShown_) - { - return; - } - - int ids[IOS_MAX_TOUCHES_COUNT] = {0}; - float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f}; - - int i = 0; - for (UITouch *touch in touches) { - ids[i] = (int)touch; - xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;; - ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;; - ++i; - } - cocos2d::EGLView::getInstance()->handleTouchesCancel(i, ids, xs, ys); -} - -#pragma mark - -#pragma mark UIView - Responder - -- (BOOL)canBecomeFirstResponder -{ - if (nil != markedText_) { - [markedText_ release]; - } - markedText_ = nil; - if (isUseUITextField) - { - return NO; - } - return YES; -} - -- (BOOL)becomeFirstResponder -{ - isUseUITextField = NO; - return [super becomeFirstResponder]; -} - -- (BOOL)resignFirstResponder -{ - isUseUITextField = YES; - return [super resignFirstResponder]; -} - -#pragma mark - -#pragma mark UIKeyInput protocol - - -- (BOOL)hasText -{ - return NO; -} - -- (void)insertText:(NSString *)text -{ - if (nil != markedText_) { - [markedText_ release]; - markedText_ = nil; - } - const char * pszText = [text cStringUsingEncoding:NSUTF8StringEncoding]; - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); -} - -- (void)deleteBackward -{ - if (nil != markedText_) { - [markedText_ release]; - markedText_ = nil; - } - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); -} - -#pragma mark - -#pragma mark UITextInputTrait protocol - --(UITextAutocapitalizationType) autocapitalizationType -{ - return UITextAutocapitalizationTypeNone; -} - -#pragma mark - -#pragma mark UITextInput protocol - -#pragma mark UITextInput - properties - -@synthesize beginningOfDocument; -@synthesize endOfDocument; -@synthesize inputDelegate; -@synthesize markedTextRange; -@synthesize markedTextStyle; -// @synthesize selectedTextRange; // must implement -@synthesize tokenizer; - -/* Text may have a selection, either zero-length (a caret) or ranged. Editing operations are - * always performed on the text from this selection. nil corresponds to no selection. */ -- (void)setSelectedTextRange:(UITextRange *)aSelectedTextRange; -{ - CCLOG("UITextRange:setSelectedTextRange"); -} -- (UITextRange *)selectedTextRange; -{ - return [[[UITextRange alloc] init] autorelease]; -} - -#pragma mark UITextInput - Replacing and Returning Text - -- (NSString *)textInRange:(UITextRange *)range; -{ - CCLOG("textInRange"); - return @""; -} -- (void)replaceRange:(UITextRange *)range withText:(NSString *)theText; -{ - CCLOG("replaceRange"); -} - -#pragma mark UITextInput - Working with Marked and Selected Text - - - -/* If text can be selected, it can be marked. Marked text represents provisionally - * inserted text that has yet to be confirmed by the user. It requires unique visual - * treatment in its display. If there is any marked text, the selection, whether a - * caret or an extended range, always resides within. - * - * Setting marked text either replaces the existing marked text or, if none is present, - * inserts it from the current selection. */ - -- (void)setMarkedTextRange:(UITextRange *)markedTextRange; -{ - CCLOG("setMarkedTextRange"); -} - -- (UITextRange *)markedTextRange; -{ - CCLOG("markedTextRange"); - return nil; // Nil if no marked text. -} -- (void)setMarkedTextStyle:(NSDictionary *)markedTextStyle; -{ - CCLOG("setMarkedTextStyle"); - -} -- (NSDictionary *)markedTextStyle; -{ - CCLOG("markedTextStyle"); - return nil; -} -- (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange; -{ - CCLOG("setMarkedText"); - if (markedText == markedText_) { - return; - } - if (nil != markedText_) { - [markedText_ release]; - } - markedText_ = markedText; - [markedText_ retain]; -} -- (void)unmarkText; -{ - CCLOG("unmarkText"); - if (nil == markedText_) - { - return; - } - const char * pszText = [markedText_ cStringUsingEncoding:NSUTF8StringEncoding]; - cocos2d::IMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText)); - [markedText_ release]; - markedText_ = nil; -} - -#pragma mark Methods for creating ranges and positions. - -- (UITextRange *)textRangeFromPosition:(UITextPosition *)fromPosition toPosition:(UITextPosition *)toPosition; -{ - CCLOG("textRangeFromPosition"); - return nil; -} -- (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset; -{ - CCLOG("positionFromPosition"); - return nil; -} -- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset; -{ - CCLOG("positionFromPosition"); - return nil; -} - -/* Simple evaluation of positions */ -- (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other; -{ - CCLOG("comparePosition"); - return (NSComparisonResult)0; -} -- (NSInteger)offsetFromPosition:(UITextPosition *)from toPosition:(UITextPosition *)toPosition; -{ - CCLOG("offsetFromPosition"); - return 0; -} - -- (UITextPosition *)positionWithinRange:(UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction; -{ - CCLOG("positionWithinRange"); - return nil; -} -- (UITextRange *)characterRangeByExtendingPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction; -{ - CCLOG("characterRangeByExtendingPosition"); - return nil; -} - -#pragma mark Writing direction - -- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction; -{ - CCLOG("baseWritingDirectionForPosition"); - return UITextWritingDirectionNatural; -} -- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection forRange:(UITextRange *)range; -{ - CCLOG("setBaseWritingDirection"); -} - -#pragma mark Geometry - -/* Geometry used to provide, for example, a correction rect. */ -- (CGRect)firstRectForRange:(UITextRange *)range; -{ - CCLOG("firstRectForRange"); - return CGRectNull; -} -- (CGRect)caretRectForPosition:(UITextPosition *)position; -{ - CCLOG("caretRectForPosition"); - return caretRect_; -} - -#pragma mark Hit testing - -/* JS - Find the closest position to a given point */ -- (UITextPosition *)closestPositionToPoint:(CGPoint)point; -{ - CCLOG("closestPositionToPoint"); - return nil; -} -- (UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange *)range; -{ - CCLOG("closestPositionToPoint"); - return nil; -} -- (UITextRange *)characterRangeAtPoint:(CGPoint)point; -{ - CCLOG("characterRangeAtPoint"); - return nil; -} - -- (NSArray *)selectionRectsForRange:(UITextRange *)range -{ - CCLOG("selectionRectsForRange"); - return nil; -} - -#pragma mark - -#pragma mark UIKeyboard notification - -- (void)onUIKeyboardNotification:(NSNotification *)notif; -{ - NSString * type = notif.name; - - NSDictionary* info = [notif userInfo]; - CGRect begin = [self convertRect: - [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue] - fromView:self]; - CGRect end = [self convertRect: - [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue] - fromView:self]; - double aniDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; - - CGSize viewSize = self.frame.size; - CGFloat tmp; - - switch ([[UIApplication sharedApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - begin.origin.y = viewSize.height - begin.origin.y - begin.size.height; - end.origin.y = viewSize.height - end.origin.y - end.size.height; - break; - - case UIInterfaceOrientationPortraitUpsideDown: - begin.origin.x = viewSize.width - (begin.origin.x + begin.size.width); - end.origin.x = viewSize.width - (end.origin.x + end.size.width); - break; - - case UIInterfaceOrientationLandscapeLeft: - tmp = begin.size.width; - begin.size.width = begin.size.height; - begin.size.height = tmp; - tmp = end.size.width; - end.size.width = end.size.height; - end.size.height = tmp; - tmp = viewSize.width; - viewSize.width = viewSize.height; - viewSize.height = tmp; - - tmp = begin.origin.x; - begin.origin.x = begin.origin.y; - begin.origin.y = viewSize.height - tmp - begin.size.height; - tmp = end.origin.x; - end.origin.x = end.origin.y; - end.origin.y = viewSize.height - tmp - end.size.height; - break; - - case UIInterfaceOrientationLandscapeRight: - tmp = begin.size.width; - begin.size.width = begin.size.height; - begin.size.height = tmp; - tmp = end.size.width; - end.size.width = end.size.height; - end.size.height = tmp; - tmp = viewSize.width; - viewSize.width = viewSize.height; - viewSize.height = tmp; - - tmp = begin.origin.x; - begin.origin.x = begin.origin.y; - begin.origin.y = tmp; - tmp = end.origin.x; - end.origin.x = end.origin.y; - end.origin.y = tmp; - break; - - default: - break; - } - - float scaleX = cocos2d::EGLView::getInstance()->getScaleX(); - float scaleY = cocos2d::EGLView::getInstance()->getScaleY(); - - - if (self.contentScaleFactor == 2.0f) - { - // Convert to pixel coordinate - - begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); - end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 2.0f, 2.0f)); - } - - float offestY = cocos2d::EGLView::getInstance()->getViewPortRect().origin.y; - CCLOG("offestY = %f", offestY); - if (offestY < 0.0f) - { - begin.origin.y += offestY; - begin.size.height -= offestY; - end.size.height -= offestY; - } - - // Convert to desigin coordinate - begin = CGRectApplyAffineTransform(begin, CGAffineTransformScale(CGAffineTransformIdentity, 1.0f/scaleX, 1.0f/scaleY)); - end = CGRectApplyAffineTransform(end, CGAffineTransformScale(CGAffineTransformIdentity, 1.0f/scaleX, 1.0f/scaleY)); - - - cocos2d::IMEKeyboardNotificationInfo notiInfo; - notiInfo.begin = cocos2d::Rect(begin.origin.x, - begin.origin.y, - begin.size.width, - begin.size.height); - notiInfo.end = cocos2d::Rect(end.origin.x, - end.origin.y, - end.size.width, - end.size.height); - notiInfo.duration = (float)aniDuration; - - cocos2d::IMEDispatcher* dispatcher = cocos2d::IMEDispatcher::sharedDispatcher(); - if (UIKeyboardWillShowNotification == type) - { - self.keyboardShowNotification = notif; // implicit copy - dispatcher->dispatchKeyboardWillShow(notiInfo); - } - else if (UIKeyboardDidShowNotification == type) - { - //CGSize screenSize = self.window.screen.bounds.size; - dispatcher->dispatchKeyboardDidShow(notiInfo); - caretRect_ = end; - caretRect_.origin.y = viewSize.height - (caretRect_.origin.y + caretRect_.size.height + [UIFont smallSystemFontSize]); - caretRect_.size.height = 0; - isKeyboardShown_ = YES; - } - else if (UIKeyboardWillHideNotification == type) - { - dispatcher->dispatchKeyboardWillHide(notiInfo); - } - else if (UIKeyboardDidHideNotification == type) - { - caretRect_ = CGRectZero; - dispatcher->dispatchKeyboardDidHide(notiInfo); - isKeyboardShown_ = NO; - } -} - --(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis -{ - [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDelegate:self]; - [UIView setAnimationDuration:duration]; - [UIView setAnimationBeginsFromCurrentState:YES]; - - //NSLog(@"[animation] dis = %f, scale = %f \n", dis, cocos2d::EGLView::getInstance()->getScaleY()); - - if (dis < 0.0f) dis = 0.0f; - - dis *= cocos2d::EGLView::getInstance()->getScaleY(); - - if (self.contentScaleFactor == 2.0f) - { - dis /= 2.0f; - } - - switch ([[UIApplication sharedApplication] statusBarOrientation]) - { - case UIInterfaceOrientationPortrait: - self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationPortraitUpsideDown: - self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationLandscapeLeft: - self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); - break; - - case UIInterfaceOrientationLandscapeRight: - self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); - break; - - default: - break; - } - - [UIView commitAnimations]; -} - - --(void) doAnimationWhenAnotherEditBeClicked -{ - if (self.keyboardShowNotification != nil) - { - [[NSNotificationCenter defaultCenter]postNotification:self.keyboardShowNotification]; - } -} - -@end diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp deleted file mode 100644 index 3f45f4e75c..0000000000 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga 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. -****************************************************************************/ - -// cocos2d -#include "CCTextureAtlas.h" -#include "CCTextureCache.h" -#include "ccMacros.h" -#include "shaders/CCGLProgram.h" -#include "shaders/ccGLStateCache.h" -#include "support/CCNotificationCenter.h" -#include "CCEventType.h" -#include "CCGL.h" -#include "CCConfiguration.h" -// support -#include "CCTexture2D.h" -#include "cocoa/CCString.h" -#include - -//According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong - -// implementation TextureAtlas - -NS_CC_BEGIN - -TextureAtlas::TextureAtlas() - :_indices(NULL) - ,_dirty(false) - ,_texture(NULL) - ,_quads(NULL) -{} - -TextureAtlas::~TextureAtlas() -{ - CCLOGINFO("deallocing TextureAtlas: %p", this); - - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - - glDeleteBuffers(2, _buffersVBO); - - if (Configuration::getInstance()->supportsShareableVAO()) { - glDeleteVertexArrays(1, &_VAOname); - GL::bindVAO(0); - } - CC_SAFE_RELEASE(_texture); - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif -} - -int TextureAtlas::getTotalQuads() const -{ - return _totalQuads; -} - -int TextureAtlas::getCapacity() const -{ - return _capacity; -} - -Texture2D* TextureAtlas::getTexture() const -{ - return _texture; -} - -void TextureAtlas::setTexture(Texture2D * var) -{ - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(_texture); - _texture = var; -} - -V3F_C4B_T2F_Quad* TextureAtlas::getQuads() -{ - //if someone accesses the quads directly, presume that changes will be made - _dirty = true; - return _quads; -} - -void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads) -{ - _quads = quads; -} - -// TextureAtlas - alloc & init - -TextureAtlas * TextureAtlas::create(const char* file, int capacity) -{ - TextureAtlas * textureAtlas = new TextureAtlas(); - if(textureAtlas && textureAtlas->initWithFile(file, capacity)) - { - textureAtlas->autorelease(); - return textureAtlas; - } - CC_SAFE_DELETE(textureAtlas); - return NULL; -} - -TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity) -{ - TextureAtlas * textureAtlas = new TextureAtlas(); - if (textureAtlas && textureAtlas->initWithTexture(texture, capacity)) - { - textureAtlas->autorelease(); - return textureAtlas; - } - CC_SAFE_DELETE(textureAtlas); - return NULL; -} - -bool TextureAtlas::initWithFile(const char * file, int capacity) -{ - // retained in property - Texture2D *texture = TextureCache::getInstance()->addImage(file); - - if (texture) - { - return initWithTexture(texture, capacity); - } - else - { - CCLOG("cocos2d: Could not open file: %s", file); - return false; - } -} - -bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity) -{ - CCASSERT(capacity>=0, "Capacity must be >= 0"); - -// CCASSERT(texture != NULL, "texture should not be null"); - _capacity = capacity; - _totalQuads = 0; - - // retained in property - this->_texture = texture; - CC_SAFE_RETAIN(_texture); - - // Re-initialization is not allowed - CCASSERT(_quads == NULL && _indices == NULL, ""); - - _quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) ); - _indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) ); - - if( ! ( _quads && _indices) && _capacity > 0) - { - //CCLOG("cocos2d: TextureAtlas: not enough memory"); - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - - // release texture, should set it to null, because the destruction will - // release it too. see cocos2d-x issue #484 - CC_SAFE_RELEASE_NULL(_texture); - return false; - } - - memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) ); - memset( _indices, 0, _capacity * 6 * sizeof(GLushort) ); - -#if CC_ENABLE_CACHE_TEXTURE_DATA - // listen the event when app go to background - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(TextureAtlas::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); -#endif - - this->setupIndices(); - - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } - - _dirty = true; - - return true; -} - -void TextureAtlas::listenBackToForeground(Object *obj) -{ - if (Configuration::getInstance()->supportsShareableVAO()) { - setupVBOandVAO(); - } - else { - setupVBO(); - } - - // set _dirty to true to force it rebinding buffer - _dirty = true; -} - -const char* TextureAtlas::description() const -{ - return String::createWithFormat("", _totalQuads)->getCString(); -} - - -void TextureAtlas::setupIndices() -{ - if (_capacity == 0) - return; - - for( int i=0; i < _capacity; i++) - { -#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - _indices[i*6+0] = i*4+0; - _indices[i*6+1] = i*4+0; - _indices[i*6+2] = i*4+2; - _indices[i*6+3] = i*4+1; - _indices[i*6+4] = i*4+3; - _indices[i*6+5] = i*4+3; -#else - _indices[i*6+0] = i*4+0; - _indices[i*6+1] = i*4+1; - _indices[i*6+2] = i*4+2; - - // inverted index. issue #179 - _indices[i*6+3] = i*4+3; - _indices[i*6+4] = i*4+2; - _indices[i*6+5] = i*4+1; -#endif - } -} - -//TextureAtlas - VAO / VBO specific - -void TextureAtlas::setupVBOandVAO() -{ - glGenVertexArrays(1, &_VAOname); - GL::bindVAO(_VAOname); - -#define kQuadSize sizeof(_quads[0].bl) - - glGenBuffers(2, &_buffersVBO[0]); - - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); - - // vertices - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); - - // colors - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); - - // tex coords - glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); - - // Must unbind the VAO before changing the element buffer. - GL::bindVAO(0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -void TextureAtlas::setupVBO() -{ - glGenBuffers(2, &_buffersVBO[0]); - - mapBuffers(); -} - -void TextureAtlas::mapBuffers() -{ - // Avoid changing the element buffer for whatever VAO might be bound. - GL::bindVAO(0); - - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - CHECK_GL_ERROR_DEBUG(); -} - -// TextureAtlas - Update, Insert, Move & Remove - -void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index) -{ - CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index"); - - _totalQuads = MAX( index+1, _totalQuads); - - _quads[index] = *quad; - - - _dirty = true; - -} - -void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index) -{ - CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index"); - - _totalQuads++; - CCASSERT( _totalQuads <= _capacity, "invalid totalQuads"); - - // issue #575. index can be > totalQuads - unsigned int remaining = (_totalQuads-1) - index; - - // last object doesn't need to be moved - if( remaining > 0) - { - // texture coordinates - memmove( &_quads[index+1],&_quads[index], sizeof(_quads[0]) * remaining ); - } - - _quads[index] = *quad; - - - _dirty = true; - -} - -void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount) -{ - CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount"); - - _totalQuads += amount; - - CCASSERT( _totalQuads <= _capacity, "invalid totalQuads"); - - // issue #575. index can be > totalQuads - int remaining = (_totalQuads-1) - index - amount; - - // last object doesn't need to be moved - if( remaining > 0) - { - // tex coordinates - memmove( &_quads[index+amount],&_quads[index], sizeof(_quads[0]) * remaining ); - } - - - int max = index + amount; - int j = 0; - for (int i = index; i < max ; i++) - { - _quads[index] = quads[j]; - index++; - j++; - } - - _dirty = true; -} - -void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex) -{ - CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); - CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); - - if( oldIndex == newIndex ) - { - return; - } - // because it is ambiguous in iphone, so we implement abs ourselves - // unsigned int howMany = abs( oldIndex - newIndex); - int howMany = (oldIndex - newIndex) > 0 ? (oldIndex - newIndex) : (newIndex - oldIndex); - int dst = oldIndex; - int src = oldIndex + 1; - if( oldIndex > newIndex) - { - dst = newIndex+1; - src = newIndex; - } - - // texture coordinates - V3F_C4B_T2F_Quad quadsBackup = _quads[oldIndex]; - memmove( &_quads[dst],&_quads[src], sizeof(_quads[0]) * howMany ); - _quads[newIndex] = quadsBackup; - - - _dirty = true; -} - -void TextureAtlas::removeQuadAtIndex(int index) -{ - CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index"); - - int remaining = (_totalQuads-1) - index; - - // last object doesn't need to be moved - if( remaining ) - { - // texture coordinates - memmove( &_quads[index],&_quads[index+1], sizeof(_quads[0]) * remaining ); - } - - _totalQuads--; - - - _dirty = true; -} - -void TextureAtlas::removeQuadsAtIndex(int index, int amount) -{ - CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds"); - - int remaining = (_totalQuads) - (index + amount); - - _totalQuads -= amount; - - if ( remaining ) - { - memmove( &_quads[index], &_quads[index+amount], sizeof(_quads[0]) * remaining ); - } - - _dirty = true; -} - -void TextureAtlas::removeAllQuads() -{ - _totalQuads = 0; -} - -// TextureAtlas - Resize -bool TextureAtlas::resizeCapacity(int newCapacity) -{ - CCASSERT(newCapacity>=0, "capacity >= 0"); - if( newCapacity == _capacity ) - { - return true; - } - int oldCapactiy = _capacity; - // update capacity and totolQuads - _totalQuads = MIN(_totalQuads, newCapacity); - _capacity = newCapacity; - - V3F_C4B_T2F_Quad* tmpQuads = NULL; - GLushort* tmpIndices = NULL; - - // when calling initWithTexture(fileName, 0) on bada device, calloc(0, 1) will fail and return NULL, - // so here must judge whether _quads and _indices is NULL. - if (_quads == NULL) - { - tmpQuads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(_quads[0]) ); - if (tmpQuads != NULL) - { - memset(tmpQuads, 0, _capacity * sizeof(_quads[0]) ); - } - } - else - { - tmpQuads = (V3F_C4B_T2F_Quad*)realloc( _quads, sizeof(_quads[0]) * _capacity ); - if (tmpQuads != NULL && _capacity > oldCapactiy) - { - memset(tmpQuads+oldCapactiy, 0, (_capacity - oldCapactiy)*sizeof(_quads[0]) ); - } - } - - if (_indices == NULL) - { - tmpIndices = (GLushort*)malloc( _capacity * 6 * sizeof(_indices[0]) ); - if (tmpIndices != NULL) - { - memset( tmpIndices, 0, _capacity * 6 * sizeof(_indices[0]) ); - } - - } - else - { - tmpIndices = (GLushort*)realloc( _indices, sizeof(_indices[0]) * _capacity * 6 ); - if (tmpIndices != NULL && _capacity > oldCapactiy) - { - memset( tmpIndices+oldCapactiy, 0, (_capacity-oldCapactiy) * 6 * sizeof(_indices[0]) ); - } - } - - if( ! ( tmpQuads && tmpIndices) ) { - CCLOG("cocos2d: TextureAtlas: not enough memory"); - CC_SAFE_FREE(tmpQuads); - CC_SAFE_FREE(tmpIndices); - CC_SAFE_FREE(_quads); - CC_SAFE_FREE(_indices); - _capacity = _totalQuads = 0; - return false; - } - - _quads = tmpQuads; - _indices = tmpIndices; - - - setupIndices(); - mapBuffers(); - - _dirty = true; - - return true; -} - -void TextureAtlas::increaseTotalQuadsWith(int amount) -{ - CCASSERT(amount>=0, "amount >= 0"); - _totalQuads += amount; -} - -void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex) -{ - CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0"); - CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); - CCASSERT(oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index"); - - if( oldIndex == newIndex ) - { - return; - } - //create buffer - size_t quadSize = sizeof(V3F_C4B_T2F_Quad); - V3F_C4B_T2F_Quad* tempQuads = (V3F_C4B_T2F_Quad*)malloc( quadSize * amount); - memcpy( tempQuads, &_quads[oldIndex], quadSize * amount ); - - if (newIndex < oldIndex) - { - // move quads from newIndex to newIndex + amount to make room for buffer - memmove( &_quads[newIndex], &_quads[newIndex+amount], (oldIndex-newIndex)*quadSize); - } - else - { - // move quads above back - memmove( &_quads[oldIndex], &_quads[oldIndex+amount], (newIndex-oldIndex)*quadSize); - } - memcpy( &_quads[newIndex], tempQuads, amount*quadSize); - - free(tempQuads); - - _dirty = true; -} - -void TextureAtlas::moveQuadsFromIndex(int index, int newIndex) -{ - CCASSERT(index>=0 && newIndex>=0, "values must be >= 0"); - CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds"); - - memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0])); -} - -void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount) -{ - CCASSERT(index>=0 && amount>=0, "values must be >= 0"); - V3F_C4B_T2F_Quad quad; - memset(&quad, 0, sizeof(quad)); - - int to = index + amount; - for (int i = index ; i < to ; i++) - { - _quads[i] = quad; - } -} - -// TextureAtlas - Drawing - -void TextureAtlas::drawQuads() -{ - this->drawNumberOfQuads(_totalQuads, 0); -} - -void TextureAtlas::drawNumberOfQuads(int numberOfQuads) -{ - CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0"); - this->drawNumberOfQuads(numberOfQuads, 0); -} - -void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) -{ - CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0"); - - if(!numberOfQuads) - return; - - GL::bindTexture2D(_texture->getName()); - - if (Configuration::getInstance()->supportsShareableVAO()) { - // - // Using VBO and VAO - // - - // XXX: update is done in draw... perhaps it should be done in a timer - if (_dirty) - { - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - // option 1: subdata - //glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); - - // option 2: data - // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); - - // option 3: orphaning + glMapBuffer - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW); - void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start)); - glUnmapBuffer(GL_ARRAY_BUFFER); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - - _dirty = false; - } - - GL::bindVAO(_VAOname); - -#if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); -#endif - -#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); -#else - glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) ); -#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - -#if CC_REBIND_INDICES_BUFFER - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -#endif - -// glBindVertexArray(0); - } - else { - // - // Using VBO without VAO - // - -#define kQuadSize sizeof(_quads[0].bl) - glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); - - // XXX: update is done in draw... perhaps it should be done in a timer - if (_dirty) - { - glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] ); - _dirty = false; - } - - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - - // vertices - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); - - // colors - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); - - // tex coords - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); - -#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); -#else - glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0]))); -#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - - CC_INCREMENT_GL_DRAWS(1); - CHECK_GL_ERROR_DEBUG(); -} - - -NS_CC_END - diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h deleted file mode 100644 index 9e1bca0381..0000000000 --- a/cocos2dx/textures/CCTextureAtlas.h +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga 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 __CCTEXTURE_ATLAS_H__ -#define __CCTEXTURE_ATLAS_H__ - -#include "ccTypes.h" -#include "cocoa/CCObject.h" -#include "ccConfig.h" -#include - -NS_CC_BEGIN - -class Texture2D; - -/** - * @addtogroup textures - * @{ - */ - -/** @brief A class that implements a Texture Atlas. -Supported features: -* The atlas file can be a PVRTC, PNG or any other format supported by Texture2D -* Quads can be updated in runtime -* Quads can be added in runtime -* Quads can be removed in runtime -* Quads can be re-ordered in runtime -* The TextureAtlas capacity can be increased or decreased in runtime -* OpenGL component: V3F, C4B, T2F. -The quads are rendered using an OpenGL ES VBO. -To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file -*/ -class CC_DLL TextureAtlas : public Object -{ -public: - /** creates a TextureAtlas with an filename and with an initial capacity for Quads. - * The TextureAtlas capacity can be increased in runtime. - */ - static TextureAtlas* create(const char* file , int capacity); - - /** creates a TextureAtlas with a previously initialized Texture2D object, and - * with an initial capacity for n Quads. - * The TextureAtlas capacity can be increased in runtime. - */ - static TextureAtlas* createWithTexture(Texture2D *texture, int capacity); - /** - * @js ctor - */ - TextureAtlas(); - /** - * @js NA - * @lua NA - */ - virtual ~TextureAtlas(); - - /** initializes a TextureAtlas with a filename and with a certain capacity for Quads. - * The TextureAtlas capacity can be increased in runtime. - * - * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) - */ - bool initWithFile(const char* file, int capacity); - - /** initializes a TextureAtlas with a previously initialized Texture2D object, and - * with an initial capacity for Quads. - * The TextureAtlas capacity can be increased in runtime. - * - * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706) - */ - bool initWithTexture(Texture2D *texture, int capacity); - - /** updates a Quad (texture, vertex and color) at a certain index - * index must be between 0 and the atlas capacity - 1 - @since v0.8 - */ - void updateQuad(V3F_C4B_T2F_Quad* quad, int index); - - /** Inserts a Quad (texture, vertex and color) at a certain index - index must be between 0 and the atlas capacity - 1 - @since v0.8 - */ - void insertQuad(V3F_C4B_T2F_Quad* quad, int index); - - /** Inserts a c array of quads at a given index - index must be between 0 and the atlas capacity - 1 - this method doesn't enlarge the array when amount + index > totalQuads - @since v1.1 - */ - void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount); - - /** Removes the quad that is located at a certain index and inserts it at a new index - This operation is faster than removing and inserting in a quad in 2 different steps - @since v0.7.2 - */ - void insertQuadFromIndex(int fromIndex, int newIndex); - - /** removes a quad at a given index number. - The capacity remains the same, but the total number of quads to be drawn is reduced in 1 - @since v0.7.2 - */ - void removeQuadAtIndex(int index); - - /** removes a amount of quads starting from index - @since 1.1 - */ - void removeQuadsAtIndex(int index, int amount); - /** removes all Quads. - The TextureAtlas capacity remains untouched. No memory is freed. - The total number of quads to be drawn will be 0 - @since v0.7.2 - */ - void removeAllQuads(); - - /** resize the capacity of the TextureAtlas. - * The new capacity can be lower or higher than the current one - * It returns true if the resize was successful. - * If it fails to resize the capacity it will return false with a new capacity of 0. - */ - bool resizeCapacity(int capacity); - - /** - Used internally by ParticleBatchNode - don't use this unless you know what you're doing - @since 1.1 - */ - void increaseTotalQuadsWith(int amount); - - /** Moves an amount of quads from oldIndex at newIndex - @since v1.1 - */ - void moveQuadsFromIndex(int oldIndex, int amount, int newIndex); - - /** - Moves quads from index till totalQuads to the newIndex - Used internally by ParticleBatchNode - This method doesn't enlarge the array if newIndex + quads to be moved > capacity - @since 1.1 - */ - void moveQuadsFromIndex(int index, int newIndex); - - /** - Ensures that after a realloc quads are still empty - Used internally by ParticleBatchNode - @since 1.1 - */ - void fillWithEmptyQuadsFromIndex(int index, int amount); - - /** draws n quads - * n can't be greater than the capacity of the Atlas - */ - void drawNumberOfQuads(int n); - - /** draws n quads from an index (offset). - n + start can't be greater than the capacity of the atlas - - @since v1.0 - */ - void drawNumberOfQuads(int numberOfQuads, int start); - - /** draws all the Atlas's Quads - */ - void drawQuads(); - /** listen the event that coming to foreground on Android - */ - void listenBackToForeground(Object *obj); - - /** whether or not the array buffer of the VBO needs to be updated*/ - inline bool isDirty(void) { return _dirty; } - /** specify if the array buffer of the VBO needs to be updated */ - inline void setDirty(bool bDirty) { _dirty = bDirty; } - /** - * @js NA - * @lua NA - */ - const char* description() const; - - /** Gets the quantity of quads that are going to be drawn */ - int getTotalQuads() const; - - /** Gets the quantity of quads that can be stored with the current texture atlas size */ - int getCapacity() const; - - /** Gets the texture of the texture atlas */ - Texture2D* getTexture() const; - - /** Sets the texture for the texture atlas */ - void setTexture(Texture2D* texture); - - /** Gets the quads that are going to be rendered */ - V3F_C4B_T2F_Quad* getQuads(); - - /** Sets the quads that are going to be rendered */ - void setQuads(V3F_C4B_T2F_Quad* quads); - -private: - void setupIndices(); - void mapBuffers(); - void setupVBOandVAO(); - void setupVBO(); - -protected: - GLushort* _indices; - GLuint _VAOname; - GLuint _buffersVBO[2]; //0: vertex 1: indices - bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated - /** quantity of quads that are going to be drawn */ - int _totalQuads; - /** quantity of quads that can be stored with the current texture atlas size */ - int _capacity; - /** Texture of the texture atlas */ - Texture2D* _texture; - /** Quads that are going to be rendered */ - V3F_C4B_T2F_Quad* _quads; -}; - -// end of textures group -/// @} - -NS_CC_END - -#endif //__CCTEXTURE_ATLAS_H__ - - From 3f61a0ac00a2e281294a7effebc904b1384b5746 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 12 Nov 2013 14:56:24 -0800 Subject: [PATCH 130/185] Updates CODING STYLE Adds Xcode 5.0, gcc 4.8 and VS 2012 as the supported compilers --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 2a00974e4b..6945ddbae6 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -f86eb12e6d4835f93bd6f59d860970bcd2f74128 \ No newline at end of file +37dfc3b433bd9ec20bb0c8d6577a3a359297e601 \ No newline at end of file From d8efcc04e6d64644c18b116409140135532bdc14 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 12 Nov 2013 15:23:43 -0800 Subject: [PATCH 131/185] More fixes to CODING STYLE Adds cocos2d-x logo, and other syntax fixes --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 6945ddbae6..01d3ca6aba 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -37dfc3b433bd9ec20bb0c8d6577a3a359297e601 \ No newline at end of file +6ff98d27fb05c33096fc76e1bdd71104506f5bc8 \ No newline at end of file From da05fa1f63715a7be7c41b81fec5437f2fa79ec3 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 12 Nov 2013 15:57:29 -0800 Subject: [PATCH 132/185] removes cocos2d-x from title since the image is already there --- docs/CODING_STYLE.md.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CODING_STYLE.md.REMOVED.git-id b/docs/CODING_STYLE.md.REMOVED.git-id index 01d3ca6aba..14fe782823 100644 --- a/docs/CODING_STYLE.md.REMOVED.git-id +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -1 +1 @@ -6ff98d27fb05c33096fc76e1bdd71104506f5bc8 \ No newline at end of file +811c4efefbe80ac5bcc88d74e56cc093166dd64a \ No newline at end of file From 4848e3d3bb7350d40bd133a9e88883ddde49fe76 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 12 Nov 2013 17:14:51 -0800 Subject: [PATCH 133/185] correct size for Listener ID --- cocos/2d/CCEventListener.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCEventListener.h b/cocos/2d/CCEventListener.h index 04a1a779a4..a24b709e5b 100644 --- a/cocos/2d/CCEventListener.h +++ b/cocos/2d/CCEventListener.h @@ -57,7 +57,7 @@ public: CUSTOM }; - typedef int ListenerID; + typedef std::size_t ListenerID; protected: /** Constructor */ From 062fb859430695fae6d4734af3495bd6a434e459 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Wed, 13 Nov 2013 10:12:44 +0800 Subject: [PATCH 134/185] issue #2868:Modify cocos2dx_studio.ini to add more auto-binding class --- .../cocostudio/CSContentJsonDictionary.h | 2 +- .../CocoStudioSceneTest/CocoStudioSceneTest.lua | 15 +-------------- tools/tolua/cocos2dx_studio.ini | 6 ++++-- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/cocos/editor-support/cocostudio/CSContentJsonDictionary.h b/cocos/editor-support/cocostudio/CSContentJsonDictionary.h index f8f047b19a..cca9ba5ad8 100644 --- a/cocos/editor-support/cocostudio/CSContentJsonDictionary.h +++ b/cocos/editor-support/cocostudio/CSContentJsonDictionary.h @@ -50,7 +50,7 @@ namespace cocostudio { { public: JsonDictionary(); - ~JsonDictionary(); + virtual ~JsonDictionary(); public: void initWithDescription(const char *pszDescription); diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index 2b7fd6905d..a1679ee671 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -11,19 +11,6 @@ function SceneEditorTestLayer.extend(target) return target end -function SceneEditorTestLayer:init() - - - local mainMenuLabel = ccs.UILabel:create() - mainMenuLabel:setText("MainMenu") - mainMenuLabel:setFontSize(20) - mainMenuLabel:setTouchScaleChangeEnabled(true) - mainMenuLabel:setPosition(cc.p(430,30)) - mainMenuLabel:setTouchEnabled(true) - mainMenuLabel:addTouchEventListener(menuCloseCallback) - self._uiLayer:addWidget(mainMenuLabel) -end - function SceneEditorTestLayer:createGameScene() local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/FishJoy2.json") if nil == node then @@ -44,7 +31,7 @@ function SceneEditorTestLayer:createGameScene() cc.MenuItemFont:setFontSize(24) local itemBack = cc.MenuItemFont:create("Back") itemBack:setColor(cc.c3b(255, 255, 255)) - itemBack:setPosition(cc.p(VisibleRect:bottom().x - 50, VisibleRect:bottom().y + 25)) + itemBack:setPosition( cc.p(430,30) ) itemBack:registerScriptTapHandler(menuCloseCallback) local menuBack = cc.Menu:create() menuBack:setPosition(cc.p(0.0, 0.0)) diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 734bf0f02b..3aed09bac4 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/co # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio ComController ComAttribute ComRender # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -45,7 +45,9 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* UILayer::[getInputManager], UILayoutParameter::[(s|g)etMargin], UIHelper::[init], - GUIReader::[setPropsForImageButtonFromJsonDictionary] + GUIReader::[setPropsForImageButtonFromJsonDictionary], + UIWidget::[(s|g)etUserObject], + UIImageView::[doubleClickEvent] rename_functions = UIHelper::[instance=getInstance], ArmatureDataManager::[sharedArmatureDataManager=getInstance], From 03b3d583e833343801e4e33f565b4d098d930ade Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Wed, 13 Nov 2013 10:16:16 +0800 Subject: [PATCH 135/185] Modify scenereader --- cocos/editor-support/cocostudio/CCSSceneReader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 25c84fd773..71134ed58e 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -320,8 +320,8 @@ namespace cocostudio { { gui::UILayer *pLayer = gui::UILayer::create(); pLayer->scheduleUpdate(); -// UIWidget* widget= gui::UIHelper::instance()->createWidgetFromJsonFile(pPath.c_str()); -// pLayer->addWidget(widget); + UIWidget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str()); + pLayer->addWidget(widget); ComRender *pRender = ComRender::create(pLayer, "GUIComponent"); if (pComName != NULL) { From fb04c9e57492d1e0c67a38cb1b4cee0eaf6f22e3 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Wed, 13 Nov 2013 11:22:34 +0800 Subject: [PATCH 136/185] issue #2770: fix some warning --- cocos/2d/CCFontFreeType.cpp | 10 +++++----- cocos/2d/CCLabel.cpp | 14 +++++++------- cocos/2d/CCLabelAtlas.cpp | 10 +++++----- cocos/2d/CCLabelBMFont.cpp | 2 +- cocos/2d/CCParticleSystem.cpp | 12 ++++++------ cocos/2d/CCProfiling.cpp | 6 +++--- cocos/2d/CCTextImage.cpp | 2 +- cocos/2d/CCTexture2D.cpp | 12 ++++++------ cocos/2d/ZipUtils.cpp | 2 +- cocos/2d/platform/CCImageCommon_cpp.h | 6 +++--- cocos/2d/platform/linux/CCEGLView.cpp | 2 +- .../editor-support/cocostudio/CCColliderDetector.h | 2 +- .../cocostudio/CCDataReaderHelper.cpp | 6 +++--- cocos/physics/CCPhysicsContact.cpp | 2 +- extensions/assets-manager/AssetsManager.h | 2 ++ samples/Cpp/HelloCpp/Classes/AppDelegate.cpp | 2 -- .../Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp | 2 +- .../PerformanceNodeChildrenTest.cpp | 2 -- .../TestCpp/Classes/PhysicsTest/PhysicsTest.cpp | 2 +- .../Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h | 4 +--- 20 files changed, 49 insertions(+), 53 deletions(-) diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 5e2173204f..e0cbb516eb 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -87,11 +87,11 @@ FT_Library FontFreeType::getFTLibrary() return _FTlibrary; } -FontFreeType::FontFreeType(bool dynamicGlyphCollection) - : _letterPadding(5), - _ttfData(nullptr), - _dynamicGlyphCollection(dynamicGlyphCollection), - _fontRef(nullptr) +FontFreeType::FontFreeType(bool dynamicGlyphCollection) +: _fontRef(nullptr), +_letterPadding(5), +_ttfData(nullptr), +_dynamicGlyphCollection(dynamicGlyphCollection) { } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 0dc7fc5081..5099fb551e 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -93,12 +93,13 @@ Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int li } Label::Label(FontAtlas *atlas, TextHAlignment alignment) -: _currentUTF16String(0) -, _originalUTF16String(0) -, _fontAtlas(atlas) -, _alignment(alignment) +: _reusedLetter(nullptr) , _lineBreakWithoutSpaces(false) +, _alignment(alignment) +, _currentUTF16String(0) +, _originalUTF16String(0) , _advances(0) +, _fontAtlas(atlas) , _displayedColor(Color3B::WHITE) , _realColor(Color3B::WHITE) , _cascadeColorEnabled(true) @@ -106,7 +107,6 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment) , _displayedOpacity(255) , _realOpacity(255) , _isOpacityModifyRGB(true) -,_reusedLetter(nullptr) { } @@ -386,7 +386,7 @@ Sprite * Label::updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const F bool Label::recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) { - if (spriteIndex >= _lettersInfo.size()) + if (static_cast(spriteIndex) >= _lettersInfo.size()) { LetterInfo tmpInfo; _lettersInfo.push_back(tmpInfo); @@ -402,7 +402,7 @@ bool Label::recordLetterInfo(const cocos2d::Point& point,unsigned short int theC bool Label::recordPlaceholderInfo(int spriteIndex) { - if (spriteIndex >= _lettersInfo.size()) + if (static_cast(spriteIndex) >= _lettersInfo.size()) { LetterInfo tmpInfo; _lettersInfo.push_back(tmpInfo); diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index b9115741e3..4c64ca3418 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -127,9 +127,9 @@ void LabelAtlas::updateAtlasValues() itemHeightInPixels = _itemHeight; } - CCASSERT( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length"); + CCASSERT( static_cast(n) <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length"); V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads(); - for(int i = 0; i < n; i++) { + for(long i = 0; i < static_cast(n); i++) { unsigned char a = s[i] - _mapStartChar; float row = (float) (a % _itemsPerRow); @@ -177,8 +177,8 @@ void LabelAtlas::updateAtlasValues() } if (n > 0 ){ _textureAtlas->setDirty(true); - int totalQuads = _textureAtlas->getTotalQuads(); - if (n > totalQuads) { + long totalQuads = _textureAtlas->getTotalQuads(); + if (static_cast(n) > totalQuads) { _textureAtlas->increaseTotalQuadsWith(n - totalQuads); } } @@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues() void LabelAtlas::setString(const std::string &label) { size_t len = label.size(); - if (len > _textureAtlas->getTotalQuads()) + if (static_cast(len) > _textureAtlas->getTotalQuads()) { _textureAtlas->resizeCapacity(len); } diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 6749c5d107..13ff2fc980 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -202,7 +202,7 @@ std::set* CCBMFontConfiguration::parseConfigFile(const std::string { size_t pos = strLeft.find('\n'); - if (pos != (int)std::string::npos) + if (pos != std::string::npos) { // the data is more than a line.get one line line = strLeft.substr(0, pos); diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index cb2c4326f3..ce34d18be1 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -81,15 +81,15 @@ NS_CC_BEGIN // ParticleSystem::ParticleSystem() -: _configName("") -, _isBlendAdditive(false) +: _isBlendAdditive(false) , _isAutoRemoveOnFinish(false) , _plistFile("") , _elapsed(0) -, _particles(NULL) +, _particles(nullptr) +, _configName("") , _emitCounter(0) , _particleIdx(0) -, _batchNode(NULL) +, _batchNode(nullptr) , _atlasIndex(0) , _transformSystemDirty(false) , _allocatedParticles(0) @@ -113,11 +113,11 @@ ParticleSystem::ParticleSystem() , _endSpinVar(0) , _emissionRate(0) , _totalParticles(0) -, _texture(NULL) +, _texture(nullptr) , _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED) , _opacityModifyRGB(false) -, _positionType(PositionType::FREE) , _yCoordFlipped(0) +, _positionType(PositionType::FREE) { modeA.gravity = Point::ZERO; modeA.speed = 0; diff --git a/cocos/2d/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp index 3c90394d58..e0878d5f5a 100644 --- a/cocos/2d/CCProfiling.cpp +++ b/cocos/2d/CCProfiling.cpp @@ -101,12 +101,12 @@ void Profiler::displayTimers() // implementation of ProfilingTimer ProfilingTimer::ProfilingTimer() -: numberOfCalls(0) -, _averageTime1(0) +: _averageTime1(0) , _averageTime2(0) -, totalTime(0) , minTime(100000000) , maxTime(0) +, totalTime(0) +, numberOfCalls(0) { } diff --git a/cocos/2d/CCTextImage.cpp b/cocos/2d/CCTextImage.cpp index fd2ca403f5..3e8398ba02 100644 --- a/cocos/2d/CCTextImage.cpp +++ b/cocos/2d/CCTextImage.cpp @@ -130,7 +130,7 @@ TextFontPagesDef::~TextFontPagesDef() } } -TextImage::TextImage(): _font(0), _fontPages(0) +TextImage::TextImage(): _fontPages(0), _font(0) { } diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 2f0665afb4..d8c0bfbaf8 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -622,8 +622,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat CHECK_GL_ERROR_DEBUG(); // clean possible GL error // Specify OpenGL texture image - int width = pixelsWide; - int height = pixelsHigh; + long width = pixelsWide; + long height = pixelsHigh; for (int i = 0; i < mipmapsNum; ++i) { @@ -641,7 +641,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat if (i > 0 && (width != height || ccNextPOT(width) != width )) { - CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%u != height=%u", i, width, height); + CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%ld != height=%ld", i, width, height); } GLenum err = glGetError(); @@ -1243,7 +1243,7 @@ void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) void Texture2D::generateMipmap() { - CCASSERT( _pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures"); + CCASSERT( static_cast(_pixelsWide) == ccNextPOT(_pixelsWide) && static_cast(_pixelsHigh) == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures"); GL::bindTexture2D( _name ); glGenerateMipmap(GL_TEXTURE_2D); _hasMipmaps = true; @@ -1256,8 +1256,8 @@ bool Texture2D::hasMipmaps() const void Texture2D::setTexParameters(const TexParams &texParams) { - CCASSERT( (_pixelsWide == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) && - (_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE), + CCASSERT( (static_cast(_pixelsWide) == ccNextPOT(_pixelsWide) || texParams.wrapS == GL_CLAMP_TO_EDGE) && + (static_cast(_pixelsHigh) == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE), "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); GL::bindTexture2D( _name ); diff --git a/cocos/2d/ZipUtils.cpp b/cocos/2d/ZipUtils.cpp index 2e5d9fe43f..8cfdf73026 100644 --- a/cocos/2d/ZipUtils.cpp +++ b/cocos/2d/ZipUtils.cpp @@ -318,7 +318,7 @@ bool ZipUtils::ccIsCCZFile(const char *path) bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len) { - if (len < sizeof(struct CCZHeader)) + if (static_cast(len) < sizeof(struct CCZHeader)) { return false; } diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index bf1f856e39..09b73ea421 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -380,8 +380,8 @@ Image::Image() , _fileType(Format::UNKOWN) , _renderFormat(Texture2D::PixelFormat::NONE) , _preMulti(false) -, _hasPremultipliedAlpha(true) , _numberOfMipmaps(0) +, _hasPremultipliedAlpha(true) { } @@ -602,7 +602,7 @@ bool Image::isWebp(const unsigned char * data, int dataLen) bool Image::isPvr(const unsigned char * data, int dataLen) { - if (dataLen < sizeof(PVRv2TexHeader) || dataLen < sizeof(PVRv3TexHeader)) + if (static_cast(dataLen) < sizeof(PVRv2TexHeader) || static_cast(dataLen) < sizeof(PVRv3TexHeader)) { return false; } @@ -1283,7 +1283,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen) bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen) { - if (dataLen < sizeof(PVRv3TexHeader)) + if (static_cast(dataLen) < sizeof(PVRv3TexHeader)) { return false; } diff --git a/cocos/2d/platform/linux/CCEGLView.cpp b/cocos/2d/platform/linux/CCEGLView.cpp index a136ba54b3..612f936d51 100644 --- a/cocos/2d/platform/linux/CCEGLView.cpp +++ b/cocos/2d/platform/linux/CCEGLView.cpp @@ -284,8 +284,8 @@ EGLView* EGLView::s_pEglView = nullptr; EGLView::EGLView() : _captured(false) -, _frameZoomFactor(1.0f) , _supportTouch(false) +, _frameZoomFactor(1.0f) , _mainWindow(nullptr) { CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n"); diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index 2737980f60..3e9277f3e8 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -50,7 +50,7 @@ class Bone; class ColliderFilter { public: - ~ColliderFilter() { } + virtual ~ColliderFilter() { } #if ENABLE_PHYSICS_BOX2D_DETECT public: ColliderFilter(unsigned short categoryBits = 0x0001, unsigned short maskBits = 0xFFFF, signed short groupIndex = 0); diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index 0d7a397b68..c2fd534403 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -242,11 +242,11 @@ void DataReaderHelper::purge() DataReaderHelper::DataReaderHelper() : _loadingThread(nullptr) - , _asyncStructQueue(nullptr) - , _dataQueue(nullptr) - , need_quit(false) , _asyncRefCount(0) , _asyncRefTotalCount(0) + , need_quit(false) + , _asyncStructQueue(nullptr) + , _dataQueue(nullptr) { } diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index 9d6325c150..74cb18ffca 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -52,10 +52,10 @@ PhysicsContact::PhysicsContact() , _info(nullptr) , _notificationEnable(true) , _begin(false) +, _result(true) , _data(nullptr) , _contactInfo(nullptr) , _contactData(nullptr) -, _result(true) { } diff --git a/extensions/assets-manager/AssetsManager.h b/extensions/assets-manager/AssetsManager.h index f3e413f4bd..93ff6ad950 100644 --- a/extensions/assets-manager/AssetsManager.h +++ b/extensions/assets-manager/AssetsManager.h @@ -237,6 +237,8 @@ private: class AssetsManagerDelegateProtocol { +public: + virtual ~AssetsManagerDelegateProtocol(){}; public: /* @brief Call back function for error @param errorCode Type of error diff --git a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp index 54019ceb53..97fb7366c3 100644 --- a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp @@ -23,8 +23,6 @@ bool AppDelegate::applicationDidFinishLaunching() { auto glView = EGLView::getInstance(); director->setOpenGLView(glView); - - auto size = director->getWinSize(); // Set the design resolution glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp index e329dafcbe..3da126f3b2 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp @@ -1096,7 +1096,7 @@ LabelTTFFontsTestNew::LabelTTFFontsTestNew() auto size = Director::getInstance()->getWinSize(); - for(int i=0;i < arraysize(ttfpaths); ++i) { + for(size_t i=0;i < arraysize(ttfpaths); ++i) { auto label = Label::createWithTTF( ttfpaths[i], ttfpaths[i], 40, 0, TextHAlignment::CENTER, GlyphCollection::NEHE); if( label ) { diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 6d1391b578..bb54a16f24 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -235,8 +235,6 @@ IterateSpriteSheet::~IterateSpriteSheet() void IterateSpriteSheet::updateQuantityOfNodes() { - auto s = Director::getInstance()->getWinSize(); - // increase nodes if( currentQuantityOfNodes < quantityOfNodes ) { diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index 29f4b68e6d..6f85f86411 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -96,8 +96,8 @@ void PhysicsTestScene::toggleDebug() PhysicsDemo::PhysicsDemo() : _scene(nullptr) -, _ball(nullptr) , _spriteTexture(nullptr) +, _ball(nullptr) { } diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index a3ccc76e57..e0f607b9cf 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -22,9 +22,6 @@ private: class PhysicsDemo : public BaseTest { -protected: - PhysicsTestScene* _scene; - public: PhysicsDemo(); virtual ~PhysicsDemo(); @@ -48,6 +45,7 @@ public: void onTouchEnded(Touch* touch, Event* event); protected: + PhysicsTestScene* _scene; Texture2D* _spriteTexture; // weak ref SpriteBatchNode* _ball; std::map _mouses; From 2a08c3b876fb5650d5732f5bdb178e51fbf73f8b Mon Sep 17 00:00:00 2001 From: bmanGH Date: Wed, 13 Nov 2013 14:28:23 +0800 Subject: [PATCH 137/185] remove conflicts files; --- cocos2dx/platform/CCEGLViewProtocol.cpp | 384 ------------------------ 1 file changed, 384 deletions(-) delete mode 100644 cocos2dx/platform/CCEGLViewProtocol.cpp diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp deleted file mode 100644 index 985cbb51c7..0000000000 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ /dev/null @@ -1,384 +0,0 @@ -#include "CCEGLViewProtocol.h" -#include "event_dispatcher/CCTouch.h" -#include "CCDirector.h" -#include "cocoa/CCSet.h" -#include "event_dispatcher/CCEventDispatcher.h" - - -NS_CC_BEGIN - -namespace { - - static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL }; - static unsigned int g_indexBitsUsed = 0; - // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0 - static std::map g_touchIdReorderMap; - - static int getUnUsedIndex() - { - int i; - int temp = g_indexBitsUsed; - - for (i = 0; i < EventTouch::MAX_TOUCHES; i++) { - if (! (temp & 0x00000001)) { - g_indexBitsUsed |= (1 << i); - return i; - } - - temp >>= 1; - } - - // all bits are used - return -1; - } - - static void removeUsedIndexBit(int index) - { - if (index < 0 || index >= EventTouch::MAX_TOUCHES) - { - return; - } - - unsigned int temp = 1 << index; - temp = ~temp; - g_indexBitsUsed &= temp; - } - -} - -EGLViewProtocol::EGLViewProtocol() -: _delegate(NULL) -, _scaleX(1.0f) -, _scaleY(1.0f) -, _resolutionPolicy(ResolutionPolicy::UNKNOWN) -{ -} - -EGLViewProtocol::~EGLViewProtocol() -{ - -} - -void EGLViewProtocol::pollInputEvents() -{ -} - -void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy) -{ - CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy"); - - if (width == 0.0f || height == 0.0f) - { - return; - } - - _designResolutionSize.setSize(width, height); - - _scaleX = (float)_screenSize.width / _designResolutionSize.width; - _scaleY = (float)_screenSize.height / _designResolutionSize.height; - - if (resolutionPolicy == ResolutionPolicy::NO_BORDER) - { - _scaleX = _scaleY = MAX(_scaleX, _scaleY); - } - - if (resolutionPolicy == ResolutionPolicy::SHOW_ALL) - { - _scaleX = _scaleY = MIN(_scaleX, _scaleY); - } - - if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) { - _scaleX = _scaleY; - _designResolutionSize.width = ceilf(_screenSize.width/_scaleX); - } - - if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) { - _scaleY = _scaleX; - _designResolutionSize.height = ceilf(_screenSize.height/_scaleY); - } - - // calculate the rect of viewport - float viewPortW = _designResolutionSize.width * _scaleX; - float viewPortH = _designResolutionSize.height * _scaleY; - - _viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH); - - _resolutionPolicy = resolutionPolicy; - - // reset director's member variables to fit visible rect - Director::getInstance()->_winSizeInPoints = getDesignResolutionSize(); - Director::getInstance()->createStatsLabel(); - Director::getInstance()->setGLDefaultValues(); -} - -const Size& EGLViewProtocol::getDesignResolutionSize() const -{ - return _designResolutionSize; -} - -const Size& EGLViewProtocol::getFrameSize() const -{ - return _screenSize; -} - -void EGLViewProtocol::setFrameSize(float width, float height) -{ - _designResolutionSize = _screenSize = Size(width, height); -} - -Size EGLViewProtocol::getVisibleSize() const -{ - if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) - { - return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY); - } - else - { - return _designResolutionSize; - } -} - -Point EGLViewProtocol::getVisibleOrigin() const -{ - if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) - { - return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2, - (_designResolutionSize.height - _screenSize.height/_scaleY)/2); - } - else - { - return Point::ZERO; - } -} - -void EGLViewProtocol::setTouchDelegate(EGLTouchDelegate * pDelegate) -{ - _delegate = pDelegate; -} - -void EGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h) -{ - glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x), - (GLint)(y * _scaleY + _viewPortRect.origin.y), - (GLsizei)(w * _scaleX), - (GLsizei)(h * _scaleY)); -} - -void EGLViewProtocol::setScissorInPoints(float x , float y , float w , float h) -{ - glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x), - (GLint)(y * _scaleY + _viewPortRect.origin.y), - (GLsizei)(w * _scaleX), - (GLsizei)(h * _scaleY)); -} - -bool EGLViewProtocol::isScissorEnabled() -{ - return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true; -} - -Rect EGLViewProtocol::getScissorRect() -{ - GLfloat params[4]; - glGetFloatv(GL_SCISSOR_BOX, params); - float x = (params[0] - _viewPortRect.origin.x) / _scaleX; - float y = (params[1] - _viewPortRect.origin.y) / _scaleY; - float w = params[2] / _scaleX; - float h = params[3] / _scaleY; - return Rect(x, y, w, h); -} - -void EGLViewProtocol::setViewName(const char* pszViewName) -{ - if (pszViewName != NULL && strlen(pszViewName) > 0) - { - strncpy(_viewName, pszViewName, sizeof(_viewName)); - } -} - -const char* EGLViewProtocol::getViewName() -{ - return _viewName; -} - -void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) -{ - int id = 0; - float x = 0.0f; - float y = 0.0f; - int nUnusedIndex = 0; - EventTouch touchEvent; - - for (int i = 0; i < num; ++i) - { - id = ids[i]; - x = xs[i]; - y = ys[i]; - - auto iter = g_touchIdReorderMap.find(id); - nUnusedIndex = 0; - - // it is a new touch - if (iter == g_touchIdReorderMap.end()) - { - nUnusedIndex = getUnUsedIndex(); - - // The touches is more than MAX_TOUCHES ? - if (nUnusedIndex == -1) { - CCLOG("The touches is more than MAX_TOUCHES, nUnusedIndex = %d", nUnusedIndex); - continue; - } - - Touch* touch = g_touches[nUnusedIndex] = new Touch(); - touch->setTouchInfo(nUnusedIndex, (x - _viewPortRect.origin.x) / _scaleX, - (y - _viewPortRect.origin.y) / _scaleY); - - CCLOGINFO("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y); - - g_touchIdReorderMap.insert(std::make_pair(id, nUnusedIndex)); - touchEvent._touches.push_back(touch); - } - } - - if (touchEvent._touches.size() == 0) - { - CCLOG("touchesBegan: size = 0"); - return; - } - - touchEvent._eventCode = EventTouch::EventCode::BEGAN; - EventDispatcher::getInstance()->dispatchEvent(&touchEvent); -} - -void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[]) -{ - int id = 0; - float x = 0.0f; - float y = 0.0f; - EventTouch touchEvent; - - for (int i = 0; i < num; ++i) - { - id = ids[i]; - x = xs[i]; - y = ys[i]; - - auto iter = g_touchIdReorderMap.find(id); - if (iter == g_touchIdReorderMap.end()) - { - CCLOG("if the index doesn't exist, it is an error"); - continue; - } - - CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y); - Touch* touch = g_touches[iter->second]; - if (touch) - { - touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX, - (y - _viewPortRect.origin.y) / _scaleY); - - touchEvent._touches.push_back(touch); - } - else - { - // It is error, should return. - CCLOG("Moving touches with id: %d error", id); - return; - } - } - - if (touchEvent._touches.size() == 0) - { - CCLOG("touchesMoved: size = 0"); - return; - } - - touchEvent._eventCode = EventTouch::EventCode::MOVED; - EventDispatcher::getInstance()->dispatchEvent(&touchEvent); -} - -void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]) -{ - int id = 0; - float x = 0.0f; - float y = 0.0f; - EventTouch touchEvent; - - for (int i = 0; i < num; ++i) - { - id = ids[i]; - x = xs[i]; - y = ys[i]; - - auto iter = g_touchIdReorderMap.find(id); - if (iter == g_touchIdReorderMap.end()) - { - CCLOG("if the index doesn't exist, it is an error"); - continue; - } - - /* Add to the set to send to the director */ - Touch* touch = g_touches[iter->second]; - if (touch) - { - CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y); - touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX, - (y - _viewPortRect.origin.y) / _scaleY); - - touchEvent._touches.push_back(touch); - - g_touches[iter->second] = NULL; - removeUsedIndexBit(iter->second); - - g_touchIdReorderMap.erase(id); - } - else - { - CCLOG("Ending touches with id: %d error", id); - return; - } - - } - - if (touchEvent._touches.size() == 0) - { - CCLOG("touchesEnded or touchesCancel: size = 0"); - return; - } - - touchEvent._eventCode = eventCode; - EventDispatcher::getInstance()->dispatchEvent(&touchEvent); - - for (auto& touch : touchEvent._touches) - { - // release the touch object. - touch->release(); - } -} - -void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) -{ - handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys); -} - -void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) -{ - handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys); -} - -const Rect& EGLViewProtocol::getViewPortRect() const -{ - return _viewPortRect; -} - -float EGLViewProtocol::getScaleX() const -{ - return _scaleX; -} - -float EGLViewProtocol::getScaleY() const -{ - return _scaleY; -} - -NS_CC_END From fbb4d0225193006cd7301163fa3e760c3ba6ec7d Mon Sep 17 00:00:00 2001 From: garfield_ho Date: Wed, 13 Nov 2013 14:38:01 +0800 Subject: [PATCH 138/185] When anchor point is 0,0 , CocosBuilder will not output anchor point param setting request.Although the Scale9Sprite`s anchor point is default to 0, 0, but when calling function "initWithBatchNode", the anchor point will be set to 0.5, 0.5. --- cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h index b4ec05c92f..2d3673f17b 100644 --- a/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h +++ b/cocos/editor-support/cocosbuilder/CCScale9SpriteLoader.h @@ -28,7 +28,13 @@ protected: * @js NA * @lua NA */ - CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::extension::Scale9Sprite); + virtual cocos2d::extension::Scale9Sprite * createNode(cocos2d::Node * pParent, cocosbuilder::CCBReader * ccbReader) { + cocos2d::extension::Scale9Sprite* pNode = cocos2d::extension::Scale9Sprite::create(); + + pNode->setAnchorPoint(cocos2d::Point(0,0)); + + return pNode; + }; /** * @js NA * @lua NA From 2687ee8915bbb67c9df5c46e88637ea281ad569b Mon Sep 17 00:00:00 2001 From: bmanGH Date: Wed, 13 Nov 2013 14:52:16 +0800 Subject: [PATCH 139/185] put '{' in a new line to follow cocos2d-x coding style --- cocos/2d/CCDrawNode.cpp | 15 ++++++++----- cocos/2d/CCParticleSystemQuad.cpp | 36 ++++++++++++++++++++----------- cocos/2d/CCTextureAtlas.cpp | 21 ++++++++++++------ cocos/2d/ccGLStateCache.cpp | 3 ++- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 0fb35408bf..67ba1075b1 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -115,7 +115,8 @@ DrawNode::~DrawNode() glDeleteBuffers(1, &_vbo); _vbo = 0; - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { glDeleteVertexArrays(1, &_vao); GL::bindVAO(0); _vao = 0; @@ -160,7 +161,8 @@ bool DrawNode::init() ensureCapacity(512); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { glGenVertexArrays(1, &_vao); GL::bindVAO(_vao); } @@ -180,7 +182,8 @@ bool DrawNode::init() glBindBuffer(GL_ARRAY_BUFFER, 0); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { GL::bindVAO(0); } @@ -207,10 +210,12 @@ void DrawNode::render() glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW); _dirty = false; } - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { GL::bindVAO(_vao); } - else { + else + { GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); glBindBuffer(GL_ARRAY_BUFFER, _vbo); diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 9564ca3fbb..36d2567809 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -58,10 +58,12 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) } initIndices(); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } @@ -95,7 +97,8 @@ ParticleSystemQuad::~ParticleSystemQuad() CC_SAFE_FREE(_quads); CC_SAFE_FREE(_indices); glDeleteBuffers(2, &_buffersVBO[0]); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); } @@ -355,7 +358,8 @@ void ParticleSystemQuad::draw() CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { // // Using VBO and VAO // @@ -371,7 +375,8 @@ void ParticleSystemQuad::draw() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #endif } - else { + else + { // // Using VBO without VAO // @@ -453,10 +458,12 @@ void ParticleSystemQuad::setTotalParticles(int tp) } initIndices(); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } } @@ -527,10 +534,12 @@ void ParticleSystemQuad::setupVBO() void ParticleSystemQuad::listenBackToForeground(Object *obj) { - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } } @@ -575,10 +584,12 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) allocMemory(); initIndices(); setTexture(oldBatch->getTexture()); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } } @@ -595,7 +606,8 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) glDeleteBuffers(2, &_buffersVBO[0]); memset(_buffersVBO, 0, sizeof(_buffersVBO)); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); _VAOname = 0; diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index cc29126f85..ec42b9dbfd 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -62,7 +62,8 @@ TextureAtlas::~TextureAtlas() glDeleteBuffers(2, _buffersVBO); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { glDeleteVertexArrays(1, &_VAOname); GL::bindVAO(0); } @@ -192,10 +193,12 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity) this->setupIndices(); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } @@ -206,10 +209,12 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity) void TextureAtlas::listenBackToForeground(Object *obj) { - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { setupVBOandVAO(); } - else { + else + { setupVBO(); } @@ -605,7 +610,8 @@ void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start) GL::bindTexture2D(_texture->getName()); - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { // // Using VBO and VAO // @@ -649,7 +655,8 @@ void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start) // glBindVertexArray(0); } - else { + else + { // // Using VBO without VAO // diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index 71a880c984..c4de9784b8 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/ccGLStateCache.cpp @@ -184,7 +184,8 @@ void deleteTextureN(GLuint textureUnit, GLuint textureId) void bindVAO(GLuint vaoId) { - if (Configuration::getInstance()->supportsShareableVAO()) { + if (Configuration::getInstance()->supportsShareableVAO()) + { #if CC_ENABLE_GL_STATE_CACHE if (s_uVAO != vaoId) From 42e7106b99909eac9dd8cfe50f0ec8bf7c0b9239 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Nov 2013 14:57:24 +0800 Subject: [PATCH 140/185] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index e857757e3c..e6bebcaae3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -597,6 +597,7 @@ Developers: bmanGH Use gl caching functions in TexturePVR::createGLTexture() + Configuration of VAO in runtime metadao make create_project.py more pythonic and fix some typoes From 39ec684ac8748365bcb95e6a7f9db310d75e9cf3 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Nov 2013 15:32:22 +0800 Subject: [PATCH 141/185] [ci skip] --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e06e8d0e37..c0f33125bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,13 +14,14 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] When parsing XML using TinyXML, the data size has to be specified. [FIX] Parameter type: const char* -> const string& [FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation + [FIX] Configuration of VAO in runtime + [FIX] Webp Test Crashes. [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support - [FIX] Webp Test Crashes. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From 17f74eeb170c559571440b866b837f44f9112612 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Wed, 13 Nov 2013 18:18:29 +0800 Subject: [PATCH 142/185] issue #2868:Modify armature test samples and add more armature test samples --- cocos/scripting/lua/bindings/CCLuaEngine.cpp | 6 +- .../lua_cocos2dx_coco_studio_manual.cpp | 2 + .../scripting/lua/script/StudioConstants.lua | 9 +- .../CocoStudioArmatureTest.lua | 1197 +++++++++++++++++ .../CocoStudioSceneTest.lua | 2 +- .../CocoStudioTest/CocoStudioTest.lua | 3 +- .../luaScript/ExtensionTest/ArmatureTest.lua | 742 ---------- .../luaScript/ExtensionTest/ExtensionTest.lua | 6 +- tools/tolua/cocos2dx_studio.ini | 2 +- 9 files changed, 1213 insertions(+), 756 deletions(-) create mode 100644 samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua delete mode 100644 samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ArmatureTest.lua diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index efb181178b..85f491032b 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.cpp +++ b/cocos/scripting/lua/bindings/CCLuaEngine.cpp @@ -877,7 +877,7 @@ int LuaEngine::handleArmatureWrapper(void* data) { LuaArmatureMovementEventData* movementData = static_cast(wrapperData->eventData); - _stack->pushObject(movementData->objTarget, "Object"); + _stack->pushObject(movementData->objTarget, "Armature"); _stack->pushInt(movementData->movementType); _stack->pushString(movementData->movementID.c_str()); _stack->executeFunctionByHandler(handler, 3); @@ -887,7 +887,7 @@ int LuaEngine::handleArmatureWrapper(void* data) { LuaArmatureFrameEventData* frameData = static_cast(wrapperData->eventData); - _stack->pushObject(frameData->objTarget, "Object"); + _stack->pushObject(frameData->objTarget, "Bone"); _stack->pushString(frameData->frameEventName.c_str()); _stack->pushInt(frameData->originFrameIndex); _stack->pushInt(frameData->currentFrameIndex); @@ -897,7 +897,7 @@ int LuaEngine::handleArmatureWrapper(void* data) case LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC: { _stack->pushFloat(*(float*)wrapperData->eventData); - _stack->executeFunctionByHandler(handler, 0); + _stack->executeFunctionByHandler(handler, 1); } break; default: diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 63396d5e9e..71e1e59a93 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -725,6 +725,7 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + self->setUserObject(wrapper); self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback)); return 0; @@ -780,6 +781,7 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + self->setUserObject(wrapper); self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback)); return 0; diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua index b98714dd1d..001ebe7341 100644 --- a/cocos/scripting/lua/script/StudioConstants.lua +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -1,8 +1,11 @@ ccs = ccs or {} -CC_MovementEventType_START = 0 -CC_MovementEventType_COMPLETE = 1 -CC_MovementEventType_LOOP_COMPLETE = 2 + +ccs.MovementEventType = { + START = 0, + COMPLETE = 1, + LOOP_COMPLETE = 2, +} ccs.BrightStyle = { diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua new file mode 100644 index 0000000000..feb1b19290 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -0,0 +1,1197 @@ +local itemTagBasic = 1000 +local armaturePerformanceTag = 20000 +local frameEventActionTag = 10000 +local winSize = cc.Director:getInstance():getWinSize() +local scheduler = cc.Director:getInstance():getScheduler() +local ArmatureTestIndex = +{ + TEST_ASYNCHRONOUS_LOADING = 1, + TEST_DIRECT_LOADING = 2, + TEST_COCOSTUDIO_WITH_SKELETON = 3, + TEST_DRAGON_BONES_2_0 = 4, + TEST_PERFORMANCE = 5, + TEST_PERFORMANCE_BATCHNODE = 6, + TEST_CHANGE_ZORDER = 7, + TEST_ANIMATION_EVENT = 8, + TEST_FRAME_EVENT = 9, + TEST_PARTICLE_DISPLAY = 10, + TEST_USE_DIFFERENT_PICTURE = 11, + TEST_ANCHORPOINT = 12, + TEST_ARMATURE_NESTING = 13, + TEST_ARMATURE_NESTING_2 = 14, +} +local armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING + +local ArmatureTestScene = class("ArmatureTestScene") +ArmatureTestScene.__index = ArmatureTestScene + +function ArmatureTestScene.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, ArmatureTestScene) + return target +end + +function ArmatureTestScene:runThisTest() + armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING + self:addChild(restartArmatureTest()) +end + +function ArmatureTestScene.create() + local scene = ArmatureTestScene.extend(cc.Scene:create()) + local bg = cc.Sprite:create("armature/bg.jpg") + bg:setPosition(VisibleRect:center()) + + local scaleX = VisibleRect:getVisibleRect().width / bg:getContentSize().width + local scaleY = VisibleRect:getVisibleRect().height / bg:getContentSize().height + + bg:setScaleX(scaleX) + bg:setScaleY(scaleY) + + scene:addChild(bg) + return scene +end + +function ArmatureTestScene.toMainMenuCallback() + ccs.ArmatureDataManager:purgeArmatureSystem() +end + +local ArmatureTestLayer = class("ArmatureTestLayer") +ArmatureTestLayer.__index = ArmatureTestLayer +ArmatureTestLayer._backItem = nil +ArmatureTestLayer._restarItem = nil +ArmatureTestLayer._nextItem = nil + +function ArmatureTestLayer:onEnter() + +end + +function ArmatureTestLayer.title(idx) + if ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING == idx then + return "Test Asynchronous Loading" + elseif ArmatureTestIndex.TEST_DIRECT_LOADING == idx then + return "Test Direct Loading" + elseif ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON == idx then + return "Test Export From CocoStudio With Skeleton Effect" + elseif ArmatureTestIndex.TEST_DRAGON_BONES_2_0 == idx then + return "Test Export From DragonBones version 2.0" + elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then + return "Test Performance" + elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then + return "Test Performance of using BatchNode" + elseif ArmatureTestIndex.TEST_CHANGE_ZORDER == idx then + return "Test Change ZOrder Of Different Armature" + elseif ArmatureTestIndex.TEST_ANIMATION_EVENT == idx then + return "Test Armature Animation Event" + elseif ArmatureTestIndex.TEST_FRAME_EVENT == idx then + return "Test Frame Event" + elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then + return "Test Particle Display" + elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then + return "Test One Armature Use Different Picture" + elseif ArmatureTestIndex.TEST_ANCHORPOINT == idx then + return "Test Set AnchorPoint" + elseif ArmatureTestIndex.TEST_ARMATURE_NESTING == idx then + return "Test Armature Nesting" + elseif ArmatureTestIndex.TEST_ARMATURE_NESTING_2 == idx then + return "Test Armature Nesting 2" + end +end + +function ArmatureTestLayer.subTitle(idx) + if ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING == idx then + return "current percent :" + elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then + return "Current Armature Count : " + elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then + return "Current Armature Count : " + elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then + return "Touch to change animation" + elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then + return "weapon and armature are in different picture" + elseif ArmatureTestIndex.TEST_ARMATURE_NESTING_2 == idx then + return "Move to a mount and press the ChangeMount Button." + else + return "" + end +end + +function ArmatureTestLayer.create() + local layer = ArmatureTestLayer.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +function ArmatureTestLayer.backCallback() + local newScene = ArmatureTestScene.create() + newScene:addChild(backArmatureTest()) + cc.Director:getInstance():replaceScene(newScene) +end + +function ArmatureTestLayer.restartCallback() + local newScene = ArmatureTestScene.create() + newScene:addChild(restartArmatureTest()) + cc.Director:getInstance():replaceScene(newScene) +end + +function ArmatureTestLayer.nextCallback() + local newScene = ArmatureTestScene.create() + newScene:addChild(nextArmatureTest()) + cc.Director:getInstance():replaceScene(newScene) +end + +function ArmatureTestLayer:createMenu() + local menu = cc.Menu:create() + + self._backItem = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) + self._backItem:registerScriptTapHandler(self.backCallback) + menu:addChild(self._backItem,itemTagBasic) + self._restarItem = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) + self._restarItem:registerScriptTapHandler(self.restartCallback) + menu:addChild(self._restarItem,itemTagBasic) + self._nextItem = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) + menu:addChild(self._nextItem,itemTagBasic) + self._nextItem:registerScriptTapHandler(self.nextCallback) + + local size = cc.Director:getInstance():getWinSize() + self._backItem:setPosition(cc.p(size.width / 2 - self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) + self._restarItem:setPosition(cc.p(size.width / 2, self._restarItem:getContentSize().height / 2)) + self._nextItem:setPosition(cc.p(size.width / 2 + self._restarItem:getContentSize().width * 2, self._restarItem:getContentSize().height / 2)) + + menu:setPosition(cc.p(0, 0)) + + self:addChild(menu) +end + +function ArmatureTestLayer.toExtensionMenu() + ccs.ArmatureDataManager:destoryInstance() + local scene = CocoStudioTestMain() + if scene ~= nil then + cc.Director:getInstance():replaceScene(scene) + end +end + +function ArmatureTestLayer:createToExtensionMenu() + cc.MenuItemFont:setFontName("Arial") + cc.MenuItemFont:setFontSize(24) + local menuItemFont = cc.MenuItemFont:create("Back") + menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + menuItemFont:registerScriptTapHandler(ArmatureTestLayer.toExtensionMenu) + + local backMenu = cc.Menu:create() + backMenu:addChild(menuItemFont) + backMenu:setPosition(cc.p(0, 0)) + self:addChild(backMenu,10) +end + +function ArmatureTestLayer:creatTitleAndSubTitle(idx) + local title = cc.LabelTTF:create(ArmatureTestLayer.title(idx),"Arial",18) + title:setColor(cc.c3b(0,0,0)) + self:addChild(title, 1, 10000) + title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) + local subTitle = nil + if "" ~= ArmatureTestLayer.subTitle(idx) then + local subTitle = cc.LabelTTF:create(ArmatureTestLayer.subTitle(idx), "Arial", 18) + subTitle:setColor(cc.c3b(0,0,0)) + self:addChild(subTitle, 1, 10001) + subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) + end +end + +local TestAsynchronousLoading = class("TestAsynchronousLoading",ArmatureTestLayer) +TestAsynchronousLoading.__index = TestAsynchronousLoading + +function TestAsynchronousLoading.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestAsynchronousLoading) + return target +end + +function TestAsynchronousLoading:onEnter() + self._backItem:setEnabled(false) + self._restarItem:setEnabled(false) + self._nextItem:setEnabled(false) + + local title = cc.LabelTTF:create(ArmatureTestLayer.title(1),"Arial",18) + title:setColor(cc.c3b(0,0,0)) + self:addChild(title, 1, 10000) + title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) + local subTitle = nil + if "" ~= ArmatureTestLayer.subTitle(1) then + local subInfo = ArmatureTestLayer.subTitle(1) .. 0.0 + local subTitle = cc.LabelTTF:create(subInfo, "Arial", 18) + subTitle:setColor(cc.c3b(0,0,0)) + self:addChild(subTitle, 1, 10001) + subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) + end + + local function dataLoaded(percent) + local label = self:getChildByTag(10001) + if nil ~= label then + local subInfo = ArmatureTestLayer.subTitle(1) .. (percent * 100) + label:setString(subInfo) + end + if percent >= 1 and nil ~= self._backItem and nil ~= self._restarItem and nil ~= self._nextItem then + self._backItem:setEnabled(true) + self._restarItem:setEnabled(true) + self._nextItem:setEnabled(true) + end + end + + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/knight.png", "armature/knight.plist", "armature/knight.xml", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/weapon.png", "armature/weapon.plist", "armature/weapon.xml", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/robot.png", "armature/robot.plist", "armature/robot.xml", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/Cowboy.ExportJson", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/hero.ExportJson", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/horse.ExportJson", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/bear.ExportJson", dataLoaded) + ccs.ArmatureDataManager:getInstance():addArmatureFileInfoAsync("armature/HeroAnimation.ExportJson", dataLoaded) + +end + +function TestAsynchronousLoading.restartCallback() + ccs.ArmatureDataManager:destoryInstance() + local newScene = ArmatureTestScene.create() + newScene:addChild(restartArmatureTest()) + cc.Director:getInstance():replaceScene(newScene) +end + +function TestAsynchronousLoading.create() + local layer = TestAsynchronousLoading.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + end + + return layer +end + +local TestDirectLoading = class("TestDirectLoading",ArmatureTestLayer) +TestDirectLoading.__index = TestDirectLoading + +function TestDirectLoading.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestDirectLoading) + return target +end + +function TestDirectLoading:onEnter() + ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("armature/bear.ExportJson") + ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/bear.ExportJson") + local armature = ccs.Armature:create("bear") + armature:getAnimation():playByIndex(0) + armature:setPosition(cc.p(VisibleRect:center())) + self:addChild(armature) +end + +function TestDirectLoading.create() + local layer = TestDirectLoading.extend(cc.Layer:create()) + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + return layer +end + + +local TestCSWithSkeleton = class("TestCSWithSkeleton",ArmatureTestLayer) +TestCSWithSkeleton.__index = TestCSWithSkeleton + +function TestCSWithSkeleton.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestCSWithSkeleton) + return target +end + +function TestCSWithSkeleton:onEnter() + local armature = ccs.Armature:create("Cowboy") + armature:getAnimation():playByIndex(0) + armature:setScale(0.2) + armature:setAnchorPoint(cc.p(0.5, 0.5)) + armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) + self:addChild(armature) +end + +function TestCSWithSkeleton.create() + local layer = TestCSWithSkeleton.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +local TestDragonBones20 = class("TestDragonBones20",ArmatureTestLayer) +TestDragonBones20.__index = TestDragonBones20 + +function TestDragonBones20.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestDragonBones20) + return target +end + +function TestDragonBones20:onEnter() + local armature = ccs.Armature:create("Dragon") + armature:getAnimation():playByIndex(1) + armature:getAnimation():setSpeedScale(0.4) + armature:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y * 0.3)) + armature:setScale(0.6) + self:addChild(armature) +end + +function TestDragonBones20.create() + local layer = TestDragonBones20.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + return layer +end + +local TestPerformance = class("TestPerformance",ArmatureTestLayer) +TestPerformance.__index = TestPerformance +TestPerformance._armatureCount = 0 +TestPerformance._frames = 0 +TestPerformance._times = 0 +TestPerformance._lastTimes = 0 +TestPerformance._generated = false + +function TestPerformance.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestPerformance) + return target +end + +function TestPerformance:refreshTitile() + local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount + local label = tolua.cast(self:getChildByTag(10001),"LabelTTF") + label:setString(subTitleInfo) +end + +function TestPerformance:addArmatureToParent(armature) + self:addChild(armature, 0, armaturePerformanceTag + self._armatureCount) +end + +function TestPerformance:removeArmatureFromParent(tag) + self:removeChildByTag(armaturePerformanceTag + self._armatureCount, true) +end + +function TestPerformance:addArmature(num) + for i = 1, num do + self._armatureCount = self._armatureCount + 1 + local armature = ccs.Armature:create("Knight_f/Knight") + armature:getAnimation():playByIndex(0) + armature:setPosition(50 + self._armatureCount * 2, 150) + armature:setScale(0.6) + self:addArmatureToParent(armature) + end + + self:refreshTitile() +end + +function TestPerformance:onEnter() + + local function onIncrease(sender) + self:addArmature(20) + end + + local function onDecrease(sender) + if self._armatureCount == 0 then + return + end + + for i = 1, 20 do + self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) + self._armatureCount = self._armatureCount - 1 + self:refreshTitile() + end + end + + cc.MenuItemFont:setFontSize(65) + local decrease = cc.MenuItemFont:create(" - ") + decrease:setColor(cc.c3b(0,200,20)) + decrease:registerScriptTapHandler(onDecrease) + + local increase = cc.MenuItemFont:create(" + ") + increase:setColor(cc.c3b(0,200,20)) + increase:registerScriptTapHandler(onIncrease) + + local menu = cc.Menu:create(decrease, increase ) + menu:alignItemsHorizontally() + menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) + self:addChild(menu, 10000) + + self._armatureCount = 0 + self._frames = 0 + self._times = 0 + self._lastTimes = 0 + self._generated = false + + self:addArmature(100) +end + +function TestPerformance.create() + local layer = TestPerformance.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:creatTitleAndSubTitle(armatureSceneIdx) + layer:onEnter() + end + return layer +end + +local TestPerformanceBatchNode = class("TestPerformanceBatchNode",TestPerformance) +TestPerformanceBatchNode.__index = TestPerformanceBatchNode +TestPerformanceBatchNode._batchNode = nil + +function TestPerformanceBatchNode.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestPerformanceBatchNode) + return target +end + +function TestPerformanceBatchNode:addArmatureToParent(armature) + self._batchNode:addChild(armature, 0, armaturePerformanceTag + self._armatureCount) +end + +function TestPerformanceBatchNode:removeArmatureFromParent(tag) + self._batchNode:removeChildByTag(armaturePerformanceTag + self._armatureCount, true) +end + +function TestPerformanceBatchNode:onEnter() + self._batchNode = ccs.BatchNode:create() + self:addChild(self._batchNode) + + local function onIncrease(sender) + self:addArmature(20) + end + + local function onDecrease(sender) + if self._armatureCount == 0 then + return + end + + for i = 1, 20 do + self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount) + self._armatureCount = self._armatureCount - 1 + self:refreshTitile() + end + end + + cc.MenuItemFont:setFontSize(65) + local decrease = cc.MenuItemFont:create(" - ") + decrease:setColor(cc.c3b(0,200,20)) + decrease:registerScriptTapHandler(onDecrease) + + local increase = cc.MenuItemFont:create(" + ") + increase:setColor(cc.c3b(0,200,20)) + increase:registerScriptTapHandler(onIncrease) + + local menu = cc.Menu:create(decrease, increase ) + menu:alignItemsHorizontally() + menu:setPosition(cc.p(VisibleRect:getVisibleRect().width/2, VisibleRect:getVisibleRect().height-100)) + self:addChild(menu, 10000) + + self._armatureCount = 0 + self._frames = 0 + self._times = 0 + self._lastTimes = 0 + self._generated = false + + self:addArmature(100) +end + +function TestPerformanceBatchNode.create() + local layer = TestPerformanceBatchNode.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:creatTitleAndSubTitle(armatureSceneIdx) + layer:onEnter() + end + return layer +end + +local TestChangeZorder = class("TestChangeZorder",ArmatureTestLayer) +TestChangeZorder.__index = TestChangeZorder +TestChangeZorder.currentTag = -1 + +function TestChangeZorder.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestChangeZorder) + return target +end + +function TestChangeZorder:onEnter() + self.currentTag = -1 + + local armature = ccs.Armature:create("Knight_f/Knight") + armature:getAnimation():playByIndex(0) + armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 )) + armature:setScale(0.6) + self.currentTag = self.currentTag + 1 + self:addChild(armature, self.currentTag, self.currentTag) + + armature = ccs.Armature:create("Cowboy") + armature:getAnimation():playByIndex(0) + armature:setScale(0.24) + armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) + self.currentTag = self.currentTag + 1 + self:addChild(armature, self.currentTag, self.currentTag) + + armature = ccs.Armature:create("Dragon") + armature:getAnimation():playByIndex(0) + armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) + armature:setScale(0.6) + self.currentTag = self.currentTag + 1 + self:addChild(armature, self.currentTag, self.currentTag) + + local function changeZorder(dt) + local node = self:getChildByTag(self.currentTag) + node:setZOrder(math.random(0,1) * 3) + self.currentTag = (self.currentTag + 1) % 3 + end + + schedule(self,changeZorder, 1) +end + +function TestChangeZorder.create() + local layer = TestChangeZorder.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + return layer +end + +--UNDO callback +local TestAnimationEvent = class("TestAnimationEvent",ArmatureTestLayer) +TestAnimationEvent.__index = TestAnimationEvent + +function TestAnimationEvent.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestAnimationEvent) + return target +end + +function TestAnimationEvent:onEnter() + local armature = ccs.Armature:create("Cowboy") + armature:getAnimation():play("Fire") + armature:setScaleX(-0.24) + armature:setScaleY(0.24) + armature:setPosition(cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) + + local function callback1() + armature:runAction(cc.ScaleTo:create(0.3, 0.24, 0.24)) + armature:getAnimation():play("FireMax", 10) + end + + local function callback2() + armature:runAction(cc.ScaleTo:create(0.3, -0.24, 0.24)) + armature:getAnimation():play("Fire", 10) + end + + local function animationEvent(armatureBack,movementType,movementID) + local id = movementID + if movementType == ccs.MovementEventType.LOOP_COMPLETE then + if id == "Fire" then + local actionToRight = cc.MoveTo:create(2, cc.p(VisibleRect:right().x - 50, VisibleRect:right().y)) + armatureBack:stopAllActions() + armatureBack:runAction(cc.Sequence:create(actionToRight,cc.CallFunc:create(callback1))) + armatureBack:getAnimation():play("Walk") + elseif id == "FireMax" then + local actionToLeft = cc.MoveTo:create(2, cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) + armatureBack:stopAllActions() + armatureBack:runAction(cc.Sequence:create(actionToLeft, cc.CallFunc:create(callback2))) + armatureBack:getAnimation():play("Walk") + end + end + end + + armature:getAnimation():setMovementEventCallFunc(animationEvent) + + self:addChild(armature) +end + +function TestAnimationEvent.create() + local layer = TestAnimationEvent.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + return layer +end + +local TestFrameEvent = class("TestFrameEvent",ArmatureTestLayer) +TestFrameEvent.__index = TestFrameEvent + +function TestFrameEvent.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestFrameEvent) + return target +end + +function TestFrameEvent:onEnter() + local armature = ccs.Armature:create("HeroAnimation") + armature:getAnimation():play("attack") + armature:getAnimation():setSpeedScale(0.5) + armature:setPosition(cc.p(VisibleRect:center().x - 50, VisibleRect:center().y -100)) + + local function onFrameEvent( bone,evt,originFrameIndex,currentFrameIndex) + if (not self:getActionByTag(frameEventActionTag)) or (not self:getActionByTag(frameEventActionTag):isDone()) then + self:stopAllActions() + local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) + action:setTag(frameEventActionTag) + self:runAction(action) + end + end + + armature:getAnimation():setFrameEventCallFunc(onFrameEvent) + + self:addChild(armature) + + local function checkAction(dt) + if self:getNumberOfRunningActions() == 0 and self:getGrid() ~= nil then + self:setGrid(nil) + end + end + + self:scheduleUpdateWithPriorityLua(checkAction,0) + + local function onNodeEvent(tag) + if "exit" == tag then + self:unscheduleUpdate() + end + end +end + +function TestFrameEvent.create() + local layer = TestFrameEvent.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:creatTitleAndSubTitle(armatureSceneIdx) + layer:onEnter() + end + return layer +end + +local TestParticleDisplay = class("TestParticleDisplay",ArmatureTestLayer) +TestParticleDisplay.__index = TestParticleDisplay +TestParticleDisplay.animationID = 0 +TestParticleDisplay.armature = nil + +function TestParticleDisplay.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestParticleDisplay) + return target +end + +function TestParticleDisplay:onEnter() + self:setTouchEnabled(true) + self.animationID = 0 + + self.armature = ccs.Armature:create("robot") + self.armature:getAnimation():playByIndex(0) + self.armature:setPosition(VisibleRect:center()) + self.armature:setScale(0.48) + self:addChild(self.armature) + + local p1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + local p2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") + + local bone = ccs.Bone:create("p1") + bone:addDisplay(p1, 0) + bone:changeDisplayByIndex(0, true) + bone:setIgnoreMovementBoneData(true) + bone:setZOrder(100) + bone:setScale(1.2) + self.armature:addBone(bone, "bady-a3") + + bone = ccs.Bone:create("p2") + bone:addDisplay(p2, 0) + bone:changeDisplayByIndex(0, true) + bone:setIgnoreMovementBoneData(true) + bone:setZOrder(100) + bone:setScale(1.2) + self.armature:addBone(bone, "bady-a30") + + local function onTouchBegan(x, y) + self.animationID = (self.animationID + 1) % self.armature:getAnimation():getMovementCount() + self.armature:getAnimation():playByIndex(self.animationID) + return false + end + + local function onTouch(eventType, x, y) + if eventType == "began" then + return onTouchBegan(x,y) + end + end + + self:registerScriptTouchHandler(onTouch) +end + +function TestParticleDisplay.create() + local layer = TestParticleDisplay.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +local TestUseMutiplePicture = class("TestUseMutiplePicture",ArmatureTestLayer) +TestUseMutiplePicture.__index = TestUseMutiplePicture +TestUseMutiplePicture.displayIndex = 0 +TestUseMutiplePicture.armature = nil + +function TestUseMutiplePicture.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestUseMutiplePicture) + return target +end + +function TestUseMutiplePicture:onEnter() + self:setTouchEnabled(true) + self.displayIndex = 1 + + self.armature = ccs.Armature:create("Knight_f/Knight") + self.armature:getAnimation():playByIndex(0) + self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y)) + self.armature:setScale(1.2) + self:addChild(self.armature) + + local weapon = + { + "weapon_f-sword.png", + "weapon_f-sword2.png", + "weapon_f-sword3.png", + "weapon_f-sword4.png", + "weapon_f-sword5.png", + "weapon_f-knife.png", + "weapon_f-hammer.png", + } + + local i = 1 + for i = 1,table.getn(weapon) do + local skin = ccs.Skin:createWithSpriteFrameName(weapon[i]) + self.armature:getBone("weapon"):addDisplay(skin, i - 1) + end + + local function onTouchBegan(x, y) + self.displayIndex = (self.displayIndex + 1) % (table.getn(weapon) - 1) + self.armature:getBone("weapon"):changeDisplayByIndex(self.displayIndex, true) + return false + end + + local function onTouch(eventType, x, y) + if eventType == "began" then + return onTouchBegan(x,y) + end + end + + self:registerScriptTouchHandler(onTouch) +end + +function TestUseMutiplePicture.create() + local layer = TestUseMutiplePicture.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +local TestAnchorPoint = class("TestAnchorPoint",ArmatureTestLayer) +TestAnchorPoint.__index = TestAnchorPoint + +function TestAnchorPoint.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestAnchorPoint) + return target +end + +function TestAnchorPoint:onEnter() + local i = 1 + for i = 1 , 5 do + local armature = ccs.Armature:create("Cowboy") + armature:getAnimation():playByIndex(0) + armature:setPosition(VisibleRect:center()) + armature:setScale(0.2) + self:addChild(armature, 0, i - 1) + end + + self:getChildByTag(0):setAnchorPoint(cc.p(0,0)) + self:getChildByTag(1):setAnchorPoint(cc.p(0,1)) + self:getChildByTag(2):setAnchorPoint(cc.p(1,0)) + self:getChildByTag(3):setAnchorPoint(cc.p(1,1)) + self:getChildByTag(4):setAnchorPoint(cc.p(0.5,0.5)) +end + +function TestAnchorPoint.create() + local layer = TestAnchorPoint.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +local TestArmatureNesting = class("TestArmatureNesting",ArmatureTestLayer) +TestArmatureNesting.__index = TestArmatureNesting +TestArmatureNesting.weaponIndex = 0 +TestArmatureNesting.armature = nil + +function TestArmatureNesting.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestArmatureNesting) + return target +end + +function TestArmatureNesting:onEnter() + self:setTouchEnabled(true) + self.weaponIndex = 0 + + self.armature = ccs.Armature:create("cyborg") + self.armature:getAnimation():playByIndex(1) + self.armature:setPosition(VisibleRect:center()) + self.armature:setScale(1.2) + self.armature:getAnimation():setSpeedScale(0.4) + self:addChild(self.armature) + + local function onTouchBegan(x, y) + self.weaponIndex = (self.weaponIndex + 1) % 4 + self.armature:getBone("armInside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) + self.armature:getBone("armOutside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) + return false + end + + local function onTouch(eventType, x, y) + if eventType == "began" then + return onTouchBegan(x,y) + end + end + + self:registerScriptTouchHandler(onTouch) +end + +function TestArmatureNesting.create() + local layer = TestArmatureNesting.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:onEnter() + layer:creatTitleAndSubTitle(armatureSceneIdx) + end + + return layer +end + +local Hero = class("Hero") +Hero.__index = Hero +Hero._mount = nil +Hero._layer = nil + +function Hero.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, Hero) + return target +end + +function Hero:changeMount(armature) + if nil == armature then + --note + self:retain() + + self:playByIndex(0) + self._mount:getBone("hero"):removeDisplay(0) + self._mount:stopAllActions() + self:setPosition(self._mount:getPosition()) + self._layer:addChild(self) + self:release() + self._mount = armature + else + self._mount = armature + self:retain() + self:removeFromParentAndCleanup(false) + local bone = armature:getBone("hero") + bone:addDisplay(self, 0) + bone:changeDisplayByIndex(0, true) + bone:setIgnoreMovementBoneData(true) + self:setPosition(cc.p(0,0)) + self:playByIndex(1) + self:setScale(1) + self:release() + end +end + +function Hero:playByIndex(index) + self:getAnimation():playByIndex(index) + if nil ~= self._mount then + self._mount:getAnimation():playByIndex(index) + end +end + +function Hero.create(name) + local hero = Hero.extend(ccs.Armature:create(name)) + return hero +end + + + +local TestArmatureNesting2 = class("TestArmatureNesting",ArmatureTestLayer) +TestArmatureNesting2.__index = TestArmatureNesting2 +TestArmatureNesting2._hero = nil +TestArmatureNesting2._horse = nil +TestArmatureNesting2._horse2 = nil +TestArmatureNesting2._bear = nil +TestArmatureNesting2._touchedMenu = nil + +function TestArmatureNesting2.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TestArmatureNesting2) + return target +end + +function TestArmatureNesting2:onEnter() + + self:setTouchEnabled(true) + + local function onTouchesEnded(tableArray) + local x,y = tableArray[1],tableArray[2] + local armature = self._hero._mount and self._hero._mount or self._hero + if x < armature:getPositionX() then + armature:setScaleX(-1) + else + armature:setScaleX(1) + end + + local move = cc.MoveTo:create(2, cc.p(x,y)) + armature:stopAllActions() + armature:runAction(cc.Sequence:create(move)) + end + + local function onTouch(eventType, tableArray) + if eventType == "ended" then + return onTouchesEnded(tableArray) + end + end + + self:registerScriptTouchHandler(onTouch,true) + + local function changeMountCallback(sender) + self._hero:stopAllActions() + + if nil ~= self._hero._mount then + self._hero:changeMount(nil) + else + if cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._horse:getPosition())) < 20 then + self._hero:changeMount(self._horse) + elseif cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._horse2:getPosition())) < 20 then + self._hero:changeMount(self._horse2) + elseif cc.pGetDistance(cc.p(self._hero:getPosition()),cc.p(self._bear:getPosition())) < 30 then + self._hero:changeMount(self._bear) + end + end + end + + self._touchedMenu = false + local label = cc.LabelTTF:create("Change Mount", "Arial", 20) + local menuItem = cc.MenuItemLabel:create(label) + menuItem:registerScriptTapHandler(changeMountCallback) + local menu = cc.Menu:create(menuItem) + menu:setPosition(cc.p(0,0)) + menuItem:setPosition( cc.p( VisibleRect:right().x - 67, VisibleRect:bottom().y + 50) ) + self:addChild(menu, 2) + + self._hero = Hero.create("hero") + self._hero._layer = self + self._hero:playByIndex(0) + self._hero:setPosition(cc.p(VisibleRect:left().x + 20, VisibleRect:left().y)) + self:addChild(self._hero) + + self._horse = self:createMount("horse", VisibleRect:center()) + + self._horse2 = self:createMount("horse", cc.p(120, 200)) + self._horse2:setOpacity(200) + + self._bear = self:createMount("bear", cc.p(300,70)) +end + +function TestArmatureNesting2:createMount(name,pt) + local armature = ccs.Armature:create(name) + armature:getAnimation():playByIndex(0) + armature:setPosition(pt) + self:addChild(armature) + return armature +end + +function TestArmatureNesting2.create() + local layer = TestArmatureNesting2.extend(cc.Layer:create()) + + if nil ~= layer then + layer:createMenu() + layer:createToExtensionMenu() + layer:creatTitleAndSubTitle(armatureSceneIdx) + layer:onEnter() + end + + return layer +end + + +local armatureSceneArr = +{ + TestAsynchronousLoading.create, + TestDirectLoading.create, + TestCSWithSkeleton.create, + TestDragonBones20.create, + TestPerformance.create, + TestPerformanceBatchNode.create, + TestChangeZorder.create, + TestAnimationEvent.create, + TestFrameEvent.create, + TestParticleDisplay.create, + TestUseMutiplePicture.create, + TestAnchorPoint.create, + TestArmatureNesting.create, + TestArmatureNesting2.create, +} + +function nextArmatureTest() + armatureSceneIdx = armatureSceneIdx + 1 + armatureSceneIdx = armatureSceneIdx % table.getn(armatureSceneArr) + if 0 == armatureSceneIdx then + armatureSceneIdx = table.getn(armatureSceneArr) + end + return armatureSceneArr[armatureSceneIdx]() +end + +function backArmatureTest() + armatureSceneIdx = armatureSceneIdx - 1 + if armatureSceneIdx <= 0 then + armatureSceneIdx = armatureSceneIdx + table.getn(armatureSceneArr) + end + + return armatureSceneArr[armatureSceneIdx]() +end + +function restartArmatureTest() + return armatureSceneArr[armatureSceneIdx]() +end + +local function addFileInfo() + +end + +function runArmatureTestScene() + local scene = ArmatureTestScene.create() + scene:runThisTest() + cc.Director:getInstance():replaceScene(scene) +end diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index a1679ee671..fe46748cf0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -48,7 +48,7 @@ end function SceneEditorTestLayer.create() local scene = cc.Scene:create() local layer = SceneEditorTestLayer.extend(cc.LayerColor:create()) - --layer:initWithColor(cc.c4b(0,0,0,255)) + layer:initWithColor(cc.c4b(0,0,0,255)) layer:addChild(layer:createGameScene(), 0, 1) scene:addChild(layer) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua index 2c2e355870..fdc95dae89 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua @@ -1,5 +1,6 @@ require "luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest" require "luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest" +require "luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest" local LINE_SPACE = 40 local ITEM_TAG_BASIC = 1000 @@ -9,7 +10,7 @@ local cocoStudioTestItemNames = { itemTitle = "CocoStudioArmatureTest", testScene = function () - --runArmatureTestScene() + runArmatureTestScene() end }, { diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ArmatureTest.lua deleted file mode 100644 index 446854de11..0000000000 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ArmatureTest.lua +++ /dev/null @@ -1,742 +0,0 @@ -local itemTagBasic = 1000 -local winSize = cc.Director:getInstance():getWinSize() -local scheduler = cc.Director:getInstance():getScheduler() -local ArmatureTestIndex = -{ - TEST_COCOSTUDIO_WITH_SKELETON = 1, - TEST_DRAGON_BONES_2_0 = 2, - TEST_PERFORMANCE = 3, - TEST_CHANGE_ZORDER = 4, - TEST_ANIMATION_EVENT = 5, - TEST_PARTICLE_DISPLAY = 6, - TEST_USE_DIFFERENT_PICTURE = 7, - TEST_BOUDINGBOX = 8, - TEST_ANCHORPOINT = 9, - TEST_ARMATURE_NESTING = 10, -} -local armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON - -local ArmatureTestScene = class("ArmatureTestScene") -ArmatureTestScene.__index = ArmatureTestScene - -function ArmatureTestScene.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, ArmatureTestScene) - return target -end - -function ArmatureTestScene:runThisTest() - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/TestBone0.png", "armature/TestBone0.plist", "armature/TestBone.json") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Cowboy0.png", "armature/Cowboy0.plist", "armature/Cowboy.ExportJson") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/knight.png", "armature/knight.plist", "armature/knight.xml") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/weapon.png", "armature/weapon.plist", "armature/weapon.xml") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/robot.png", "armature/robot.plist", "armature/robot.xml") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml") - ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml") - - armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON - self:addChild(restartArmatureTest()) -end - -function ArmatureTestScene.create() - local scene = ArmatureTestScene.extend(cc.Scene:create()) - local bg = cc.Sprite:create("armature/bg.jpg") - bg:setPosition(VisibleRect:center()) - - local scaleX = VisibleRect:getVisibleRect().width / bg:getContentSize().width - local scaleY = VisibleRect:getVisibleRect().height / bg:getContentSize().height - - bg:setScaleX(scaleX) - bg:setScaleY(scaleY) - - scene:addChild(bg) - return scene -end - -function ArmatureTestScene.toMainMenuCallback() - ccs.ArmatureDataManager:purgeArmatureSystem() -end - -local ArmatureTestLayer = class("ArmatureTestLayer") -ArmatureTestLayer.__index = ArmatureTestLayer - -function ArmatureTestLayer:onEnter() - -end - -function ArmatureTestLayer.title(idx) - if ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON == idx then - return "Test Export From CocoStudio With Skeleton Effect" - elseif ArmatureTestIndex.TEST_DRAGON_BONES_2_0 == idx then - return "Test Export From DragonBones version 2.0" - elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then - return "Test Performance" - elseif ArmatureTestIndex.TEST_CHANGE_ZORDER == idx then - return "Test Change ZOrder Of Different Armature" - elseif ArmatureTestIndex.TEST_ANIMATION_EVENT == idx then - return "Test Armature Animation Event" - elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then - return "Test Particle Display" - elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then - return "Test One Armature Use Different Picture" - elseif ArmatureTestIndex.TEST_BOUDINGBOX == idx then - return "Test BoundingBox" - elseif ArmatureTestIndex.TEST_ANCHORPOINT == idx then - return "Test Set AnchorPoint" - elseif ArmatureTestIndex.TEST_ARMATURE_NESTING == idx then - return "Test Armature Nesting" - end -end - -function ArmatureTestLayer.subTitle(idx) - if ArmatureTestIndex.TEST_PERFORMANCE == idx then - return "Current Armature Count : " - elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then - return "Touch to change animation" - elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then - return "weapon and armature are in different picture" - else - return "" - end -end - -function ArmatureTestLayer.create() - local layer = ArmatureTestLayer.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -function ArmatureTestLayer.backCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(backArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer.restartCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(restartArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer.nextCallback() - local newScene = ArmatureTestScene.create() - newScene:addChild(nextArmatureTest()) - cc.Director:getInstance():replaceScene(newScene) -end - -function ArmatureTestLayer:createMenu() - local menu = cc.Menu:create() - - local item1 = cc.MenuItemImage:create(s_pPathB1, s_pPathB2) - item1:registerScriptTapHandler(self.backCallback) - menu:addChild(item1,itemTagBasic) - local item2 = cc.MenuItemImage:create(s_pPathR1, s_pPathR2) - item2:registerScriptTapHandler(self.restartCallback) - menu:addChild(item2,itemTagBasic) - local item3 = cc.MenuItemImage:create(s_pPathF1, s_pPathF2) - menu:addChild(item3,itemTagBasic) - item3:registerScriptTapHandler(self.nextCallback) - - local size = cc.Director:getInstance():getWinSize() - item1:setPosition(cc.p(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(cc.p(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(cc.p(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - - menu:setPosition(cc.p(0, 0)) - - self:addChild(menu) -end - -function ArmatureTestLayer.toExtensionMenu() - local scene = ExtensionsTestMain() - if scene ~= nil then - cc.Director:getInstance():replaceScene(scene) - end -end - -function ArmatureTestLayer:createToExtensionMenu() - cc.MenuItemFont:setFontName("Arial") - cc.MenuItemFont:setFontSize(24) - local menuItemFont = cc.MenuItemFont:create("Back") - menuItemFont:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) - menuItemFont:registerScriptTapHandler(ArmatureTestLayer.toExtensionMenu) - - local backMenu = cc.Menu:create() - backMenu:addChild(menuItemFont) - backMenu:setPosition(cc.p(0, 0)) - self:addChild(backMenu,10) -end - -function ArmatureTestLayer:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(idx),"Arial",18) - title:setColor(cc.c3b(0,0,0)) - self:addChild(title, 1, 10000) - title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) - local subTitle = nil - if "" ~= ArmatureTestLayer.subTitle(idx) then - local subTitle = cc.LabelTTF:create(ArmatureTestLayer.subTitle(idx), "Arial", 18) - subTitle:setColor(cc.c3b(0,0,0)) - self:addChild(subTitle, 1, 10001) - subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) - end -end - -local TestCSWithSkeleton = class("TestCSWithSkeleton",ArmatureTestLayer) -TestCSWithSkeleton.__index = TestCSWithSkeleton - -function TestCSWithSkeleton.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestCSWithSkeleton) - return target -end - -function TestCSWithSkeleton:onEnter() - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) - armature:setScale(0.2) - armature:setAnchorPoint(cc.p(0.5, 0.5)) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) - self:addChild(armature) -end - -function TestCSWithSkeleton.create() - local layer = TestCSWithSkeleton.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestDragonBones20 = class("TestDragonBones20",ArmatureTestLayer) -TestDragonBones20.__index = TestDragonBones20 - -function TestDragonBones20.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestDragonBones20) - return target -end - -function TestDragonBones20:onEnter() - local armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(1) - armature:getAnimation():setAnimationScale(0.4) - armature:setScale(0.6) - armature:setAnchorPoint(cc.p(0.5, 0.5)) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) - self:addChild(armature) -end - -function TestDragonBones20.create() - local layer = TestDragonBones20.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer -end - -local TestPerformance = class("TestPerformance",ArmatureTestLayer) -TestPerformance.__index = TestPerformance -TestPerformance.armatureCount = 0 -TestPerformance.times = 0 -TestPerformance.testPerformanceEntry = 0 -TestPerformance.selfLayer = nil - -function TestPerformance.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestPerformance) - return target -end - -function TestPerformance.update(delta) - TestPerformance.times = TestPerformance.times + delta - if TestPerformance.times > 0.25 then - TestPerformance.time = 0 - local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) - armature:setPosition(cc.p(50 + TestPerformance.armatureCount * 5, winSize.height / 2)) - armature:setScale(0.6) - TestPerformance.armatureCount = TestPerformance.armatureCount + 1 - TestPerformance.selfLayer:addChild(armature,TestPerformance.armatureCount) - - local subTitle = tolua.cast(TestPerformance.selfLayer:getChildByTag(10001),"LabelTTF") - if nil ~= subTitle then - local info = ArmatureTestLayer.subTitle(ArmatureTestIndex.TEST_PERFORMANCE) .. TestPerformance.armatureCount - subTitle:setString(info) - end - end -end - -function TestPerformance.onEnterOrExit(tag) - if tag == "enter" then - TestPerformance.testPerformanceEntry = scheduler:scheduleScriptFunc(TestPerformance.update, 0.0, false) - elseif tag == "exit" then - scheduler:unscheduleScriptEntry(TestPerformance.testPerformanceEntry) - end -end - -function TestPerformance:onEnter() - TestPerformance.armatureCount = 0 - TestPerformance.times = 0 - TestPerformance.selfLayer = nil - self:registerScriptHandler(self.onEnterOrExit) -end - -function TestPerformance.create() - local layer = TestPerformance.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - TestPerformance.selfLayer = layer - end - return layer -end - -local TestChangeZorder = class("TestChangeZorder",ArmatureTestLayer) -TestChangeZorder.__index = TestChangeZorder -TestChangeZorder.currentTag = -1 - -function TestChangeZorder.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestChangeZorder) - return target -end - -function TestChangeZorder:onEnter() - self.currentTag = -1 - - local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 )) - armature:setScale(0.6) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) - armature:setScale(0.24) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(0) - armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) - armature:setScale(0.6) - self.currentTag = self.currentTag + 1 - self:addChild(armature, self.currentTag, self.currentTag) - - local function changeZorder(dt) - local node = self:getChildByTag(self.currentTag) - node:setZOrder(math.random(0,1) * 3) - self.currentTag = (self.currentTag + 1) % 3 - end - - schedule(self,changeZorder, 1) -end - -function TestChangeZorder.create() - local layer = TestChangeZorder.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer -end - ---UNDO callback -local TestAnimationEvent = class("TestAnimationEvent",ArmatureTestLayer) -TestAnimationEvent.__index = TestAnimationEvent - -function TestAnimationEvent.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestAnimationEvent) - return target -end - -function TestAnimationEvent:onEnter() - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():play("Fire") - armature:setScaleX(-0.24) - armature:setScaleY(0.24) - armature:setPosition(cc.p(VisibleRect:left().x + 50, VisibleRect:left().y)) - --armature:getAnimation()->MovementEventSignal.connect(this, &TestAnimationEvent::animationEvent) - self:addChild(armature) -end - -function TestAnimationEvent.create() - local layer = TestAnimationEvent.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - return layer -end - -local TestParticleDisplay = class("TestParticleDisplay",ArmatureTestLayer) -TestParticleDisplay.__index = TestParticleDisplay -TestParticleDisplay.animationID = 0 -TestParticleDisplay.armature = nil - -function TestParticleDisplay.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestParticleDisplay) - return target -end - -function TestParticleDisplay:onEnter() - self:setTouchEnabled(true) - self.animationID = 0 - - self.armature = ccs.Armature:create("robot") - self.armature:getAnimation():playByIndex(0) - self.armature:setPosition(VisibleRect:center()) - self.armature:setScale(0.48) - self:addChild(self.armature) - - local p1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") - local p2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist") - - local bone = ccs.Bone:create("p1") - bone:addDisplay(p1, 0) - bone:changeDisplayByIndex(0, true) - bone:setIgnoreMovementBoneData(true) - bone:setZOrder(100) - bone:setScale(1.2) - self.armature:addBone(bone, "bady-a3") - - bone = ccs.Bone:create("p2") - bone:addDisplay(p2, 0) - bone:changeDisplayByIndex(0, true) - bone:setIgnoreMovementBoneData(true) - bone:setZOrder(100) - bone:setScale(1.2) - self.armature:addBone(bone, "bady-a30") - - local function onTouchBegan(x, y) - self.animationID = (self.animationID + 1) % self.armature:getAnimation():getMovementCount() - self.armature:getAnimation():playByIndex(self.animationID) - return false - end - - local function onTouch(eventType, x, y) - if eventType == "began" then - return onTouchBegan(x,y) - end - end - - self:registerScriptTouchHandler(onTouch) -end - -function TestParticleDisplay.create() - local layer = TestParticleDisplay.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestUseMutiplePicture = class("TestUseMutiplePicture",ArmatureTestLayer) -TestUseMutiplePicture.__index = TestUseMutiplePicture -TestUseMutiplePicture.displayIndex = 0 -TestUseMutiplePicture.armature = nil - -function TestUseMutiplePicture.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestUseMutiplePicture) - return target -end - -function TestUseMutiplePicture:onEnter() - self:setTouchEnabled(true) - self.displayIndex = 1 - - self.armature = ccs.Armature:create("Knight_f/Knight") - self.armature:getAnimation():playByIndex(0) - self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y)) - self.armature:setScale(1.2) - self:addChild(self.armature) - - local weapon = - { - "weapon_f-sword.png", - "weapon_f-sword2.png", - "weapon_f-sword3.png", - "weapon_f-sword4.png", - "weapon_f-sword5.png", - "weapon_f-knife.png", - "weapon_f-hammer.png", - }; - - local i = 1 - for i = 1,table.getn(weapon) do - local skin = ccs.Skin:createWithSpriteFrameName(weapon[i]) - self.armature:getBone("weapon"):addDisplay(skin, i - 1) - end - - local function onTouchBegan(x, y) - self.displayIndex = (self.displayIndex + 1) % (table.getn(weapon) - 1) - self.armature:getBone("weapon"):changeDisplayByIndex(self.displayIndex, true) - return false - end - - local function onTouch(eventType, x, y) - if eventType == "began" then - return onTouchBegan(x,y) - end - end - - self:registerScriptTouchHandler(onTouch) -end - -function TestUseMutiplePicture.create() - local layer = TestUseMutiplePicture.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestBoundingBox = class("TestBoundingBox",ArmatureTestLayer) -TestBoundingBox.__index = TestBoundingBox - -function TestBoundingBox.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestBoundingBox) - return target -end - -function TestBoundingBox:onEnter() - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) - armature:setPosition(VisibleRect:center()) - armature:setScale(0.2) - self:addChild(armature) -end - -function TestBoundingBox.create() - local layer = TestBoundingBox.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestAnchorPoint = class("TestAnchorPoint",ArmatureTestLayer) -TestAnchorPoint.__index = TestAnchorPoint - -function TestAnchorPoint.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestAnchorPoint) - return target -end - -function TestAnchorPoint:onEnter() - local i = 1 - for i = 1 , 5 do - local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0); - armature:setPosition(VisibleRect:center()) - armature:setScale(0.2) - self:addChild(armature, 0, i - 1) - end - - self:getChildByTag(0):setAnchorPoint(cc.p(0,0)) - self:getChildByTag(1):setAnchorPoint(cc.p(0,1)) - self:getChildByTag(2):setAnchorPoint(cc.p(1,0)) - self:getChildByTag(3):setAnchorPoint(cc.p(1,1)) - self:getChildByTag(4):setAnchorPoint(cc.p(0.5,0.5)) -end - -function TestAnchorPoint.create() - local layer = TestAnchorPoint.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local TestArmatureNesting = class("TestArmatureNesting",ArmatureTestLayer) -TestArmatureNesting.__index = TestArmatureNesting -TestArmatureNesting.weaponIndex = 0 -TestArmatureNesting.armature = nil - -function TestArmatureNesting.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TestArmatureNesting) - return target -end - -function TestArmatureNesting:onEnter() - self:setTouchEnabled(true) - self.weaponIndex = 0 - - self.armature = ccs.Armature:create("cyborg") - self.armature:getAnimation():playByIndex(1) - self.armature:setPosition(VisibleRect:center()) - self.armature:setScale(1.2) - self.armature:getAnimation():setAnimationScale(0.4) - self:addChild(self.armature) - - local function onTouchBegan(x, y) - self.weaponIndex = (self.weaponIndex + 1) % 4 - self.armature:getBone("armInside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) - self.armature:getBone("armOutside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) - return false - end - - local function onTouch(eventType, x, y) - if eventType == "began" then - return onTouchBegan(x,y) - end - end - - self:registerScriptTouchHandler(onTouch) -end - -function TestArmatureNesting.create() - local layer = TestArmatureNesting.extend(cc.Layer:create()) - - if nil ~= layer then - layer:createMenu() - layer:createToExtensionMenu() - layer:onEnter() - layer:creatTitleAndSubTitle(armatureSceneIdx) - end - - return layer -end - -local armatureSceneArr = -{ - TestCSWithSkeleton.create, - TestDragonBones20.create, - TestPerformance.create, - TestChangeZorder.create, - TestAnimationEvent.create, - TestParticleDisplay.create, - TestUseMutiplePicture.create, - TestBoundingBox.create, - TestAnchorPoint.create, - TestArmatureNesting.create, -} - -function nextArmatureTest() - armatureSceneIdx = armatureSceneIdx + 1 - armatureSceneIdx = armatureSceneIdx % table.getn(armatureSceneArr) - if 0 == armatureSceneIdx then - armatureSceneIdx = table.getn(armatureSceneArr) - end - return armatureSceneArr[armatureSceneIdx]() -end - -function backArmatureTest() - armatureSceneIdx = armatureSceneIdx - 1 - if armatureSceneIdx <= 0 then - armatureSceneIdx = armatureSceneIdx + table.getn(armatureSceneArr) - end - - return armatureSceneArr[armatureSceneIdx]() -end - -function restartArmatureTest() - return armatureSceneArr[armatureSceneIdx]() -end - -local function addFileInfo() - -end - -function runArmatureTest() - local newScene = ArmatureTestScene.create() - newScene:runThisTest() - return newScene -end diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 0197b6ec4e..0a179dce6b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -1,6 +1,5 @@ require "luaScript/ExtensionTest/CocosBuilderTest" require "luaScript/ExtensionTest/WebProxyTest" -require "luaScript/ExtensionTest/ArmatureTest" local LINE_SPACE = 40 local kItemTagBasic = 1000 @@ -14,8 +13,7 @@ local ExtensionTestEnum = TEST_EDITBOX = 4, TEST_TABLEVIEW = 5, TEST_SCROLLVIEW = 6, - TEST_ARMATURE = 7, - TEST_MAX_COUNT = 8, + TEST_MAX_COUNT = 7, } local testsName = @@ -27,7 +25,6 @@ local testsName = "EditBoxTest", "TableViewTest", "ScrollViewTest", - "ArmatureTest", } @@ -1193,7 +1190,6 @@ local CreateExtensionsTestTable = runEditBoxTest, runTableViewTest, runScrollViewTest, - runArmatureTest, } diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 3aed09bac4..5fd5cacc31 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/co # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio ComController ComAttribute ComRender +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio ComController ComAttribute ComRender BatchNode # 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 From 5f68e028b547674e5e3850608b88b5f4f5e30c6d Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Wed, 13 Nov 2013 20:01:57 +0800 Subject: [PATCH 143/185] Modify reader and fixed bugs --- .../cocostudio/CCSGUIReader.cpp | 53 +++++++++++++++++++ cocos/gui/UILabel.cpp | 33 +++++++++--- cocos/gui/UILabel.h | 33 +++++++++++- cocos/gui/UILayer.cpp | 2 +- cocos/gui/UIPageView.cpp | 17 +++++- cocos/gui/UIPageView.h | 30 +++++++++-- cocos/gui/UIWidget.cpp | 10 ++-- 7 files changed, 159 insertions(+), 19 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index ca1067e504..4188f62fef 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1033,6 +1033,12 @@ UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *d } CC_SAFE_DELETE(subData); } + + UILayout* layout = dynamic_cast(widget); + if (layout) + { + layout->doLayout(); + } CC_SAFE_DELETE(uiOptions); return widget; @@ -1047,6 +1053,12 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize")); } + widget->setSizeType((SizeType)dicHelper->getIntValue_json(options, "sizeType")); + widget->setPositionType((PositionType)dicHelper->getIntValue_json(options, "positionType")); + + widget->setSizePercent(Point(dicHelper->getFloatValue_json(options, "sizePercentX"), dicHelper->getFloatValue_json(options, "sizePercentY"))); + widget->setPositionPercent(Point(dicHelper->getFloatValue_json(options, "positionPercentX"), dicHelper->getFloatValue_json(options, "positionPercentY"))); + float w = dicHelper->getFloatValue_json(options, "width"); float h = dicHelper->getFloatValue_json(options, "height"); widget->setSize(Size(w, h)); @@ -1082,6 +1094,46 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi } int z = dicHelper->getIntValue_json(options, "ZOrder"); widget->setZOrder(z); + + JsonDictionary* layoutParameterDic = dicHelper->getSubDictionary_json(options, "layoutParameter"); + if (layoutParameterDic) + { + int paramType = dicHelper->getIntValue_json(layoutParameterDic, "type"); + UILayoutParameter* parameter = NULL; + switch (paramType) + { + case 0: + break; + case 1: + { + parameter = UILinearLayoutParameter::create(); + int gravity = dicHelper->getIntValue_json(layoutParameterDic, "gravity"); + ((UILinearLayoutParameter*)parameter)->setGravity((UILinearGravity)gravity); + break; + } + case 2: + { + parameter = UIRelativeLayoutParameter::create(); + UIRelativeLayoutParameter* rParameter = (UIRelativeLayoutParameter*)parameter; + const char* relativeName = dicHelper->getStringValue_json(layoutParameterDic, "relativeName"); + rParameter->setRelativeName(relativeName); + const char* relativeToName = dicHelper->getStringValue_json(layoutParameterDic, "relativeToName"); + rParameter->setRelativeToWidgetName(relativeToName); + int align = dicHelper->getIntValue_json(layoutParameterDic, "align"); + rParameter->setAlign((UIRelativeAlign)align); + break; + } + default: + break; + } + float mgl = dicHelper->getFloatValue_json(layoutParameterDic, "marginLeft"); + float mgt = dicHelper->getFloatValue_json(layoutParameterDic, "marginTop"); + float mgr = dicHelper->getFloatValue_json(layoutParameterDic, "marginRight"); + float mgb = dicHelper->getFloatValue_json(layoutParameterDic, "marginDown"); + parameter->setMargin(UIMargin(mgl, mgt, mgr, mgb)); + widget->setLayoutParameter(parameter); + } + } void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) @@ -1563,6 +1615,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*wi float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); } + panel->setLayoutType((LayoutType)dicHelper->getIntValue_json(options, "layoutType")); setColorPropsForWidgetFromJsonDictionary(widget,options); } diff --git a/cocos/gui/UILabel.cpp b/cocos/gui/UILabel.cpp index cdf32c49c1..aeab14037d 100644 --- a/cocos/gui/UILabel.cpp +++ b/cocos/gui/UILabel.cpp @@ -29,7 +29,8 @@ namespace gui { UILabel::UILabel(): _touchScaleChangeEnabled(false), -_normalScaleValue(1.0f), +_normalScaleValueX(1.0f), +_normalScaleValueY(1.0f), _fontName("Thonburi"), _fontSize(10), _onSelectedScaleOffset(0.5), @@ -124,7 +125,26 @@ void UILabel::setTextVerticalAlignment(cocos2d::TextVAlignment alignment) void UILabel::setTouchScaleChangeEnabled(bool enable) { _touchScaleChangeEnabled = enable; - _normalScaleValue = getScale(); + _normalScaleValueX = getScaleX(); + _normalScaleValueY = getScaleY(); +} + +void UILabel::setScale(float fScale) +{ + UIWidget::setScale(fScale); + _normalScaleValueX = _normalScaleValueY = fScale; +} + +void UILabel::setScaleX(float fScaleX) +{ + UIWidget::setScaleX(fScaleX); + _normalScaleValueX = fScaleX; +} + +void UILabel::setScaleY(float fScaleY) +{ + UIWidget::setScaleY(fScaleY); + _normalScaleValueY = fScaleY; } bool UILabel::isTouchScaleChangeEnabled() @@ -138,7 +158,7 @@ void UILabel::onPressStateChangedToNormal() { return; } - clickScale(_normalScaleValue); + clickScale(_normalScaleValueX, _normalScaleValueY); } void UILabel::onPressStateChangedToPressed() @@ -147,7 +167,7 @@ void UILabel::onPressStateChangedToPressed() { return; } - clickScale(_normalScaleValue + _onSelectedScaleOffset); + clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset); } void UILabel::onPressStateChangedToDisabled() @@ -155,9 +175,10 @@ void UILabel::onPressStateChangedToDisabled() } -void UILabel::clickScale(float scale) +void UILabel::clickScale(float scaleX, float scaleY) { - _renderer->setScale(scale); + _renderer->setScaleX(scaleX); + _renderer->setScaleY(scaleY); } void UILabel::setFlipX(bool flipX) diff --git a/cocos/gui/UILabel.h b/cocos/gui/UILabel.h index c38945bb9a..e029a5b920 100644 --- a/cocos/gui/UILabel.h +++ b/cocos/gui/UILabel.h @@ -100,6 +100,34 @@ public: * @return touch scale enabled of label. */ bool isTouchScaleChangeEnabled(); + + /** + * Changes both X and Y scale factor of the widget. + * + * 1.0 is the default scale factor. It modifies the X and Y scale at the same time. + * + * @param scale The scale factor for both X and Y axis. + */ + virtual void setScale(float fScale); + + /** + * Changes the scale factor on X axis of this widget + * + * The deafult value is 1.0 if you haven't changed it before + * + * @param fScaleX The scale factor on X axis. + */ + virtual void setScaleX(float fScaleX); + + /** + * Changes the scale factor on Y axis of this widget + * + * The Default value is 1.0 if you haven't changed it before. + * + * @param fScaleY The scale factor on Y axis. + */ + virtual void setScaleY(float fScaleY); + //override "setFlipX" method of widget. virtual void setFlipX(bool flipX); @@ -137,13 +165,14 @@ protected: virtual void onPressStateChangedToPressed(); virtual void onPressStateChangedToDisabled(); virtual void onSizeChanged(); - void clickScale(float scale); + void clickScale(float scaleX, float scaleY); void labelScaleChangedWithSize(); virtual UIWidget* createCloneInstance(); virtual void copySpecialProperties(UIWidget* model); protected: bool _touchScaleChangeEnabled; - float _normalScaleValue; + float _normalScaleValueX; + float _normalScaleValueY; std::string _fontName; int _fontSize; float _onSelectedScaleOffset; diff --git a/cocos/gui/UILayer.cpp b/cocos/gui/UILayer.cpp index a935f9efc5..f86d4ce9eb 100644 --- a/cocos/gui/UILayer.cpp +++ b/cocos/gui/UILayer.cpp @@ -48,7 +48,6 @@ bool UILayer::init() { _rootWidget = UIRootWidget::create(); _rootWidget->retain(); - _rootWidget->onEnter(); addChild(_rootWidget->getRenderer()); _inputManager = new UIInputManager(); _inputManager->setRootWidget(_rootWidget); @@ -85,6 +84,7 @@ void UILayer::onEnter() listener->onTouchCancelled = CC_CALLBACK_2(UILayer::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + _rootWidget->onEnter(); } void UILayer::onExit() diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index 2183091b6d..823e997727 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -219,6 +219,11 @@ void UIPageView::removePageAtIndex(int index) removePage(page); } } + +void UIPageView::removeAllPages() +{ + removeAllChildren(); +} void UIPageView::updateBoundaryPages() { @@ -247,9 +252,8 @@ bool UIPageView::removeChild(UIWidget* widget) if (_pages->containsObject(widget)) { _pages->removeObject(widget); - return UILayout::removeChild(widget); } - return false; + return UILayout::removeChild(widget); } void UIPageView::onSizeChanged() @@ -586,6 +590,15 @@ cocos2d::Array* UIPageView::getPages() { return _pages; } + +UILayout* UIPageView::getPage(int index) +{ + if (index < 0 || index >= (int)(_pages->count())) + { + return NULL; + } + return (UILayout*)_pages->getObjectAtIndex(index); +} const char* UIPageView::getDescription() const { diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index ef11056e9b..e5aac237d4 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -101,6 +101,8 @@ public: */ void removePageAtIndex(int index); + void removeAllPages(); + /** * scroll pageview to index. * @@ -117,15 +119,13 @@ public: cocos2d::Array* getPages(); + UILayout* getPage(int index); + // event void addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector); - //override "removeChild" method of widget. - virtual bool removeChild(UIWidget* widget); - - //override "removeAllChildrenAndCleanUp" method of widget. - virtual void removeAllChildren(); + //override "onTouchBegan" method of widget. virtual bool onTouchBegan(const cocos2d::Point &touchPoint); @@ -144,6 +144,24 @@ public: virtual void doLayout(){}; + /** + * Sets LayoutType. + * + * @see LayoutType + * + * @param LayoutType + */ + virtual void setLayoutType(LayoutType type){}; + + /** + * Gets LayoutType. + * + * @see LayoutType + * + * @return LayoutType + */ + virtual LayoutType getLayoutType() const{return LAYOUT_ABSOLUTE;}; + /** * Returns the "class name" of widget. */ @@ -151,6 +169,8 @@ public: protected: virtual bool addChild(UIWidget* widget); + virtual bool removeChild(UIWidget* widget); + virtual void removeAllChildren(); virtual bool init(); UILayout* createPage(); float getPositionXByIndex(int idx); diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index ad63b28451..7ee89886ac 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -342,11 +342,11 @@ void UIWidget::setSize(const cocos2d::Size &size) void UIWidget::setSizePercent(const cocos2d::Point &percent) { _sizePercent = percent; - if (!_isRunning) + cocos2d::Size cSize = _customSize; + if (_isRunning) { - return; + cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y); } - cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y); if (_ignoreSize) { _size = getContentSize(); @@ -1115,6 +1115,10 @@ WidgetType UIWidget::getWidgetType() const void UIWidget::setLayoutParameter(UILayoutParameter *parameter) { + if (!parameter) + { + return; + } _layoutParameterDictionary->setObject(parameter, parameter->getLayoutType()); } From 3ac054edbd25bb1d2ed603e05a025cdf1e20de49 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Wed, 13 Nov 2013 20:38:18 +0800 Subject: [PATCH 144/185] Fixed bugs --- cocos/editor-support/cocostudio/CCSGUIReader.cpp | 2 +- cocos/gui/UILayer.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 4188f62fef..841763701c 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1133,7 +1133,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi parameter->setMargin(UIMargin(mgl, mgt, mgr, mgb)); widget->setLayoutParameter(parameter); } - + CC_SAFE_DELETE(layoutParameterDic); } void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) diff --git a/cocos/gui/UILayer.cpp b/cocos/gui/UILayer.cpp index f86d4ce9eb..ce0b81cd47 100644 --- a/cocos/gui/UILayer.cpp +++ b/cocos/gui/UILayer.cpp @@ -89,6 +89,7 @@ void UILayer::onEnter() void UILayer::onExit() { + _rootWidget->onExit(); CCLayer::onExit(); } From ccbbff3c22d6c769c4ab9e9e544800f933b9ecbd Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 14 Nov 2013 09:44:35 +0800 Subject: [PATCH 145/185] Fix bug: Z fighting on TransitionScenePageTurn --- cocos/2d/CCTransitionPageTurn.cpp | 24 ++++++++++++++++++++++++ cocos/2d/CCTransitionPageTurn.h | 10 ++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 3bde055c59..b90b6d790d 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -32,6 +32,9 @@ THE SOFTWARE. NS_CC_BEGIN +float TransitionPageTurn::POLYGONOFFSETFACTOR = -20.f; +float TransitionPageTurn::POLYGONOFFSETUNITS = -20.f; + TransitionPageTurn::TransitionPageTurn() { } @@ -67,6 +70,27 @@ void TransitionPageTurn::sceneOrder() _isInSceneOnTop = _back; } +void TransitionPageTurn::draw() +{ + Scene::draw(); + + if( _isInSceneOnTop ) { + _outScene->visit(); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(POLYGONOFFSETFACTOR, POLYGONOFFSETUNITS); + _inScene->visit(); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + } else { + _inScene->visit(); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(POLYGONOFFSETFACTOR, POLYGONOFFSETUNITS); + _outScene->visit(); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + } +} + void TransitionPageTurn::onEnter() { TransitionScene::onEnter(); diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index f055274720..cb138aa389 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -64,6 +64,11 @@ public: * @lua NA */ virtual ~TransitionPageTurn(); + + // + // Overrides + // + virtual void draw() override; /** * Creates a base transition with duration and incoming scene. @@ -83,8 +88,9 @@ protected: virtual void sceneOrder() override; protected: - bool _back; - + bool _back; + static float POLYGONOFFSETFACTOR; + static float POLYGONOFFSETUNITS; }; // end of transition group From dff9c6a5b5dc4cd3597a4761905ef8b2cefb0f91 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 14 Nov 2013 01:52:57 +0000 Subject: [PATCH 146/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 3fa10c3f8f..3c656c5ae4 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 3fa10c3f8f9fe083ef05cb401924d31740da9719 +Subproject commit 3c656c5ae444653a31d3955ff4377eca3aadc08e From b4b4e9952234cf68fc49aed16a6229da13c4b96c Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 14 Nov 2013 10:00:59 +0800 Subject: [PATCH 147/185] Fix bug: rename const with under line seperator --- cocos/2d/CCTransitionPageTurn.cpp | 8 ++++---- cocos/2d/CCTransitionPageTurn.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index b90b6d790d..e291bcd84e 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -32,8 +32,8 @@ THE SOFTWARE. NS_CC_BEGIN -float TransitionPageTurn::POLYGONOFFSETFACTOR = -20.f; -float TransitionPageTurn::POLYGONOFFSETUNITS = -20.f; +float TransitionPageTurn::POLYGON_OFFSET_FACTOR = -20.f; +float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f; TransitionPageTurn::TransitionPageTurn() { @@ -77,14 +77,14 @@ void TransitionPageTurn::draw() if( _isInSceneOnTop ) { _outScene->visit(); glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(POLYGONOFFSETFACTOR, POLYGONOFFSETUNITS); + glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); _inScene->visit(); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } else { _inScene->visit(); glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(POLYGONOFFSETFACTOR, POLYGONOFFSETUNITS); + glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); _outScene->visit(); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index cb138aa389..3f0eca219d 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -89,8 +89,8 @@ protected: protected: bool _back; - static float POLYGONOFFSETFACTOR; - static float POLYGONOFFSETUNITS; + static float POLYGON_OFFSET_FACTOR; + static float POLYGON_OFFSET_UNITS; }; // end of transition group From 71ca09d0414bde9ab10c798f8b841449d4b8be67 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 10:09:32 +0800 Subject: [PATCH 148/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index c0f33125bf..1d31799984 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation [FIX] Configuration of VAO in runtime [FIX] Webp Test Crashes. + [FIX] TransitionScenePageTurn: z fighting [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. From 9b2da3b09f24a7a1ce3f9dfe81cbf9420c94b960 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 10:11:18 +0800 Subject: [PATCH 149/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 1d31799984..7f5f506181 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support + [NEW] GLProgram: setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From c51f0965aa60368af9b1dc35f2086f298e65bb9c Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 10:12:25 +0800 Subject: [PATCH 150/185] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index e6bebcaae3..93024d83a7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -598,6 +598,7 @@ Developers: bmanGH Use gl caching functions in TexturePVR::createGLTexture() Configuration of VAO in runtime + Add setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv mothed into GLProgram class metadao make create_project.py more pythonic and fix some typoes From dee3bffcdc8993b7ce5950039de224cabd9a30f4 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Thu, 14 Nov 2013 10:40:06 +0800 Subject: [PATCH 151/185] Fix: UserDefault::createXMLFile with correct XML definition. --- cocos/2d/CCUserDefault.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp index 2104051f76..1a83091dfe 100644 --- a/cocos/2d/CCUserDefault.cpp +++ b/cocos/2d/CCUserDefault.cpp @@ -479,7 +479,7 @@ bool UserDefault::createXMLFile() { return false; } - tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration("1.0"); + tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(NULL); if (NULL==pDeclaration) { return false; From c1ccfc5cea01be996aa9370a3d6c49b3b9b77b03 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 10:41:09 +0800 Subject: [PATCH 152/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 7f5f506181..e9d44a8465 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Configuration of VAO in runtime [FIX] Webp Test Crashes. [FIX] TransitionScenePageTurn: z fighting + [FIX] AssetsManager: Adding test whether the file directory exists when uncompressing file entry,if does not exist then create directory [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. From f4425f5db2f32f64e2258fdb22fe36dff911f7b1 Mon Sep 17 00:00:00 2001 From: Jason Xu Date: Thu, 14 Nov 2013 11:08:50 +0800 Subject: [PATCH 153/185] C++11: NULL -> nullptr --- cocos/2d/CCUserDefault.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp index 1a83091dfe..d81596fca6 100644 --- a/cocos/2d/CCUserDefault.cpp +++ b/cocos/2d/CCUserDefault.cpp @@ -479,7 +479,7 @@ bool UserDefault::createXMLFile() { return false; } - tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(NULL); + tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(nullptr); if (NULL==pDeclaration) { return false; From 6b07ee4d08cf2731f52d94d54e28e7300192e880 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 11:15:02 +0800 Subject: [PATCH 154/185] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 93024d83a7..cbd740889a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Core Developers: Qingkui Hu (samuele3hu) Huabing Xu (dabingnn) Bo Yu (boyu0) + Wenhai Lin(Dhilan007) Developers: From 4b9215708c69b98fb4392a3e0a026c07862805d8 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 11:25:39 +0800 Subject: [PATCH 155/185] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index cbd740889a..eae59ddd9d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -632,6 +632,7 @@ Developers: Fixed a bug that CCBReader can't play sequence automatically in JSB. Could not set next animation in CCBAnimationCompleted callback. Fixed missing to add JSAutoCompartment when invoking JS functions from C++. + CCBReader: To set anchor point to 0,0 when created by loader lite3 Fixed a bug that Node's anchor point was changed after being added to ScrollView. From a2bfc31ea0d5f20af7754c43caad7897d03e01f7 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 11:27:26 +0800 Subject: [PATCH 156/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e9d44a8465..d848fd916c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Webp Test Crashes. [FIX] TransitionScenePageTurn: z fighting [FIX] AssetsManager: Adding test whether the file directory exists when uncompressing file entry,if does not exist then create directory + [FIX] CCBReader: To set anchor point to 0,0 when loading Scale9Sprite [NEW] Arm64 support. [NEW] Added Mouse Support For Desktop Platforms. [NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc. From 611ba9e9f51c1f894e45d1662d728db9bed6324b Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 14 Nov 2013 11:37:46 +0800 Subject: [PATCH 157/185] Modify code criterion --- .../cocostudio/CCSGUIReader.cpp | 92 +++++++++---------- cocos/gui/UIButton.cpp | 18 ++-- cocos/gui/UICheckBox.cpp | 20 ++-- cocos/gui/UIHelper.cpp | 22 ++--- cocos/gui/UIImageView.cpp | 6 +- cocos/gui/UIInputManager.cpp | 6 +- cocos/gui/UILabel.cpp | 4 +- cocos/gui/UILabelAtlas.cpp | 6 +- cocos/gui/UILabelBMFont.cpp | 4 +- cocos/gui/UILayer.cpp | 10 +- cocos/gui/UILayout.cpp | 28 +++--- cocos/gui/UILayoutParameter.cpp | 6 +- cocos/gui/UIListView.cpp | 16 ++-- cocos/gui/UILoadingBar.cpp | 6 +- cocos/gui/UIPageView.cpp | 22 ++--- cocos/gui/UIRootWidget.cpp | 2 +- cocos/gui/UIScrollView.cpp | 12 +-- cocos/gui/UISlider.cpp | 26 +++--- cocos/gui/UITextField.cpp | 14 +-- cocos/gui/UIWidget.cpp | 40 ++++---- 20 files changed, 180 insertions(+), 180 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 841763701c..7179c41172 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -34,7 +34,7 @@ namespace cocostudio { -static GUIReader* sharedReader = NULL; +static GUIReader* sharedReader = nullptr; GUIReader::GUIReader(): m_strFilePath("") @@ -122,26 +122,26 @@ const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const UIWidget* GUIReader::widgetFromJsonFile(const char *fileName) { DictionaryHelper* dicHelper = DICTOOL; - const char *des = NULL; + const char *des = nullptr; std::string jsonpath; - JsonDictionary *jsonDict = NULL; + JsonDictionary *jsonDict = nullptr; jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName); int pos = jsonpath.find_last_of('/'); m_strFilePath = jsonpath.substr(0,pos+1); long size = 0; des = (char*)(CCFileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); - if(NULL == des || strcmp(des, "") == 0) + if(nullptr == des || strcmp(des, "") == 0) { printf("read json file[%s] error!\n", fileName); - return NULL; + return nullptr; } std::string strDes(des); jsonDict = new JsonDictionary(); jsonDict->initWithDescription(strDes.c_str()); - UIWidget* widget = NULL; + UIWidget* widget = nullptr; const char* fileVersion = dicHelper->getStringValue_json(jsonDict, "version"); - WidgetPropertiesReader * pReader = NULL; + WidgetPropertiesReader * pReader = nullptr; if (fileVersion) { int versionInteger = getVersionInteger(fileVersion); @@ -221,7 +221,7 @@ UIWidget* WidgetPropertiesReader0250::createWidget(JsonDictionary* data, const c UIWidget* WidgetPropertiesReader0250::widgetFromJsonDictionary(JsonDictionary *data) { DictionaryHelper* dicHelper = DICTOOL; - UIWidget* widget = NULL; + UIWidget* widget = nullptr; const char* classname = dicHelper->getStringValue_json(data, "classname"); JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) @@ -397,9 +397,9 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(UIWidget*wi const char* pressedFileName = dicHelper->getStringValue_json(options, "pressed"); const char* disabledFileName = dicHelper->getStringValue_json(options, "disabled"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); if (scale9Enable) { @@ -484,11 +484,11 @@ void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(UIWidget* std::string tp_bd = m_strFilePath; std::string tp_cd = m_strFilePath; - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr; + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr; + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr; + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr; + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr; bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); if (useMergedTexture) @@ -519,7 +519,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(UIWidget imageView->setScale9Enabled(scale9Enable); std::string tp_i = m_strFilePath; - const char* imageFileName_tp = NULL; + const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); @@ -619,7 +619,7 @@ void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(UIWidge if (sv && cmf && iw && ih && scm && (strcmp(dicHelper->getStringValue_json(options, "charMapFile"), "") != 0)) { std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; + const char* cmf_tp = nullptr; const char* cmft = dicHelper->getStringValue_json(options, "charMapFile"); cmf_tp = tp_c.append(cmft).c_str(); @@ -668,7 +668,7 @@ void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(UIWidget*wi std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(options, "backGroundImage"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); if (backGroundScale9Enable) { @@ -732,7 +732,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); @@ -747,7 +747,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); @@ -766,9 +766,9 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi const char* pressedFileName = dicHelper->getStringValue_json(options, "ballPressed"); const char* disabledFileName = dicHelper->getStringValue_json(options, "ballDisabled"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; if (useMergedTexture) { slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); @@ -781,7 +781,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*wi std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(options, "progressBarFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); @@ -852,7 +852,7 @@ void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(UIWidge bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); std::string tp_b = m_strFilePath; const char*imageFileName = dicHelper->getStringValue_json(options, "texture"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; if (useMergedTexture) { loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); @@ -875,7 +875,7 @@ void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(UIWidg UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; + const char* cmf_tp = nullptr; const char* cmft = dicHelper->getStringValue_json(options, "fileName"); cmf_tp = tp_c.append(cmft).c_str(); @@ -940,7 +940,7 @@ UIWidget* WidgetPropertiesReader0300::createWidget(JsonDictionary* data, const c UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *data) { DictionaryHelper* dicHelper = DICTOOL; - UIWidget* widget = NULL; + UIWidget* widget = nullptr; const char* classname = dicHelper->getStringValue_json(data, "classname"); JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) @@ -1099,7 +1099,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*wi if (layoutParameterDic) { int paramType = dicHelper->getIntValue_json(layoutParameterDic, "type"); - UILayoutParameter* parameter = NULL; + UILayoutParameter* parameter = nullptr; switch (paramType) { case 0: @@ -1178,7 +1178,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi { std::string tp_n = m_strFilePath; const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; button->loadTextureNormal(normalFileName_tp); break; } @@ -1200,7 +1200,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi { std::string tp_p = m_strFilePath; const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; button->loadTexturePressed(pressedFileName_tp); break; } @@ -1222,7 +1222,7 @@ void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*wi { std::string tp_d = m_strFilePath; const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; button->loadTextureDisabled(disabledFileName_tp); break; } @@ -1297,7 +1297,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget* { std::string tp_b = m_strFilePath; const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path"); - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr; checkBox->loadTextureBackGround(backGroundFileName_tp); break; } @@ -1320,7 +1320,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget* { std::string tp_bs = m_strFilePath; const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path"); - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr; checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); break; } @@ -1343,7 +1343,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget* { std::string tp_c = m_strFilePath; const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path"); - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr; checkBox->loadTextureFrontCross(frontCrossFileName_tp); break; } @@ -1366,7 +1366,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget* { std::string tp_bd = m_strFilePath; const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path"); - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr; checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); break; } @@ -1389,7 +1389,7 @@ void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget* { std::string tp_cd = m_strFilePath; const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path"); - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr; checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); break; } @@ -1422,7 +1422,7 @@ void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(UIWidget { std::string tp_i = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; + const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); @@ -1592,7 +1592,7 @@ void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; panel->setBackGroundImage(imageFileName_tp); break; } @@ -1656,7 +1656,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadBarTexture(imageFileName_tp); break; } @@ -1683,7 +1683,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadBarTexture(imageFileName_tp); break; } @@ -1708,7 +1708,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_n = m_strFilePath; const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; slider->loadSlidBallTextureNormal(normalFileName_tp); break; } @@ -1731,7 +1731,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_p = m_strFilePath; const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; slider->loadSlidBallTexturePressed(pressedFileName_tp); break; } @@ -1754,7 +1754,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_d = m_strFilePath; const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; slider->loadSlidBallTextureDisabled(disabledFileName_tp); break; } @@ -1779,7 +1779,7 @@ void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*wi { std::string tp_b = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; slider->loadProgressBarTexture(imageFileName_tp); break; } @@ -1860,7 +1860,7 @@ void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(UIWidge { std::string tp_i = m_strFilePath; const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; + const char* imageFileName_tp = nullptr; if (imageFileName && (strcmp(imageFileName, "") != 0)) { imageFileName_tp = tp_i.append(imageFileName).c_str(); diff --git a/cocos/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index d18627be1e..b477713fde 100644 --- a/cocos/gui/UIButton.cpp +++ b/cocos/gui/UIButton.cpp @@ -33,10 +33,10 @@ namespace gui { #define TITLERENDERERZ (1) UIButton::UIButton(): -_buttonNormalRenderer(NULL), -_buttonClickedRenderer(NULL), -_buttonDisableRenderer(NULL), -_titleRenderer(NULL), +_buttonNormalRenderer(nullptr), +_buttonClickedRenderer(nullptr), +_buttonDisableRenderer(nullptr), +_titleRenderer(nullptr), _normalFileName(""), _clickedFileName(""), _disabledFileName(""), @@ -70,7 +70,7 @@ UIButton* UIButton::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIButton::init() @@ -109,9 +109,9 @@ void UIButton::setScale9Enabled(bool able) _renderer->removeChild(_buttonClickedRenderer, true); _renderer->removeChild(_buttonDisableRenderer, true); - _buttonNormalRenderer = NULL; - _buttonClickedRenderer = NULL; - _buttonDisableRenderer = NULL; + _buttonNormalRenderer = nullptr; + _buttonClickedRenderer = nullptr; + _buttonDisableRenderer = nullptr; if (_scale9Enabled) { _buttonNormalRenderer = cocos2d::extension::Scale9Sprite::create(); @@ -457,7 +457,7 @@ cocos2d::Node* UIButton::getVirtualRenderer() case BRIGHT_HIGHLIGHT: return _buttonClickedRenderer; default: - return NULL; + return nullptr; } } else diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index 511d03a7ea..d46d41ac4f 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -28,14 +28,14 @@ namespace gui { UICheckBox::UICheckBox(): -_backGroundBoxRenderer(NULL), -_backGroundSelectedBoxRenderer(NULL), -_frontCrossRenderer(NULL), -_backGroundBoxDisabledRenderer(NULL), -_frontCrossDisabledRenderer(NULL), +_backGroundBoxRenderer(nullptr), +_backGroundSelectedBoxRenderer(nullptr), +_frontCrossRenderer(nullptr), +_backGroundBoxDisabledRenderer(nullptr), +_frontCrossDisabledRenderer(nullptr), _isSelected(true), -_checkBoxEventListener(NULL), -_checkBoxEventSelector(NULL), +_checkBoxEventListener(nullptr), +_checkBoxEventSelector(nullptr), _backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL), @@ -51,8 +51,8 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - _checkBoxEventListener = NULL; - _checkBoxEventSelector = NULL; + _checkBoxEventListener = nullptr; + _checkBoxEventSelector = nullptr; } UICheckBox* UICheckBox::create() @@ -64,7 +64,7 @@ UICheckBox* UICheckBox::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UICheckBox::init() diff --git a/cocos/gui/UIHelper.cpp b/cocos/gui/UIHelper.cpp index d896a6372c..5385e84ce8 100644 --- a/cocos/gui/UIHelper.cpp +++ b/cocos/gui/UIHelper.cpp @@ -30,7 +30,7 @@ UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag) { if (!root) { - return NULL; + return nullptr; } if (root->getTag() == tag) { @@ -42,19 +42,19 @@ UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag) { UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]); UIWidget* res = seekWidgetByTag(child,tag); - if (res != NULL) + if (res != nullptr) { return res; } } - return NULL; + return nullptr; } UIWidget* UIHelper::seekWidgetByName(UIWidget* root, const char *name) { if (!root) { - return NULL; + return nullptr; } if (strcmp(root->getName(), name) == 0) { @@ -66,19 +66,19 @@ UIWidget* UIHelper::seekWidgetByName(UIWidget* root, const char *name) { UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]); UIWidget* res = seekWidgetByName(child,name); - if (res != NULL) + if (res != nullptr) { return res; } } - return NULL; + return nullptr; } UIWidget* UIHelper::seekWidgetByRelativeName(UIWidget *root, const char *name) { if (!root) { - return NULL; + return nullptr; } cocos2d::ccArray* arrayRootChildren = root->getChildren()->data; int length = arrayRootChildren->num; @@ -91,7 +91,7 @@ UIWidget* UIHelper::seekWidgetByRelativeName(UIWidget *root, const char *name) return child; } } - return NULL; + return nullptr; } /*temp action*/ @@ -99,7 +99,7 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag) { if (!root) { - return NULL; + return nullptr; } if (root->getActionTag() == tag) { @@ -111,12 +111,12 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag) { UIWidget* child = (UIWidget*)(arrayRootChildren->arr[i]); UIWidget* res = seekActionWidgetByActionTag(child,tag); - if (res != NULL) + if (res != nullptr) { return res; } } - return NULL; + return nullptr; } } \ No newline at end of file diff --git a/cocos/gui/UIImageView.cpp b/cocos/gui/UIImageView.cpp index 68d604f21a..781a1134bb 100644 --- a/cocos/gui/UIImageView.cpp +++ b/cocos/gui/UIImageView.cpp @@ -40,7 +40,7 @@ _doubleClickEnabled(false), _scale9Enabled(false), _prevIgnoreSize(true), _capInsets(cocos2d::Rect::ZERO), -_imageRenderer(NULL), +_imageRenderer(nullptr), _textureFile(""), _imageTexType(UI_TEX_TYPE_LOCAL), _imageTextureSize(_size) @@ -62,7 +62,7 @@ UIImageView* UIImageView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UIImageView::initRenderer() @@ -275,7 +275,7 @@ void UIImageView::setScale9Enabled(bool able) _scale9Enabled = able; _renderer->removeChild(_imageRenderer, true); - _imageRenderer = NULL; + _imageRenderer = nullptr; if (_scale9Enabled) { _imageRenderer = cocos2d::extension::Scale9Sprite::create(); diff --git a/cocos/gui/UIInputManager.cpp b/cocos/gui/UIInputManager.cpp index a1c6659557..04aac38a82 100644 --- a/cocos/gui/UIInputManager.cpp +++ b/cocos/gui/UIInputManager.cpp @@ -30,12 +30,12 @@ namespace gui { UIInputManager::UIInputManager(): -_manageredWidget(NULL), +_manageredWidget(nullptr), _touchDown(false), _longClickTime(0.0), _longClickRecordTime(0.0), -_checkedDoubleClickWidget(NULL), -_rootWidget(NULL) +_checkedDoubleClickWidget(nullptr), +_rootWidget(nullptr) { _manageredWidget = Array::create(); _manageredWidget->retain(); diff --git a/cocos/gui/UILabel.cpp b/cocos/gui/UILabel.cpp index aeab14037d..44fde58cd8 100644 --- a/cocos/gui/UILabel.cpp +++ b/cocos/gui/UILabel.cpp @@ -34,7 +34,7 @@ _normalScaleValueY(1.0f), _fontName("Thonburi"), _fontSize(10), _onSelectedScaleOffset(0.5), -_labelRenderer(NULL) +_labelRenderer(nullptr) { } @@ -52,7 +52,7 @@ UILabel* UILabel::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UILabel::init() diff --git a/cocos/gui/UILabelAtlas.cpp b/cocos/gui/UILabelAtlas.cpp index 17963f595f..8a3bcc2677 100644 --- a/cocos/gui/UILabelAtlas.cpp +++ b/cocos/gui/UILabelAtlas.cpp @@ -47,7 +47,7 @@ UICCLabelAtlas* UICCLabelAtlas::create() } CC_SAFE_DELETE(pRet); - return NULL; + return nullptr; } void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) @@ -79,7 +79,7 @@ void UICCLabelAtlas::updateDisplayedOpacity(GLubyte opacity) UILabelAtlas::UILabelAtlas(): -_laberAtlasRenderer(NULL), +_laberAtlasRenderer(nullptr), _stringValue(""), _charMapFileName(""), _itemWidth(0), @@ -103,7 +103,7 @@ UILabelAtlas* UILabelAtlas::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UILabelAtlas::initRenderer() diff --git a/cocos/gui/UILabelBMFont.cpp b/cocos/gui/UILabelBMFont.cpp index ee3ad66ddf..ad6a5beeb1 100644 --- a/cocos/gui/UILabelBMFont.cpp +++ b/cocos/gui/UILabelBMFont.cpp @@ -27,7 +27,7 @@ namespace gui { UILabelBMFont::UILabelBMFont(): -_labelBMFontRenderer(NULL), +_labelBMFontRenderer(nullptr), _fntFileHasInit(false), _fntFileName(""), _stringValue("") @@ -48,7 +48,7 @@ UILabelBMFont* UILabelBMFont::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UILabelBMFont::initRenderer() diff --git a/cocos/gui/UILayer.cpp b/cocos/gui/UILayer.cpp index ce0b81cd47..31472cb83f 100644 --- a/cocos/gui/UILayer.cpp +++ b/cocos/gui/UILayer.cpp @@ -30,8 +30,8 @@ namespace gui { UILayer::UILayer(): -_rootWidget(NULL), -_inputManager(NULL) +_rootWidget(nullptr), +_inputManager(nullptr) { } @@ -67,7 +67,7 @@ UILayer* UILayer::create(void) else { CC_SAFE_DELETE(pRet); - return NULL; + return nullptr; } } @@ -118,7 +118,7 @@ UIWidget* UILayer::getWidgetByTag(int tag) { if (!_rootWidget) { - return NULL; + return nullptr; } return UIHelper::seekWidgetByTag(_rootWidget, tag); } @@ -127,7 +127,7 @@ UIWidget* UILayer::getWidgetByName(const char* name) { if (!_rootWidget) { - return NULL; + return nullptr; } return UIHelper::seekWidgetByName(_rootWidget, name); } diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 9a25d57b13..3cbd5fef8a 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -35,13 +35,13 @@ namespace gui { UILayout::UILayout(): _clippingEnabled(false), _backGroundScale9Enabled(false), -_backGroundImage(NULL), +_backGroundImage(nullptr), _backGroundImageFileName(""), _backGroundImageCapInsets(cocos2d::Rect::ZERO), _colorType(LAYOUT_COLOR_NONE), _bgImageTexType(UI_TEX_TYPE_LOCAL), -_colorRender(NULL), -_gradientRender(NULL), +_colorRender(nullptr), +_gradientRender(nullptr), _cColor(cocos2d::Color3B::WHITE), _gStartColor(cocos2d::Color3B::WHITE), _gEndColor(cocos2d::Color3B::WHITE), @@ -66,7 +66,7 @@ UILayout* UILayout::create() return layout; } CC_SAFE_DELETE(layout); - return NULL; + return nullptr; } bool UILayout::init() @@ -165,7 +165,7 @@ void UILayout::setBackGroundImageScale9Enabled(bool able) return; } _renderer->removeChild(_backGroundImage, true); - _backGroundImage = NULL; + _backGroundImage = nullptr; _backGroundScale9Enabled = able; if (_backGroundScale9Enabled) { @@ -188,7 +188,7 @@ void UILayout::setBackGroundImage(const char* fileName,TextureResType texType) { return; } - if (_backGroundImage == NULL) + if (_backGroundImage == nullptr) { addBackGroundImage(); } @@ -305,7 +305,7 @@ void UILayout::removeBackGroundImage() return; } _renderer->removeChild(_backGroundImage, true); - _backGroundImage = NULL; + _backGroundImage = nullptr; _backGroundImageFileName = ""; _backGroundImageTextureSize = cocos2d::Size::ZERO; } @@ -322,26 +322,26 @@ void UILayout::setBackGroundColorType(LayoutBackGroundColorType type) if (_colorRender) { _renderer->removeChild(_colorRender, true); - _colorRender = NULL; + _colorRender = nullptr; } if (_gradientRender) { _renderer->removeChild(_gradientRender, true); - _gradientRender = NULL; + _gradientRender = nullptr; } break; case LAYOUT_COLOR_SOLID: if (_colorRender) { _renderer->removeChild(_colorRender, true); - _colorRender = NULL; + _colorRender = nullptr; } break; case LAYOUT_COLOR_GRADIENT: if (_gradientRender) { _renderer->removeChild(_gradientRender, true); - _gradientRender = NULL; + _gradientRender = nullptr; } break; default: @@ -596,8 +596,8 @@ void UILayout::doLayout() cocos2d::Size cs = child->getSize(); UIRelativeAlign align = layoutParameter->getAlign(); const char* relativeName = layoutParameter->getRelativeToWidgetName(); - UIWidget* relativeWidget = NULL; - UIRelativeLayoutParameter* relativeWidgetLP = NULL; + UIWidget* relativeWidget = nullptr; + UIRelativeLayoutParameter* relativeWidgetLP = nullptr; float finalPosX = 0.0f; float finalPosY = 0.0f; if (relativeName && strcmp(relativeName, "")) @@ -927,7 +927,7 @@ void UILayout::copySpecialProperties(UIWidget *widget) } UIRectClippingNode::UIRectClippingNode(): -_innerStencil(NULL), +_innerStencil(nullptr), _enabled(true), _clippingSize(cocos2d::Size(50.0f, 50.0f)), _clippingEnabled(false) diff --git a/cocos/gui/UILayoutParameter.cpp b/cocos/gui/UILayoutParameter.cpp index c468f69a24..dc15bf0dae 100644 --- a/cocos/gui/UILayoutParameter.cpp +++ b/cocos/gui/UILayoutParameter.cpp @@ -37,7 +37,7 @@ UILayoutParameter* UILayoutParameter::create() return parameter; } CC_SAFE_DELETE(parameter); - return NULL; + return nullptr; } void UILayoutParameter::setMargin(const UIMargin &margin) @@ -64,7 +64,7 @@ UILinearLayoutParameter* UILinearLayoutParameter::create() return parameter; } CC_SAFE_DELETE(parameter); - return NULL; + return nullptr; } void UILinearLayoutParameter::setGravity(UILinearGravity gravity) @@ -86,7 +86,7 @@ UIRelativeLayoutParameter* UIRelativeLayoutParameter::create() return parameter; } CC_SAFE_DELETE(parameter); - return NULL; + return nullptr; } void UIRelativeLayoutParameter::setAlign(UIRelativeAlign align) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index c6e076821d..47a579f908 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -29,12 +29,12 @@ namespace gui { UIListView::UIListView(): -_model(NULL), -_items(NULL), +_model(nullptr), +_items(nullptr), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), _itemsMargin(0.0f), -_listViewEventListener(NULL), -_listViewEventSelector(NULL), +_listViewEventListener(nullptr), +_listViewEventSelector(nullptr), _curSelectedIndex(0) { @@ -44,8 +44,8 @@ UIListView::~UIListView() { _items->removeAllObjects(); CC_SAFE_RELEASE(_items); - _listViewEventListener = NULL; - _listViewEventSelector = NULL; + _listViewEventListener = nullptr; + _listViewEventSelector = nullptr; } UIListView* UIListView::create() @@ -57,7 +57,7 @@ UIListView* UIListView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIListView::init() @@ -303,7 +303,7 @@ UIWidget* UIListView::getItem(unsigned int index) { if ((int)index < 0 || index >= _items->count()) { - return NULL; + return nullptr; } return (UIWidget*)(_items->data->arr[index]); } diff --git a/cocos/gui/UILoadingBar.cpp b/cocos/gui/UILoadingBar.cpp index 09b78c7b25..4f67f2423f 100644 --- a/cocos/gui/UILoadingBar.cpp +++ b/cocos/gui/UILoadingBar.cpp @@ -34,7 +34,7 @@ UILoadingBar::UILoadingBar(): _barType(LoadingBarTypeLeft), _percent(100), _totalLength(0), -_barRenderer(NULL), +_barRenderer(nullptr), _renderBarTexType(UI_TEX_TYPE_LOCAL), _barRendererTextureSize(cocos2d::Size::ZERO), _scale9Enabled(false), @@ -58,7 +58,7 @@ UILoadingBar* UILoadingBar::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UILoadingBar::initRenderer() @@ -179,7 +179,7 @@ void UILoadingBar::setScale9Enabled(bool enabled) } _scale9Enabled = enabled; _renderer->removeChild(_barRenderer, true); - _barRenderer = NULL; + _barRenderer = nullptr; if (_scale9Enabled) { _barRenderer = cocos2d::extension::Scale9Sprite::create(); diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index 823e997727..e23be185e1 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -28,13 +28,13 @@ namespace gui { UIPageView::UIPageView(): _curPageIdx(0), -_pages(NULL), +_pages(nullptr), _touchMoveDir(PAGEVIEW_TOUCHLEFT), _touchStartLocation(0.0f), _touchMoveStartLocation(0.0f), _movePagePoint(cocos2d::Point::ZERO), -_leftChild(NULL), -_rightChild(NULL), +_leftChild(nullptr), +_rightChild(nullptr), _leftBoundary(0.0f), _rightBoundary(0.0f), _isAutoScrolling(false), @@ -42,8 +42,8 @@ _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDir(0), _childFocusCancelOffset(5.0f), -_pageViewEventListener(NULL), -_pageViewEventSelector(NULL) +_pageViewEventListener(nullptr), +_pageViewEventSelector(nullptr) { } @@ -51,8 +51,8 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); - _pageViewEventListener = NULL; - _pageViewEventSelector = NULL; + _pageViewEventListener = nullptr; + _pageViewEventSelector = nullptr; } UIPageView* UIPageView::create() @@ -64,7 +64,7 @@ UIPageView* UIPageView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIPageView::init() @@ -229,8 +229,8 @@ void UIPageView::updateBoundaryPages() { if (_pages->count() <= 0) { - _leftChild = NULL; - _rightChild = NULL; + _leftChild = nullptr; + _rightChild = nullptr; return; } _leftChild = dynamic_cast(_pages->getObjectAtIndex(0)); @@ -595,7 +595,7 @@ UILayout* UIPageView::getPage(int index) { if (index < 0 || index >= (int)(_pages->count())) { - return NULL; + return nullptr; } return (UILayout*)_pages->getObjectAtIndex(index); } diff --git a/cocos/gui/UIRootWidget.cpp b/cocos/gui/UIRootWidget.cpp index 0b7581287f..4c3ad39210 100644 --- a/cocos/gui/UIRootWidget.cpp +++ b/cocos/gui/UIRootWidget.cpp @@ -43,7 +43,7 @@ UIRootWidget* UIRootWidget::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIRootWidget::init() diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index e80bd3873c..c9243712ad 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -34,7 +34,7 @@ const cocos2d::Point SCROLLDIR_LEFT = cocos2d::Point(-1.0f, 0.0f); const cocos2d::Point SCROLLDIR_RIGHT = cocos2d::Point(1.0f, 0.0f); UIScrollView::UIScrollView(): -_innerContainer(NULL), +_innerContainer(nullptr), _direction(SCROLLVIEW_DIR_VERTICAL), _touchBeganPoint(cocos2d::Point::ZERO), _touchMovedPoint(cocos2d::Point::ZERO), @@ -69,15 +69,15 @@ _bouncing(false), _bounceDir(cocos2d::Point::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), -_scrollViewEventListener(NULL), -_scrollViewEventSelector(NULL) +_scrollViewEventListener(nullptr), +_scrollViewEventSelector(nullptr) { } UIScrollView::~UIScrollView() { - _scrollViewEventListener = NULL; - _scrollViewEventSelector = NULL; + _scrollViewEventListener = nullptr; + _scrollViewEventSelector = nullptr; } UIScrollView* UIScrollView::create() @@ -89,7 +89,7 @@ UIScrollView* UIScrollView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIScrollView::init() diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index d8f2f95e86..5521770060 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -28,13 +28,13 @@ namespace gui { UISlider::UISlider(): -_barRenderer(NULL), -_progressBarRenderer(NULL), +_barRenderer(nullptr), +_progressBarRenderer(nullptr), _progressBarTextureSize(cocos2d::Size::ZERO), -_slidBallNormalRenderer(NULL), -_slidBallPressedRenderer(NULL), -_slidBallDisabledRenderer(NULL), -_slidBallRenderer(NULL), +_slidBallNormalRenderer(nullptr), +_slidBallPressedRenderer(nullptr), +_slidBallDisabledRenderer(nullptr), +_slidBallRenderer(nullptr), _barLength(0.0), _percent(0), _scale9Enabled(false), @@ -46,8 +46,8 @@ _slidBallPressedTextureFile(""), _slidBallDisabledTextureFile(""), _capInsetsBarRenderer(cocos2d::Rect::ZERO), _capInsetsProgressBarRenderer(cocos2d::Rect::ZERO), -_sliderEventListener(NULL), -_sliderEventSelector(NULL), +_sliderEventListener(nullptr), +_sliderEventSelector(nullptr), _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), @@ -58,8 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - _sliderEventListener = NULL; - _sliderEventSelector = NULL; + _sliderEventListener = nullptr; + _sliderEventSelector = nullptr; } UISlider* UISlider::create() @@ -71,7 +71,7 @@ UISlider* UISlider::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UISlider::initRenderer() @@ -198,8 +198,8 @@ void UISlider::setScale9Enabled(bool able) _scale9Enabled = able; _renderer->removeChild(_barRenderer, true); _renderer->removeChild(_progressBarRenderer, true); - _barRenderer = NULL; - _progressBarRenderer = NULL; + _barRenderer = nullptr; + _progressBarRenderer = nullptr; if (_scale9Enabled) { _barRenderer = cocos2d::extension::Scale9Sprite::create(); diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 75010d0261..4f6be40d32 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -57,7 +57,7 @@ UICCTextField * UICCTextField::create(const char *placeholder, const char *fontN } CC_SAFE_DELETE(pRet); - return NULL; + return nullptr; } void UICCTextField::onEnter() @@ -271,20 +271,20 @@ bool UICCTextField::getDeleteBackward() UITextField::UITextField(): -_textFieldRenderer(NULL), +_textFieldRenderer(nullptr), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), -_textFieldEventListener(NULL), -_textFieldEventSelector(NULL), +_textFieldEventListener(nullptr), +_textFieldEventSelector(nullptr), _passwordStyleText("") { } UITextField::~UITextField() { - _textFieldEventListener = NULL; - _textFieldEventSelector = NULL; + _textFieldEventListener = nullptr; + _textFieldEventSelector = nullptr; } UITextField* UITextField::create() @@ -296,7 +296,7 @@ UITextField* UITextField::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UITextField::init() diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 7ee89886ac..a597a04b7b 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -44,46 +44,46 @@ _touchPassedEnabled(false), _focus(false), _widgetZOrder(0), _anchorPoint(cocos2d::Point(0.5f, 0.5f)), -_widgetParent(NULL), +_widgetParent(nullptr), _brightStyle(BRIGHT_NONE), _updateEnabled(false), -_renderer(NULL), +_renderer(nullptr), _touchStartPos(cocos2d::Point::ZERO), _touchMovePos(cocos2d::Point::ZERO), _touchEndPos(cocos2d::Point::ZERO), -_touchEventListener(NULL), -_touchEventSelector(NULL), +_touchEventListener(nullptr), +_touchEventSelector(nullptr), _widgetTag(-1), _name("default"), _widgetType(WidgetTypeWidget), _actionTag(0), _size(cocos2d::Size::ZERO), _customSize(cocos2d::Size::ZERO), -_layoutParameterDictionary(NULL), +_layoutParameterDictionary(nullptr), _ignoreSize(false), -_children(NULL), +_children(nullptr), _affectByClipping(false), -_scheduler(NULL), +_scheduler(nullptr), _sizeType(SIZE_ABSOLUTE), _sizePercent(cocos2d::Point::ZERO), _positionType(POSITION_ABSOLUTE), _positionPercent(cocos2d::Point::ZERO), _isRunning(false), -_userObject(NULL) +_userObject(nullptr) { } UIWidget::~UIWidget() { - _touchEventListener = NULL; - _touchEventSelector = NULL; + _touchEventListener = nullptr; + _touchEventSelector = nullptr; removeAllChildren(); _children->release(); _renderer->removeAllChildrenWithCleanup(true); _renderer->removeFromParentAndCleanup(true); _renderer->release(); - setParent(NULL); + setParent(nullptr); _layoutParameterDictionary->removeAllObjects(); CC_SAFE_RELEASE(_layoutParameterDictionary); CC_SAFE_RELEASE(_scheduler); @@ -99,7 +99,7 @@ UIWidget* UIWidget::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIWidget::init() @@ -210,7 +210,7 @@ bool UIWidget::removeChild(UIWidget *child) child->onExit(); } child->setUpdateEnabled(false); - child->setParent(NULL); + child->setParent(nullptr); _renderer->removeChild(child->getRenderer()); _children->removeObject(child); return true; @@ -334,7 +334,7 @@ void UIWidget::setSize(const cocos2d::Size &size) } if (_isRunning) { - _sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); + _sizePercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); } onSizeChanged(); } @@ -345,7 +345,7 @@ void UIWidget::setSizePercent(const cocos2d::Point &percent) cocos2d::Size cSize = _customSize; if (_isRunning) { - cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y); + cSize = (_widgetParent == nullptr) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * percent.x , _widgetParent->getSize().height * percent.y); } if (_ignoreSize) { @@ -372,11 +372,11 @@ void UIWidget::updateSizeAndPosition() { _size = _customSize; } - _sizePercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); + _sizePercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); break; case SIZE_PERCENT: { - cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y); + cocos2d::Size cSize = (_widgetParent == nullptr) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y); if (_ignoreSize) { _size = getContentSize(); @@ -396,7 +396,7 @@ void UIWidget::updateSizeAndPosition() switch (_positionType) { case POSITION_ABSOLUTE: - _positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(absPos.x / _widgetParent->getSize().width, absPos.y / _widgetParent->getSize().height); + _positionPercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(absPos.x / _widgetParent->getSize().width, absPos.y / _widgetParent->getSize().height); break; case POSITION_PERCENT: { @@ -740,7 +740,7 @@ bool UIWidget::clippingParentAreaContainPoint(const cocos2d::Point &pt) { _affectByClipping = false; UIWidget* parent = getParent(); - UIWidget* clippingParent = NULL; + UIWidget* clippingParent = nullptr; while (parent) { UILayout* layoutParent = dynamic_cast(parent); @@ -790,7 +790,7 @@ void UIWidget::setPosition(const cocos2d::Point &pos) { if (_isRunning) { - _positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height); + _positionPercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height); } _renderer->setPosition(pos); } From 13756b7558fec815db974264ac2f3d52abfa5c00 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 11:52:52 +0800 Subject: [PATCH 158/185] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index eae59ddd9d..ad51d514c5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -595,6 +595,7 @@ Developers: [Android] added EGL_RENDERABLE_TYPE to OpenGL attributes Android: add xlargeScreens="true" to supports-screens Trigger onKeyReleased only after the key has been released. + Makes Colors are now comparable and explicit convertible bmanGH Use gl caching functions in TexturePVR::createGLTexture() From 063bc6b833f70ac5b886251aee0c41bdd7829492 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 11:54:54 +0800 Subject: [PATCH 159/185] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index d848fd916c..9a5fcc000f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support [NEW] GLProgram: setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv + [NEW] Color[3|4][B|F]: comparable and explicit convertible [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From 96462eb81fd1966171ab679fae5077c10f2a7112 Mon Sep 17 00:00:00 2001 From: rablwupei Date: Thu, 14 Nov 2013 12:03:44 +0800 Subject: [PATCH 160/185] fix bug: cccolor to jsval function has error in jsb --- .../javascript/bindings/js_manual_conversions.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index 0e3e20b617..411ce359ec 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp @@ -1024,8 +1024,8 @@ jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) { if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", INT_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } @@ -1037,8 +1037,8 @@ jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) { if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", DOUBLE_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(v.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } @@ -1050,7 +1050,7 @@ jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) { if (!tmp) return JSVAL_NULL; JSBool ok = JS_DefineProperty(cx, tmp, "r", INT_TO_JSVAL(v.r), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && JS_DefineProperty(cx, tmp, "g", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && - JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.g), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineProperty(cx, tmp, "b", INT_TO_JSVAL(v.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); if (ok) { return OBJECT_TO_JSVAL(tmp); } From 6602e781681c2ca5641a54c2841a58bbe6f3b96c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Nov 2013 12:22:47 +0800 Subject: [PATCH 161/185] Update AUTHORS [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index ad51d514c5..576904e3bf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -616,6 +616,7 @@ Developers: Added support of passing array to cc.Sequence.create and cc.Spawn.create. Fixed a bug that sys.localStorage.getItem() does not support non-ascii string. Fixed a memory leak in XMLHttpRequest. + Fixed a bug that wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval. Keita Obo (ktaobo) Avoid unnecessary object duplication for Scale9Sprite. From 1d0e42deac9874a21821afc221f6f48ffe1901a3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Nov 2013 12:30:38 +0800 Subject: [PATCH 162/185] Update CHANGELOG[ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 9a5fcc000f..ec818494f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -50,6 +50,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] cc.Scheduler.schedule(target, func) without repeat argument couldn't repeat schedule forever on device. [FIX] CCBReader can't play sequence automatically in JSB. [NEW] main.js -> cocos2d-jsb.js + [FIX] Wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval [Lua Binding] [NEW] Added Armature lua binding and added test samples. From 515d20d863bc9b51c38dd8c9366a996c6bb259cd Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 14 Nov 2013 04:32:48 +0000 Subject: [PATCH 163/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 3c656c5ae4..fd5a781004 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 3c656c5ae444653a31d3955ff4377eca3aadc08e +Subproject commit fd5a7810040fa83d083dc5384ae876f8e3e0847e From 14d51f9f35508dae8c12cbc5b2695982503c768e Mon Sep 17 00:00:00 2001 From: chengstory Date: Thu, 14 Nov 2013 13:28:42 +0800 Subject: [PATCH 164/185] fixed #3185 --- .../cocostudio/CCComAttribute.cpp | 129 +----------------- .../cocostudio/CCComAttribute.h | 17 +-- .../cocostudio/CCComController.h | 10 +- .../ComponentsTestScene.h | 2 +- .../EnemyController.h | 8 +- .../PlayerController.h | 10 +- .../ProjectileController.h | 8 +- .../SceneController.cpp | 6 +- .../SceneController.h | 8 +- 9 files changed, 28 insertions(+), 170 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index f3e57eddbc..16cd6d5a6c 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.cpp +++ b/cocos/editor-support/cocostudio/CCComAttribute.cpp @@ -28,8 +28,7 @@ using namespace cocos2d; namespace cocostudio { ComAttribute::ComAttribute(void) -: _attributes(NULL) -, _jsonDict(NULL) +: _jsonDict(NULL) { _name = "ComAttribute"; } @@ -37,14 +36,10 @@ ComAttribute::ComAttribute(void) ComAttribute::~ComAttribute(void) { CC_SAFE_DELETE(_jsonDict); - CC_SAFE_RELEASE(_attributes); } bool ComAttribute::init() { - _attributes = Dictionary::create(); - _attributes->retain(); - _jsonDict = new JsonDictionary(); return true; } @@ -63,128 +58,6 @@ ComAttribute* ComAttribute::create(void) return pRet; } -void ComAttribute::setInt(const char *key, int value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Integer::create(value), key); -} - -void ComAttribute::setDouble(const char *key, double value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Double::create(value), key); -} - -void ComAttribute::setFloat(const char *key, float value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Float::create(value), key); -} - -void ComAttribute::setBool(const char *key, bool value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Bool::create(value), key); -} - -void ComAttribute::setCString(const char *key, const char *value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(String::create(value), key); -} - -void ComAttribute::setObject(const char *key, Object *value) -{ - CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(value, key); -} - -int ComAttribute::getInt(const char *key) const -{ - Object *ret = _attributes->objectForKey(key); - if( ret ) - { - if( Integer *obj=dynamic_cast(ret) ) - return obj->getValue(); - - CCASSERT(false, "Key found, type is not integer"); - } - - // XXX: Should it throw an exception ? - CCLOG("Key not found: '%s'", key ); - return 0; -} - -double ComAttribute::getDouble(const char *key) const -{ - Object *ret = _attributes->objectForKey(key); - if( ret ) - { - if( Double *obj=dynamic_cast(ret) ) - return obj->getValue(); - - CCASSERT(false, "Key found, type is not double"); - } - - // XXX: Should it throw an exception ? - CCLOG("Key not found: '%s'", key ); - return 0.0; -} - -float ComAttribute::getFloat(const char *key) const -{ - Object *ret = _attributes->objectForKey(key); - if( ret ) - { - if( Float *obj=dynamic_cast(ret) ) - return obj->getValue(); - - CCASSERT(false, "Key found, type is not float"); - } - - // XXX: Should it throw an exception ? - CCLOG("Key not found: '%s'", key ); - return 0.0; -} - -bool ComAttribute::getBool(const char *key) const -{ - Object *ret = _attributes->objectForKey(key); - if( ret ) - { - if( Bool *boolobj=dynamic_cast(ret) ) - return boolobj->getValue(); - if( String *strobj=dynamic_cast(ret) ) - return strobj->boolValue(); - CCASSERT(false, "Key found, type is not Bool"); - } - - // XXX: Should it throw an exception ? - CCLOG("Key not found: '%s'", key ); - return false; -} - -const char* ComAttribute::getCString(const char *key) const -{ - Object *ret = _attributes->objectForKey(key); - if( ret ) - { - if( String *str=dynamic_cast(ret) ) - return str->getCString(); - - CCASSERT(false, "Key found, type is not CString"); - } - - // XXX: Should it throw an exception ? - CCLOG("Key not found: '%s'", key ); - return NULL; -} - -Object* ComAttribute::getObject(const char *key) const -{ - return _attributes->objectForKey(key); -} - JsonDictionary* ComAttribute::getDict() const { return _jsonDict; diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index 53c7c2c885..dcb1b177e3 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -47,24 +47,9 @@ protected: public: virtual bool init(); static ComAttribute* create(void); - - void setInt(const char *key, int value); - void setDouble(const char *key, double value); - void setFloat(const char *key, float value); - void setBool(const char *key, bool value); - void setCString(const char *key, const char *value); - void setObject(const char *key, Object *value); - - int getInt(const char *key) const; - double getDouble(const char *key) const; - float getFloat(const char *key) const; - bool getBool(const char *key) const; - const char* getCString(const char *key) const; - cocos2d::Object* getObject(const char *key) const; - JsonDictionary* getDict() const; + private: - cocos2d::Dictionary *_attributes; JsonDictionary *_jsonDict; }; diff --git a/cocos/editor-support/cocostudio/CCComController.h b/cocos/editor-support/cocostudio/CCComController.h index 00da3fa74f..a6a877f77e 100644 --- a/cocos/editor-support/cocostudio/CCComController.h +++ b/cocos/editor-support/cocostudio/CCComController.h @@ -32,7 +32,7 @@ namespace cocostudio { class ComController : public cocos2d::Component, public InputDelegate { -protected: +public: ComController(void); public: @@ -51,10 +51,10 @@ public: * @js NA * @lua NA */ - virtual void onExit(); - virtual void update(float delta); - virtual bool isEnabled() const; - virtual void setEnabled(bool b); + virtual void onExit() override; + virtual void update(float delta) override; + virtual bool isEnabled() const override; + virtual void setEnabled(bool b) override; static ComController* create(void); }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h index 152764c4bc..23c17932d8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h @@ -14,7 +14,7 @@ public: // Here's a difference. Method 'init' in cocos2d-x returns bool, // instead of returning 'id' in cocos2d-iphone - virtual bool init(); + virtual bool init() override; // there's no 'id' in cpp, so we recommand to return the exactly class pointer static cocos2d::Scene* scene(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h index 0025fd6309..790f9da45d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h @@ -13,10 +13,10 @@ protected: virtual ~EnemyController(void); public: - virtual bool init(); - virtual void onEnter(); - virtual void onExit(); - virtual void update(float delta); + virtual bool init() override; + virtual void onEnter() override; + virtual void onExit() override; + virtual void update(float delta) override; static EnemyController* create(void); public: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h index cc5233b539..7848ff1e08 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h @@ -13,13 +13,13 @@ protected: virtual ~PlayerController(void); public: - void onTouchesEnded(const std::vector& touches, cocos2d::Event *event) override; + virtual void onTouchesEnded(const std::vector& touches, cocos2d::Event *event) override; public: - virtual bool init(); - virtual void onEnter(); - virtual void onExit(); - virtual void update(float delta); + virtual bool init() override; + virtual void onEnter() override; + virtual void onExit() override; + virtual void update(float delta) override; static PlayerController* create(void); }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h index 7ae6b71ab1..55cd5cba78 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h @@ -12,10 +12,10 @@ protected: virtual ~ProjectileController(void); public: - virtual bool init(); - virtual void onEnter(); - virtual void onExit(); - virtual void update(float delta); + virtual bool init() override; + virtual void onEnter() override; + virtual void onExit() override; + virtual void update(float delta) override; static ProjectileController* create(void); public: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp index 92ee81267f..f432a09664 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp @@ -39,7 +39,7 @@ void SceneController::onEnter() _projectiles->retain(); ((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true); - ((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0); + ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getDict()->insertItem("KillCount", 0); } void SceneController::onExit() @@ -102,10 +102,10 @@ void SceneController::spriteMoveFinished(Node* sender) void SceneController::increaseKillCount() { - int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getInt("KillCount"); + int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getDict()->getItemIntValue("KillCount", -1); ComAttribute *p = (ComAttribute*)(_owner->getComponent("ComAttribute")); - p->setInt("KillCount", ++nProjectilesDestroyed); + p->getDict()->insertItem("KillCount", ++nProjectilesDestroyed); if (nProjectilesDestroyed >= 5) { diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h index 4d6efe0c89..b2d2769d2f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h @@ -12,10 +12,10 @@ protected: virtual ~SceneController(void); public: - virtual bool init(); - virtual void onEnter(); - virtual void onExit(); - virtual void update(float delta); + virtual bool init() override; + virtual void onEnter() override; + virtual void onExit() override; + virtual void update(float delta) override; static SceneController* create(void); From 46ef7a7fbc5e0bf8fc8f0ed23bf2465e78612b94 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 14 Nov 2013 13:35:17 +0800 Subject: [PATCH 165/185] Fix bug: deprecate old interface --- cocos/2d/ZipUtils.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cocos/2d/ZipUtils.h b/cocos/2d/ZipUtils.h index b635da18c3..c322f8300a 100644 --- a/cocos/2d/ZipUtils.h +++ b/cocos/2d/ZipUtils.h @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" +#include "CCPlatformMacros.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCFileUtilsAndroid.h" @@ -64,6 +65,7 @@ namespace cocos2d * @since v0.8.1 */ + CC_DEPRECATED_ATTRIBUTE static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out) { return inflateMemory(in, inLength, out); } static int inflateMemory(unsigned char *in, long inLength, unsigned char **out); /** @@ -76,7 +78,8 @@ namespace cocos2d * @since v1.0.0 */ - static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLenghtHint); + CC_DEPRECATED_ATTRIBUTE static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint) { return inflateMemoryWithHint(in, inLength, out, outLengthHint); } + static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint); /** inflates a GZip file into memory * @@ -84,6 +87,7 @@ namespace cocos2d * * @since v0.99.5 */ + CC_DEPRECATED_ATTRIBUTE static int ccInflateGZipFile(const char *filename, unsigned char **out) { return inflateGZipFile(filename, out); } static int inflateGZipFile(const char *filename, unsigned char **out); /** test a file is a GZip format file or not @@ -92,6 +96,7 @@ namespace cocos2d * * @since v3.0 */ + CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipFile(const char *filename) { return isGZipFile(filename); } static bool isGZipFile(const char *filename); /** test the buffer is GZip format or not @@ -100,6 +105,7 @@ namespace cocos2d * * @since v3.0 */ + CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipBuffer(const unsigned char *buffer, long len) { return isGZipBuffer(buffer, len); } static bool isGZipBuffer(const unsigned char *buffer, long len); /** inflates a CCZ file into memory @@ -108,6 +114,7 @@ namespace cocos2d * * @since v0.99.5 */ + CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZFile(const char *filename, unsigned char **out) { return inflateCCZFile(filename, out); } static int inflateCCZFile(const char *filename, unsigned char **out); /** inflates a buffer with CCZ format into memory @@ -116,6 +123,7 @@ namespace cocos2d * * @since v3.0 */ + CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out) { return inflateCCZBuffer(buffer, len, out); } static int inflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out); /** test a file is a CCZ format file or not @@ -124,6 +132,7 @@ namespace cocos2d * * @since v3.0 */ + CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZFile(const char *filename) { return isCCZFile(filename); } static bool isCCZFile(const char *filename); /** test the buffer is CCZ format or not @@ -132,6 +141,7 @@ namespace cocos2d * * @since v3.0 */ + CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZBuffer(const unsigned char *buffer, long len) { return isCCZBuffer(buffer, len); } static bool isCCZBuffer(const unsigned char *buffer, long len); /** Sets the pvr.ccz encryption key parts separately for added @@ -160,6 +170,7 @@ namespace cocos2d * @param index part of the key [0..3] * @param value value of the key part */ + CC_DEPRECATED_ATTRIBUTE static void ccSetPvrEncryptionKeyPart(int index, unsigned int value) { setPvrEncryptionKeyPart(index, value); } static void setPvrEncryptionKeyPart(int index, unsigned int value); /** Sets the pvr.ccz encryption key. @@ -184,6 +195,7 @@ namespace cocos2d * @param keyPart3 the key value part 3. * @param keyPart4 the key value part 4. */ + CC_DEPRECATED_ATTRIBUTE static void ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4) { setPvrEncryptionKey(keyPart1, keyPart2, keyPart3, keyPart4); } static void setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4); private: From 2432e6e40d383700a7f69abe211125e5283b0018 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 14 Nov 2013 13:42:10 +0800 Subject: [PATCH 166/185] add "override" --- cocos/gui/UIButton.h | 36 +++++++++++++-------------- cocos/gui/UICheckBox.h | 34 ++++++++++++------------- cocos/gui/UIImageView.h | 30 +++++++++++----------- cocos/gui/UILabel.h | 38 ++++++++++++++-------------- cocos/gui/UILabelAtlas.h | 20 +++++++-------- cocos/gui/UILabelBMFont.h | 16 ++++++------ cocos/gui/UILayer.h | 10 ++++---- cocos/gui/UILayout.h | 26 ++++++++++---------- cocos/gui/UIListView.cpp | 2 +- cocos/gui/UIListView.h | 22 ++++++++++------- cocos/gui/UILoadingBar.h | 16 ++++++------ cocos/gui/UIPageView.h | 47 ++++++++++++++++++----------------- cocos/gui/UIRootWidget.h | 4 +-- cocos/gui/UIScrollView.h | 52 +++++++++++++++++++-------------------- cocos/gui/UISlider.h | 30 +++++++++++----------- cocos/gui/UITextField.h | 26 ++++++++++---------- 16 files changed, 207 insertions(+), 202 deletions(-) diff --git a/cocos/gui/UIButton.h b/cocos/gui/UIButton.h index b069cbf5e0..85f67546f3 100644 --- a/cocos/gui/UIButton.h +++ b/cocos/gui/UIButton.h @@ -120,7 +120,7 @@ public: void setCapInsetsDisabledRenderer(const cocos2d::Rect &capInsets); //override "setAnchorPoint" of widget. - virtual void setAnchorPoint(const cocos2d::Point &pt); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; /** * Sets if button is using scale9 renderer. @@ -130,16 +130,16 @@ public: virtual void setScale9Enabled(bool able); //override "setFlipX" of widget. - virtual void setFlipX(bool flipX); + virtual void setFlipX(bool flipX) override; //override "setFlipY" of widget. - virtual void setFlipY(bool flipY); + virtual void setFlipY(bool flipY) override; //override "isFlipX" of widget. - virtual bool isFlipX(); + virtual bool isFlipX() override; //override "isFlipY" of widget. - virtual bool isFlipY(); + virtual bool isFlipY() override; /** * Changes if button can be clicked zoom effect. @@ -149,13 +149,13 @@ public: void setPressedActionEnabled(bool enabled); //override "ignoreContentAdaptWithSize" method of widget. - virtual void ignoreContentAdaptWithSize(bool ignore); + virtual void ignoreContentAdaptWithSize(bool ignore) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; /** * Sets color to widget @@ -164,12 +164,12 @@ public: * * @param color */ - virtual void setColor(const cocos2d::Color3B &color); + virtual void setColor(const cocos2d::Color3B &color) override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; void setTitleText(const std::string& text); const std::string& getTitleText() const; @@ -181,18 +181,18 @@ public: const char* getTitleFontName() const; protected: - virtual bool init(); - virtual void initRenderer(); - virtual void onPressStateChangedToNormal(); - virtual void onPressStateChangedToPressed(); - virtual void onPressStateChangedToDisabled(); - virtual void onSizeChanged(); + virtual bool init() override; + virtual void initRenderer() override; + virtual void onPressStateChangedToNormal() override; + virtual void onPressStateChangedToPressed() override; + virtual void onPressStateChangedToDisabled() override; + virtual void onSizeChanged() override; void normalTextureScaleChangedWithSize(); void pressedTextureScaleChangedWithSize(); void disabledTextureScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: cocos2d::Node* _buttonNormalRenderer; cocos2d::Node* _buttonClickedRenderer; diff --git a/cocos/gui/UICheckBox.h b/cocos/gui/UICheckBox.h index 26562d2b8f..7fd144c8f3 100644 --- a/cocos/gui/UICheckBox.h +++ b/cocos/gui/UICheckBox.h @@ -135,53 +135,53 @@ public: bool getSelectedState(); //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const cocos2d::Point &pt); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; //add a call back function would called when checkbox is selected or unselected. void addEventListenerCheckBox(cocos2d::Object* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. - virtual void setFlipX(bool flipX); + virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. - virtual void setFlipY(bool flipY); + virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. - virtual bool isFlipX(); + virtual bool isFlipX() override; //override "isFlipY" method of widget. - virtual bool isFlipY(); + virtual bool isFlipY() override; //override "onTouchEnded" method of widget. - virtual void onTouchEnded(const cocos2d::Point &touchPoint); + virtual void onTouchEnded(const cocos2d::Point &touchPoint) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual bool init(); - virtual void initRenderer(); - virtual void onPressStateChangedToNormal(); - virtual void onPressStateChangedToPressed(); - virtual void onPressStateChangedToDisabled(); + virtual bool init() override; + virtual void initRenderer() override; + virtual void onPressStateChangedToNormal() override; + virtual void onPressStateChangedToPressed() override; + virtual void onPressStateChangedToDisabled() override; void selectedEvent(); void unSelectedEvent(); - virtual void onSizeChanged(); + virtual void onSizeChanged() override; void backGroundTextureScaleChangedWithSize(); void backGroundSelectedTextureScaleChangedWithSize(); void frontCrossTextureScaleChangedWithSize(); void backGroundDisabledTextureScaleChangedWithSize(); void frontCrossDisabledTextureScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: cocos2d::Sprite* _backGroundBoxRenderer; cocos2d::Sprite* _backGroundSelectedBoxRenderer; diff --git a/cocos/gui/UIImageView.h b/cocos/gui/UIImageView.h index 16103aa256..cd7d761497 100644 --- a/cocos/gui/UIImageView.h +++ b/cocos/gui/UIImageView.h @@ -81,45 +81,45 @@ public: void setCapInsets(const cocos2d::Rect &capInsets); //override "setFlipX" method of widget. - virtual void setFlipX(bool flipX); + virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. - virtual void setFlipY(bool flipY); + virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. - virtual bool isFlipX(); + virtual bool isFlipX() override; //override "isFlipY" method of widget. - virtual bool isFlipY(); + virtual bool isFlipY() override; //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const cocos2d::Point &pt); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; //override "onTouchBegan" method of widget. - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override; //override "onTouchEnded" method of widget. - virtual void onTouchEnded(const cocos2d::Point &touchPoint); + virtual void onTouchEnded(const cocos2d::Point &touchPoint) override; //override "ignoreContentAdaptWithSize" method of widget. - virtual void ignoreContentAdaptWithSize(bool ignore); + virtual void ignoreContentAdaptWithSize(bool ignore) override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; void setDoubleClickEnabled(bool able); void doubleClickEvent(); void checkDoubleClick(float dt); - virtual const cocos2d::Size& getContentSize() const; - virtual cocos2d::Node* getVirtualRenderer(); + virtual const cocos2d::Size& getContentSize() const override; + virtual cocos2d::Node* getVirtualRenderer() override; protected: - virtual void initRenderer(); - virtual void onSizeChanged(); + virtual void initRenderer() override; + virtual void onSizeChanged() override; void imageTextureScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: int _clickCount; float _clickTimeInterval; diff --git a/cocos/gui/UILabel.h b/cocos/gui/UILabel.h index e029a5b920..58e6d11a7a 100644 --- a/cocos/gui/UILabel.h +++ b/cocos/gui/UILabel.h @@ -108,7 +108,7 @@ public: * * @param scale The scale factor for both X and Y axis. */ - virtual void setScale(float fScale); + virtual void setScale(float fScale) override; /** * Changes the scale factor on X axis of this widget @@ -117,7 +117,7 @@ public: * * @param fScaleX The scale factor on X axis. */ - virtual void setScaleX(float fScaleX); + virtual void setScaleX(float fScaleX) override; /** * Changes the scale factor on Y axis of this widget @@ -126,49 +126,49 @@ public: * * @param fScaleY The scale factor on Y axis. */ - virtual void setScaleY(float fScaleY); + virtual void setScaleY(float fScaleY) override; //override "setFlipX" method of widget. - virtual void setFlipX(bool flipX); + virtual void setFlipX(bool flipX) override; //override "setFlipY" method of widget. - virtual void setFlipY(bool flipY); + virtual void setFlipY(bool flipY) override; //override "isFlipX" method of widget. - virtual bool isFlipX(); + virtual bool isFlipX() override; //override "isFlipY" method of widget. - virtual bool isFlipY(); + virtual bool isFlipY() override; //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const cocos2d::Point &pt); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; void setTextAreaSize(const cocos2d::Size &size); void setTextHorizontalAlignment(cocos2d::TextHAlignment alignment); void setTextVerticalAlignment(cocos2d::TextVAlignment alignment); protected: - virtual bool init(); - virtual void initRenderer(); - virtual void onPressStateChangedToNormal(); - virtual void onPressStateChangedToPressed(); - virtual void onPressStateChangedToDisabled(); - virtual void onSizeChanged(); + virtual bool init() override; + virtual void initRenderer() override; + virtual void onPressStateChangedToNormal() override; + virtual void onPressStateChangedToPressed() override; + virtual void onPressStateChangedToDisabled() override; + virtual void onSizeChanged() override; void clickScale(float scaleX, float scaleY); void labelScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: bool _touchScaleChangeEnabled; float _normalScaleValueX; diff --git a/cocos/gui/UILabelAtlas.h b/cocos/gui/UILabelAtlas.h index a33872ef0c..1db648884f 100644 --- a/cocos/gui/UILabelAtlas.h +++ b/cocos/gui/UILabelAtlas.h @@ -52,8 +52,8 @@ public: static UICCLabelAtlas* create(); void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); void setProperty(const std::string& string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - virtual void updateDisplayedOpacity(GLubyte opacity); - virtual void draw(void); + virtual void updateDisplayedOpacity(GLubyte opacity) override; + virtual void draw(void) override; }; /** * @js NA @@ -87,25 +87,25 @@ public: const std::string& getStringValue() const; //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const cocos2d::Point &pt); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual void initRenderer(); - virtual void onSizeChanged(); + virtual void initRenderer() override; + virtual void onSizeChanged() override; void labelAtlasScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: UICCLabelAtlas* _laberAtlasRenderer; std::string _stringValue; diff --git a/cocos/gui/UILabelBMFont.h b/cocos/gui/UILabelBMFont.h index 5c03c1ae75..64695ddd84 100644 --- a/cocos/gui/UILabelBMFont.h +++ b/cocos/gui/UILabelBMFont.h @@ -59,19 +59,19 @@ public: /** get string value for labelbmfont*/ const char* getStringValue(); - virtual void setAnchorPoint(const cocos2d::Point &pt); - virtual const cocos2d::Size& getContentSize() const; - virtual cocos2d::Node* getVirtualRenderer(); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; + virtual const cocos2d::Size& getContentSize() const override; + virtual cocos2d::Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual void initRenderer(); - virtual void onSizeChanged(); + virtual void initRenderer() override; + virtual void onSizeChanged() override; void labelBMFontScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: cocos2d::LabelBMFont* _labelBMFontRenderer; bool _fntFileHasInit; diff --git a/cocos/gui/UILayer.h b/cocos/gui/UILayer.h index 6a041dda4a..2ed91b77de 100644 --- a/cocos/gui/UILayer.h +++ b/cocos/gui/UILayer.h @@ -53,11 +53,11 @@ public: static UILayer *create(void); //initializes state of uilayer. - virtual bool init(); + virtual bool init() override; - virtual void onEnter(); - virtual void onExit(); - virtual void onEnterTransitionDidFinish(); + virtual void onEnter() override; + virtual void onExit() override; + virtual void onEnterTransitionDidFinish() override; virtual bool onTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); virtual void onTouchMoved(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); @@ -87,7 +87,7 @@ public: * * @param visible true if the UILayer is visible, false if the UILayer is hidden. */ - virtual void setVisible(bool visible); + virtual void setVisible(bool visible) override; /** * Finds a widget whose tag is equal tag param from widget tree. diff --git a/cocos/gui/UILayout.h b/cocos/gui/UILayout.h index 918bd868af..f53480d4dd 100644 --- a/cocos/gui/UILayout.h +++ b/cocos/gui/UILayout.h @@ -68,7 +68,7 @@ public: static UILayout* create(); //override "hitTest" method of widget. - virtual bool hitTest(const cocos2d::Point &pt); + virtual bool hitTest(const cocos2d::Point &pt) override; //background /** @@ -133,10 +133,10 @@ public: void setBackGroundColorVector(const cocos2d::Point &vector); //override "setColor" method of widget. - virtual void setColor(const cocos2d::Color3B &color); + virtual void setColor(const cocos2d::Color3B &color) override; //override "setOpacity" method of widget. - virtual void setOpacity(int opacity); + virtual void setOpacity(int opacity) override; /** * Remove the background image of layout. @@ -157,7 +157,7 @@ public: * * @param clipping enabled. */ - virtual void setClippingEnabled(bool able); + virtual void setClippingEnabled(bool enabled); /** * Gets if layout is clipping enabled. @@ -171,12 +171,12 @@ public: * * Content size is widget's texture size. */ - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; /** * Sets LayoutType. @@ -203,25 +203,25 @@ public: * * @param child A child widget */ - virtual bool addChild(UIWidget* child); + virtual bool addChild(UIWidget* child) override; protected: //override "init" method of widget. - virtual bool init(); + virtual bool init() override; //override "initRenderer" method of widget. - virtual void initRenderer(); + virtual void initRenderer() override; //override "onSizeChanged" method of widget. - virtual void onSizeChanged(); + virtual void onSizeChanged() override; //init background image renderer. void addBackGroundImage(); void supplyTheLayoutParameterLackToChild(UIWidget* child); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); - virtual void copyClonedWidgetChildren(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; + virtual void copyClonedWidgetChildren(UIWidget* model) override; protected: bool _clippingEnabled; diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 47a579f908..8e45662c3e 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -393,7 +393,7 @@ void UIListView::selectedItemEvent() { if (_listViewEventListener && _listViewEventSelector) { - (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECEDTITEM); + (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM); } } diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index 42fd7f15be..14b91806b8 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -43,7 +43,7 @@ typedef enum typedef enum { - LISTVIEW_ONSELECEDTITEM + LISTVIEW_ONSELECTEDITEM }ListViewEventType; typedef void (cocos2d::Object::*SEL_ListViewEvent)(cocos2d::Object*,ListViewEventType); @@ -164,20 +164,24 @@ public: * * @param SCROLLVIEW_DIR */ - virtual void setDirection(SCROLLVIEW_DIR dir); + virtual void setDirection(SCROLLVIEW_DIR dir) override; - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual bool init(); + virtual bool addChild(UIWidget* widget) override{return UIScrollView::addChild(widget);}; + virtual bool removeChild(UIWidget* widget) override{return UIScrollView::removeChild(widget);}; + virtual void removeAllChildren() override{UIScrollView::removeAllChildren();}; + virtual cocos2d::Array* getChildren() override{return UIScrollView::getChildren();}; + virtual bool init() override; void updateInnerContainerSize(); void remedyLayoutParameter(UIWidget* item); - virtual void onSizeChanged(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); - virtual void copyClonedWidgetChildren(UIWidget* model); + virtual void onSizeChanged() override; + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; + virtual void copyClonedWidgetChildren(UIWidget* model) override; void selectedItemEvent(); - virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint); + virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override; protected: UIWidget* _model; diff --git a/cocos/gui/UILoadingBar.h b/cocos/gui/UILoadingBar.h index 81c5722b4b..0a0f210357 100644 --- a/cocos/gui/UILoadingBar.h +++ b/cocos/gui/UILoadingBar.h @@ -112,25 +112,25 @@ public: void setCapInsets(const cocos2d::Rect &capInsets); //override "ignoreContentAdaptWithSize" method of widget. - virtual void ignoreContentAdaptWithSize(bool ignore); + virtual void ignoreContentAdaptWithSize(bool ignore) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual void initRenderer(); - virtual void onSizeChanged(); + virtual void initRenderer() override; + virtual void onSizeChanged() override; void setScale9Scale(); void barRendererScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: LoadingBarType _barType; int _percent; diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index e5aac237d4..99ae26deb6 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -128,21 +128,21 @@ public: //override "onTouchBegan" method of widget. - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override; //override "onTouchMoved" method of widget. - virtual void onTouchMoved(const cocos2d::Point &touchPoint); + virtual void onTouchMoved(const cocos2d::Point &touchPoint) override; //override "onTouchEnded" method of widget. - virtual void onTouchEnded(const cocos2d::Point &touchPoint); + virtual void onTouchEnded(const cocos2d::Point &touchPoint) override; //override "onTouchCancelled" method of widget. - virtual void onTouchCancelled(const cocos2d::Point &touchPoint); + virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override; //override "update" method of widget. - virtual void update(float dt); + virtual void update(float dt) override; - virtual void doLayout(){}; + virtual void doLayout() override{}; /** * Sets LayoutType. @@ -151,7 +151,7 @@ public: * * @param LayoutType */ - virtual void setLayoutType(LayoutType type){}; + virtual void setLayoutType(LayoutType type) override{}; /** * Gets LayoutType. @@ -160,36 +160,37 @@ public: * * @return LayoutType */ - virtual LayoutType getLayoutType() const{return LAYOUT_ABSOLUTE;}; + virtual LayoutType getLayoutType() const override{return LAYOUT_ABSOLUTE;}; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual bool addChild(UIWidget* widget); - virtual bool removeChild(UIWidget* widget); - virtual void removeAllChildren(); - virtual bool init(); + virtual bool addChild(UIWidget* widget) override; + virtual bool removeChild(UIWidget* widget) override; + virtual void removeAllChildren() override; + virtual cocos2d::Array* getChildren() override{return UIWidget::getChildren();}; + virtual bool init() override; UILayout* createPage(); float getPositionXByIndex(int idx); void updateBoundaryPages(); - virtual void handlePressLogic(const cocos2d::Point &touchPoint); - virtual void handleMoveLogic(const cocos2d::Point &touchPoint); - virtual void handleReleaseLogic(const cocos2d::Point &touchPoint); - virtual void interceptTouchEvent(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint); - virtual void checkChildInfo(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint); + virtual void handlePressLogic(const cocos2d::Point &touchPoint) override; + virtual void handleMoveLogic(const cocos2d::Point &touchPoint) override; + virtual void handleReleaseLogic(const cocos2d::Point &touchPoint) override; + virtual void interceptTouchEvent(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint) override; + virtual void checkChildInfo(int handleState, UIWidget* sender, const cocos2d::Point &touchPoint) override; virtual bool scrollPages(float touchOffset); void movePages(float offset); void pageTurningEvent(); void updateChildrenSize(); void updateChildrenPosition(); - virtual void onSizeChanged(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); - virtual void copyClonedWidgetChildren(UIWidget* model); - virtual void setClippingEnabled(bool able){UILayout::setClippingEnabled(able);}; + virtual void onSizeChanged() override; + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; + virtual void copyClonedWidgetChildren(UIWidget* model) override; + virtual void setClippingEnabled(bool enabled) override {UILayout::setClippingEnabled(enabled);}; protected: int _curPageIdx; cocos2d::Array* _pages; diff --git a/cocos/gui/UIRootWidget.h b/cocos/gui/UIRootWidget.h index dc93ac4645..c13beb247c 100644 --- a/cocos/gui/UIRootWidget.h +++ b/cocos/gui/UIRootWidget.h @@ -54,10 +54,10 @@ public: /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: //initializes state of widget. - virtual bool init(); + virtual bool init() override; }; } diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 94a6874376..09fc21a7a8 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -234,33 +234,33 @@ public: void addEventListenerScrollView(cocos2d::Object* target, SEL_ScrollViewEvent selector); //override "addChild" method of widget. - virtual bool addChild(UIWidget* widget); + virtual bool addChild(UIWidget* widget) override; //override "removeAllChildrenAndCleanUp" method of widget. - virtual void removeAllChildren(); + virtual void removeAllChildren() override; //override "removeChild" method of widget. - virtual bool removeChild(UIWidget* child); + virtual bool removeChild(UIWidget* child) override; //override "getChildren" method of widget. - virtual cocos2d::Array* getChildren(); + virtual cocos2d::Array* getChildren() override; //override "onTouchBegan" method of widget. - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override; //override "onTouchMoved" method of widget. - virtual void onTouchMoved(const cocos2d::Point &touchPoint); + virtual void onTouchMoved(const cocos2d::Point &touchPoint) override; //override "onTouchEnded" method of widget. - virtual void onTouchEnded(const cocos2d::Point &touchPoint); + virtual void onTouchEnded(const cocos2d::Point &touchPoint) override; //override "onTouchCancelled" method of widget. - virtual void onTouchCancelled(const cocos2d::Point &touchPoint); + virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override; //override "onTouchLongClicked" method of widget. - virtual void onTouchLongClicked(const cocos2d::Point &touchPoint); + virtual void onTouchLongClicked(const cocos2d::Point &touchPoint) override; - virtual void update(float dt); + virtual void update(float dt) override; void setBounceEnabled(bool enabled); @@ -277,7 +277,7 @@ public: * * @param LayoutType */ - virtual void setLayoutType(LayoutType type); + virtual void setLayoutType(LayoutType type) override; /** * Gets LayoutType. @@ -286,17 +286,17 @@ public: * * @return LayoutType */ - virtual LayoutType getLayoutType() const; + virtual LayoutType getLayoutType() const override; - virtual void doLayout(); + virtual void doLayout() override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual bool init(); - virtual void initRenderer(); + virtual bool init() override; + virtual void initRenderer() override; void moveChildren(float offsetX, float offsetY); void autoScrollChildren(float dt); void bounceChildren(float dt); @@ -313,11 +313,11 @@ protected: bool bounceScrollChildren(float touchOffsetX, float touchOffsetY); void startRecordSlidAction(); virtual void endRecordSlidAction(); - virtual void handlePressLogic(const cocos2d::Point &touchPoint); - virtual void handleMoveLogic(const cocos2d::Point &touchPoint); - virtual void handleReleaseLogic(const cocos2d::Point &touchPoint); - virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint); - virtual void checkChildInfo(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint); + virtual void handlePressLogic(const cocos2d::Point &touchPoint) override; + virtual void handleMoveLogic(const cocos2d::Point &touchPoint) override; + virtual void handleReleaseLogic(const cocos2d::Point &touchPoint) override; + virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override; + virtual void checkChildInfo(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint) override; void recordSlidTime(float dt); void scrollToTopEvent(); void scrollToBottomEvent(); @@ -328,11 +328,11 @@ protected: void bounceBottomEvent(); void bounceLeftEvent(); void bounceRightEvent(); - virtual void onSizeChanged(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); - virtual void copyClonedWidgetChildren(UIWidget* model); - virtual void setClippingEnabled(bool able){UILayout::setClippingEnabled(able);}; + virtual void onSizeChanged() override; + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; + virtual void copyClonedWidgetChildren(UIWidget* model) override; + virtual void setClippingEnabled(bool able) override{UILayout::setClippingEnabled(able);}; protected: UILayout* _innerContainer; diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index ff08ba1524..d4c09c5fdf 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -165,43 +165,43 @@ public: void addEventListenerSlider(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); //override "onTouchBegan" method of widget. - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override; //override "onTouchMoved" method of widget. - virtual void onTouchMoved(const cocos2d::Point &touchPoint); + virtual void onTouchMoved(const cocos2d::Point &touchPoint) override; //override "onTouchEnded" method of widget. - virtual void onTouchEnded(const cocos2d::Point &touchPoint); + virtual void onTouchEnded(const cocos2d::Point &touchPoint) override; //override "onTouchCancelled" method of widget. - virtual void onTouchCancelled(const cocos2d::Point &touchPoint); + virtual void onTouchCancelled(const cocos2d::Point &touchPoint) override; //override "getContentSize" method of widget. - virtual const cocos2d::Size& getContentSize() const; + virtual const cocos2d::Size& getContentSize() const override; //override "getVirtualRenderer" method of widget. - virtual cocos2d::Node* getVirtualRenderer(); + virtual cocos2d::Node* getVirtualRenderer() override; //override "ignoreContentAdaptWithSize" method of widget. - virtual void ignoreContentAdaptWithSize(bool ignore); + virtual void ignoreContentAdaptWithSize(bool ignore) override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; protected: - virtual void initRenderer(); + virtual void initRenderer() override; float getPercentWithBallPos(float location); void percentChangedEvent(); - virtual void onPressStateChangedToNormal(); - virtual void onPressStateChangedToPressed(); - virtual void onPressStateChangedToDisabled(); - virtual void onSizeChanged(); + virtual void onPressStateChangedToNormal() override; + virtual void onPressStateChangedToPressed() override; + virtual void onPressStateChangedToDisabled() override; + virtual void onSizeChanged() override; void barRendererScaleChangedWithSize(); void progressBarRendererScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: cocos2d::Node* _barRenderer; cocos2d::Node* _progressBarRenderer; diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index 6a61faed08..23ee0bcb6b 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -106,8 +106,8 @@ public: UITextField(); virtual ~UITextField(); static UITextField* create(); - virtual bool init(); - virtual void initRenderer(); + virtual bool init() override; + virtual void initRenderer() override; void setTouchSize(const cocos2d::Size &size); void setText(const std::string& text); void setPlaceHolder(const std::string& value); @@ -115,7 +115,7 @@ public: void setFontName(const std::string& name); virtual void didNotSelectSelf(); const std::string& getStringValue(); - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + virtual bool onTouchBegan(const cocos2d::Point &touchPoint) override; void setMaxLengthEnabled(bool enable); bool isMaxLengthEnabled(); void setMaxLength(int length); @@ -123,7 +123,7 @@ public: void setPasswordEnabled(bool enable); bool isPasswordEnabled(); void setPasswordStyleText(const char* styleText); - virtual void update(float dt); + virtual void update(float dt) override; bool getAttachWithIME(); void setAttachWithIME(bool attach); bool getDetachWithIME(); @@ -134,17 +134,17 @@ public: void setDeleteBackward(bool deleteBackward); void addEventListenerTextField(cocos2d::Object* target, SEL_TextFieldEvent selecor); - virtual void setAnchorPoint(const cocos2d::Point &pt); - virtual void setColor(const cocos2d::Color3B &color); - virtual void setOpacity(int opacity); + virtual void setAnchorPoint(const cocos2d::Point &pt) override; + virtual void setColor(const cocos2d::Color3B &color) override; + virtual void setOpacity(int opacity) override; /** * Returns the "class name" of widget. */ - virtual const char* getDescription() const; + virtual const char* getDescription() const override; - virtual const cocos2d::Size& getContentSize() const; - virtual cocos2d::Node* getVirtualRenderer(); + virtual const cocos2d::Size& getContentSize() const override; + virtual cocos2d::Node* getVirtualRenderer() override; void attachWithIME(); protected: // event @@ -152,10 +152,10 @@ protected: void detachWithIMEEvent(); void insertTextEvent(); void deleteBackwardEvent(); - virtual void onSizeChanged(); + virtual void onSizeChanged() override; void textfieldRendererScaleChangedWithSize(); - virtual UIWidget* createCloneInstance(); - virtual void copySpecialProperties(UIWidget* model); + virtual UIWidget* createCloneInstance() override; + virtual void copySpecialProperties(UIWidget* model) override; protected: UICCTextField* _textFieldRenderer; From e9f5e889d636ce4f5b0f64fb2dc12871de471dfd Mon Sep 17 00:00:00 2001 From: chengstory Date: Thu, 14 Nov 2013 14:05:24 +0800 Subject: [PATCH 167/185] fixed #3185 replace NULL to nullptr. --- .../cocostudio/CCComAttribute.cpp | 2 +- .../editor-support/cocostudio/CCComRender.cpp | 2 +- .../cocostudio/CCSSceneReader.cpp | 68 +++++++++---------- .../cocostudio/CSContentJsonDictionary.cpp | 12 ++-- .../cocostudio/DictionaryHelper.cpp | 28 ++++---- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index 16cd6d5a6c..cd20cf3c02 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.cpp +++ b/cocos/editor-support/cocostudio/CCComAttribute.cpp @@ -28,7 +28,7 @@ using namespace cocos2d; namespace cocostudio { ComAttribute::ComAttribute(void) -: _jsonDict(NULL) +: _jsonDict(nullptr) { _name = "ComAttribute"; } diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index 95465444ea..76e549761c 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. namespace cocostudio { ComRender::ComRender(void) -: _render(NULL) +: _render(nullptr) { } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 71134ed58e..452bfca276 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -30,7 +30,7 @@ using namespace gui; namespace cocostudio { - SceneReader* SceneReader::s_sharedReader = NULL; + SceneReader* SceneReader::s_sharedReader = nullptr; SceneReader::SceneReader() { @@ -49,14 +49,14 @@ namespace cocostudio { { long size = 0; const char* pData = 0; - cocos2d::Node *pNode = NULL; + cocos2d::Node *pNode = nullptr; do { - CC_BREAK_IF(pszFileName == NULL); + CC_BREAK_IF(pszFileName == nullptr); pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size)); - CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); + CC_BREAK_IF(pData == nullptr || strcmp(pData, "") == 0); JsonDictionary *jsonDict = new JsonDictionary(); jsonDict->initWithDescription(pData); - pNode = createObject(jsonDict,NULL); + pNode = createObject(jsonDict,nullptr); CC_SAFE_DELETE(jsonDict); } while (0); @@ -68,8 +68,8 @@ namespace cocostudio { const char *className = inputFiles->getItemStringValue("classname"); if(strcmp(className, "CCNode") == 0) { - Node* gb = NULL; - if(NULL == parenet) + Node* gb = nullptr; + if(nullptr == parenet) { gb = Node::create(); } @@ -97,26 +97,26 @@ namespace cocostudio { std::string pPath; std::string pPlistFile; int nResType = 0; - if (fileData != NULL) + if (fileData != nullptr) { const char *file = fileData->getItemStringValue("path"); nResType = fileData->getItemIntValue("resourceType", -1); const char *plistFile = fileData->getItemStringValue("plistFile"); - if (file != NULL) + if (file != nullptr) { pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); } - if (plistFile != NULL) + if (plistFile != nullptr) { pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile)); } CC_SAFE_DELETE(fileData); } - if (comName != NULL && strcmp(comName, "CCSprite") == 0) + if (comName != nullptr && strcmp(comName, "CCSprite") == 0) { - cocos2d::Sprite *pSprite = NULL; + cocos2d::Sprite *pSprite = nullptr; if (nResType == 0) { @@ -144,16 +144,16 @@ namespace cocostudio { } ComRender *pRender = ComRender::create(pSprite, "CCSprite"); - if (pComName != NULL) + if (pComName != nullptr) { pRender->setName(pComName); } gb->addComponent(pRender); } - else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0) + else if(comName != nullptr && strcmp(comName, "CCTMXTiledMap") == 0) { - cocos2d::TMXTiledMap *pTmx = NULL; + cocos2d::TMXTiledMap *pTmx = nullptr; if (nResType == 0) { if (pPath.find(".tmx") == pPath.npos) @@ -168,13 +168,13 @@ namespace cocostudio { } ComRender *pRender = ComRender::create(pTmx, "CCTMXTiledMap"); - if (pComName != NULL) + if (pComName != nullptr) { pRender->setName(pComName); } gb->addComponent(pRender); } - else if(comName != NULL && strcmp(comName, "CCParticleSystemQuad") == 0) + else if(comName != nullptr && strcmp(comName, "CCParticleSystemQuad") == 0) { std::string::size_type pos = pPath.find(".plist"); if (pos == pPath.npos) @@ -182,7 +182,7 @@ namespace cocostudio { continue; } - cocos2d::ParticleSystemQuad *pParticle = NULL; + cocos2d::ParticleSystemQuad *pParticle = nullptr; if (nResType == 0) { pParticle = ParticleSystemQuad::create(pPath.c_str()); @@ -194,13 +194,13 @@ namespace cocostudio { pParticle->setPosition(0, 0); ComRender *pRender = ComRender::create(pParticle, "CCParticleSystemQuad"); - if (pComName != NULL) + if (pComName != nullptr) { pRender->setName(pComName); } gb->addComponent(pRender); } - else if(comName != NULL && strcmp(comName, "CCArmature") == 0) + else if(comName != nullptr && strcmp(comName, "CCArmature") == 0) { if (nResType != 0) { @@ -217,7 +217,7 @@ namespace cocostudio { const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size)); JsonDictionary *jsonDict = new JsonDictionary(); jsonDict->initWithDescription(des); - if(NULL == des || strcmp(des, "") == 0) + if(nullptr == des || strcmp(des, "") == 0) { CCLOG("read json file[%s] error!\n", pPath.c_str()); } @@ -247,14 +247,14 @@ namespace cocostudio { Armature *pAr = Armature::create(name); ComRender *pRender = ComRender::create(pAr, "CCArmature"); - if (pComName != NULL) + if (pComName != nullptr) { pRender->setName(pComName); } gb->addComponent(pRender); const char *actionName = subDict->getItemStringValue("selectedactionname"); - if (actionName != NULL && pAr->getAnimation() != NULL) + if (actionName != nullptr && pAr->getAnimation() != nullptr) { pAr->getAnimation()->play(actionName); } @@ -263,9 +263,9 @@ namespace cocostudio { CC_SAFE_DELETE(subData); CC_SAFE_DELETE_ARRAY(des); } - else if(comName != NULL && strcmp(comName, "CCComAudio") == 0) + else if(comName != nullptr && strcmp(comName, "CCComAudio") == 0) { - ComAudio *pAudio = NULL; + ComAudio *pAudio = nullptr; if (nResType == 0) { pAudio = ComAudio::create(); @@ -277,16 +277,16 @@ namespace cocostudio { pAudio->preloadEffect(pPath.c_str()); gb->addComponent(pAudio); } - else if(comName != NULL && strcmp(comName, "CCComAttribute") == 0) + else if(comName != nullptr && strcmp(comName, "CCComAttribute") == 0) { - ComAttribute *pAttribute = NULL; + ComAttribute *pAttribute = nullptr; if (nResType == 0) { pAttribute = ComAttribute::create(); long size = 0; const char* pData = 0; pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size)); - if(pData != NULL && strcmp(pData, "") != 0) + if(pData != nullptr && strcmp(pData, "") != 0) { pAttribute->getDict()->initWithDescription(pData); } @@ -298,9 +298,9 @@ namespace cocostudio { } gb->addComponent(pAttribute); } - else if (comName != NULL && strcmp(comName, "CCBackgroundAudio") == 0) + else if (comName != nullptr && strcmp(comName, "CCBackgroundAudio") == 0) { - ComAudio *pAudio = NULL; + ComAudio *pAudio = nullptr; if (nResType == 0) { pAudio = ComAudio::create(); @@ -316,14 +316,14 @@ namespace cocostudio { gb->addComponent(pAudio); pAudio->playBackgroundMusic(pPath.c_str(), bLoop); } - else if(comName != NULL && strcmp(comName, "GUIComponent") == 0) + else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0) { gui::UILayer *pLayer = gui::UILayer::create(); pLayer->scheduleUpdate(); UIWidget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str()); pLayer->addWidget(widget); ComRender *pRender = ComRender::create(pLayer, "GUIComponent"); - if (pComName != NULL) + if (pComName != nullptr) { pRender->setName(pComName); } @@ -347,7 +347,7 @@ namespace cocostudio { return gb; } - return NULL; + return nullptr; } @@ -377,7 +377,7 @@ namespace cocostudio { SceneReader* SceneReader::getInstance() { - if (s_sharedReader == NULL) + if (s_sharedReader == nullptr) { s_sharedReader = new SceneReader(); } diff --git a/cocos/editor-support/cocostudio/CSContentJsonDictionary.cpp b/cocos/editor-support/cocostudio/CSContentJsonDictionary.cpp index 2f88410582..df21493821 100644 --- a/cocos/editor-support/cocostudio/CSContentJsonDictionary.cpp +++ b/cocos/editor-support/cocostudio/CSContentJsonDictionary.cpp @@ -132,7 +132,7 @@ namespace cocostudio { const char * JsonDictionary::getItemStringValue(const char *pszKey) { if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isString()) - return NULL; + return nullptr; return m_cValue[pszKey].asCString(); } @@ -154,7 +154,7 @@ namespace cocostudio { !m_cValue[pszKey].isConvertibleTo(Json::arrayValue) && !m_cValue[pszKey].isConvertibleTo(Json::objectValue))) { - pNewDictionary = NULL; + pNewDictionary = nullptr; } else { @@ -336,7 +336,7 @@ namespace cocostudio { return (*arrayValue)[nIndex].asCString(); } - return NULL; + return nullptr; } @@ -353,7 +353,7 @@ namespace cocostudio { } } - return NULL; + return nullptr; } @@ -379,9 +379,9 @@ namespace cocostudio { inline Json::Value * JsonDictionary::validateArrayItem(const char *pszArrayKey, int nIndex) { if (!isKeyValidate(pszArrayKey, m_cValue) && !m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(Json::arrayValue)) - return NULL; + return nullptr; if (!m_cValue[pszArrayKey].isValidIndex(nIndex)) - return NULL; + return nullptr; return &m_cValue[pszArrayKey]; } diff --git a/cocos/editor-support/cocostudio/DictionaryHelper.cpp b/cocos/editor-support/cocostudio/DictionaryHelper.cpp index 48466eeb3e..1f3c937b93 100644 --- a/cocos/editor-support/cocostudio/DictionaryHelper.cpp +++ b/cocos/editor-support/cocostudio/DictionaryHelper.cpp @@ -26,7 +26,7 @@ namespace cocostudio { -static DictionaryHelper* sharedHelper = NULL; +static DictionaryHelper* sharedHelper = nullptr; DictionaryHelper::DictionaryHelper() { @@ -54,11 +54,11 @@ void DictionaryHelper::purgeDictionaryHelper() cocos2d::Dictionary* DictionaryHelper::getSubDictionary(cocos2d::Dictionary* root,const char* key) { if (!root) { - return NULL; + return nullptr; } cocos2d::Object* obj = root->objectForKey(key); if (!obj) { - return NULL; + return nullptr; } return (cocos2d::Dictionary*)(obj); } @@ -93,11 +93,11 @@ float DictionaryHelper::getFloatValue(cocos2d::Dictionary* root,const char* key) const char* DictionaryHelper::getStringValue(cocos2d::Dictionary* root,const char* key) { if (!root) { - return NULL; + return nullptr; } cocos2d::Object* obj = root->objectForKey(key); if (!obj) { - return NULL; + return nullptr; } cocos2d::String* cstr = (cocos2d::String*)(obj); return cstr->_string.c_str(); @@ -111,11 +111,11 @@ bool DictionaryHelper::getBooleanValue(cocos2d::Dictionary* root,const char* key cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const char *key) { if (!root) { - return NULL; + return nullptr; } cocos2d::Object* obj = root->objectForKey(key); if (!obj) { - return NULL; + return nullptr; } cocos2d::Array* array = (cocos2d::Array*)(obj); return array; @@ -124,7 +124,7 @@ cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const cocos2d::Object* DictionaryHelper::checkObjectExist(cocos2d::Dictionary *root, const char *key) { if (!root) { - return NULL; + return nullptr; } return root->objectForKey(key); } @@ -153,7 +153,7 @@ const char* DictionaryHelper::objectToStringValue(cocos2d::Object *obj) { if (!obj) { - return NULL; + return nullptr; } cocos2d::String* cstr = (cocos2d::String*)(obj); return cstr->_string.c_str(); @@ -172,7 +172,7 @@ cocos2d::Array* DictionaryHelper::objectToCCArray(cocos2d::Object *obj) { if (!obj) { - return NULL; + return nullptr; } cocos2d::Array* array = (cocos2d::Array*)(obj); return array; @@ -182,7 +182,7 @@ JsonDictionary* DictionaryHelper::getSubDictionary_json(JsonDictionary* root,con { if (!root) { - return NULL; + return nullptr; } return root->getSubDictionary(key); } @@ -209,7 +209,7 @@ const char* DictionaryHelper::getStringValue_json(JsonDictionary* root,const cha { if (!root) { - return NULL; + return nullptr; } return root->getItemStringValue(key); } @@ -263,7 +263,7 @@ const char* DictionaryHelper::getStringValueFromArray_json(JsonDictionary *root, { if (!root) { - return NULL; + return nullptr; } return root->getStringValueFromArray(arrayKey, idx); } @@ -272,7 +272,7 @@ JsonDictionary* DictionaryHelper::getDictionaryFromArray_json(JsonDictionary* ro { if (!root) { - return NULL; + return nullptr; } return root->getSubItemFromArray(arrayKey, idx); } From a05727411532fc9b27f6e87fa7e9d43936b9c3af Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 14:08:50 +0800 Subject: [PATCH 168/185] set z order after reorder --- cocos/2d/CCNode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index e329f49c3e..c665b254b4 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -237,11 +237,13 @@ void Node::_setZOrder(int z) void Node::setZOrder(int z) { - _setZOrder(z); if (_parent) { _parent->reorderChild(this, z); } + // should set "_ZOrder" after reorderChild, because the implementation of reorderChild subclass of Node, such as Sprite, + // will return when _ZOrder value is not changed + _setZOrder(z); _eventDispatcher->setDirtyForNode(this); } From 38eabaf31535947f46ef5b38d01300e86efd9c8f Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 14:09:12 +0800 Subject: [PATCH 169/185] fix warning --- extensions/assets-manager/AssetsManager.h | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/assets-manager/AssetsManager.h b/extensions/assets-manager/AssetsManager.h index 93ff6ad950..2cc253c165 100644 --- a/extensions/assets-manager/AssetsManager.h +++ b/extensions/assets-manager/AssetsManager.h @@ -95,6 +95,7 @@ public: */ virtual bool checkUpdate(); + using Node::update; /* @brief Download new package if there is a new version, and uncompress downloaded zip file. * Ofcourse it will set search path that stores downloaded files. */ From babc98540991178b4cbf7ae304052744988469dc Mon Sep 17 00:00:00 2001 From: samuele3 Date: Thu, 14 Nov 2013 14:12:25 +0800 Subject: [PATCH 170/185] Add deprecated functions of class TextureCache --- .../lua/bindings/lua_cocos2dx_extension_manual.cpp | 6 +++--- cocos/scripting/lua/script/Deprecated.lua | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index c541fbdcc2..2822c7aa7a 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -186,7 +186,7 @@ static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S) return 0; } - CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -313,7 +313,7 @@ static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_ return 0; } - CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 0); + CCLOG("'unregisterControlEventHandler' function of Control has wrong number of arguments: %d, was expecting %d\n", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 @@ -1190,7 +1190,7 @@ static int lua_cocos2dx_TableView_create(lua_State* L) #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(L,3,"Node",0,&tolua_err)) goto tolua_lerror; #endif - Node* node = static_cast(tolua_tousertype(L, 2, nullptr)); + Node* node = static_cast(tolua_tousertype(L, 3, nullptr)); ret = TableView::create(dataSource, size, node); } diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 0b2bc4662f..055d417532 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -16,6 +16,19 @@ rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) --functions of CCTextureCache will be deprecated begin +local TextureCacheDeprecated = {} +function TextureCacheDeprecated.getInstance(self) + deprecatedTip("cc.TextureCache:getInstance","cc.Director:getInstance():getTextureCache") + return cc.Director:getInstance():getTextureCache() +end +rawset(cc.TextureCache,"getInstance",TextureCacheDeprecated.getInstance) + +function TextureCacheDeprecated.destroyInstance(self) + deprecatedTip("cc.TextureCache:destroyInstance","cc.Director:getInstance():destroyTextureCache") + return cc.Director:getInstance():destroyTextureCache() +end +rawset(cc.TextureCache,"destroyInstance",TextureCacheDeprecated.destroyInstance) + local CCTextureCacheDeprecated = { } function CCTextureCacheDeprecated.sharedTextureCache() deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") From 41975ba445dd4a38eabe9a633abf28118f2d1a10 Mon Sep 17 00:00:00 2001 From: chengstory Date: Thu, 14 Nov 2013 14:16:14 +0800 Subject: [PATCH 171/185] fixed #3185 ComponentTest and SceneTest NULL to nullptr. --- .../CocoStudioComponentsTest/ComponentsTestScene.cpp | 6 +++--- .../CocoStudioComponentsTest/EnemyController.cpp | 2 +- .../CocoStudioComponentsTest/GameOverScene.cpp | 8 ++++---- .../CocoStudioComponentsTest/GameOverScene.h | 4 ++-- .../CocoStudioComponentsTest/SceneController.cpp | 4 ++-- .../CocoStudioSceneTest/SceneEditorTest.cpp | 10 +++++----- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp index a7325e0663..539f9cbd0f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp @@ -19,7 +19,7 @@ ComponentsTestLayer::ComponentsTestLayer() Scene* ComponentsTestLayer::scene() { - Scene * scene = NULL; + Scene * scene = nullptr; do { // 'scene' is an autorelease object @@ -65,7 +65,7 @@ bool ComponentsTestLayer::init() cocos2d::Node* ComponentsTestLayer::createGameScene() { - Node *root = NULL; + Node *root = nullptr; do { auto visibleSize = Director::getInstance()->getVisibleSize(); @@ -89,7 +89,7 @@ cocos2d::Node* ComponentsTestLayer::createGameScene() itemBack->setColor(Color3B(0, 0, 0)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - auto menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, nullptr); menuBack->setPosition(Point::ZERO); addChild(menuBack); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp index 9376434f29..ee0cd25824 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp @@ -48,7 +48,7 @@ void EnemyController::onEnter() FiniteTimeAction* actionMoveDone = CallFuncN::create( CC_CALLBACK_1(SceneController::spriteMoveFinished, static_cast( getOwner()->getParent()->getComponent("SceneController") ))); - _owner->runAction( Sequence::create(actionMove, actionMoveDone, NULL) ); + _owner->runAction( Sequence::create(actionMove, actionMoveDone, nullptr) ); } void EnemyController::onExit() diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp index c5cef3e53c..701f75a096 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp @@ -50,7 +50,7 @@ GameOverScene::~GameOverScene() if (_layer) { _layer->release(); - _layer = NULL; + _layer = nullptr; } } @@ -69,7 +69,7 @@ bool GameOverLayer::init() this->runAction( Sequence::create( DelayTime::create(3), CallFunc::create(CC_CALLBACK_0(GameOverLayer::gameOverDone, this)), - NULL)); + nullptr)); auto itemBack = MenuItemFont::create("Back", [](Object* sender){ @@ -80,7 +80,7 @@ bool GameOverLayer::init() itemBack->setColor(Color3B(0, 0, 0)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - auto menuBack = Menu::create(itemBack, NULL); + auto menuBack = Menu::create(itemBack, nullptr); menuBack->setPosition(Point::ZERO); addChild(menuBack); @@ -102,6 +102,6 @@ GameOverLayer::~GameOverLayer() if (_label) { _label->release(); - _label = NULL; + _label = nullptr; } } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h index f3fd0da63f..37f17e1481 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h @@ -6,7 +6,7 @@ class GameOverLayer : public cocos2d::LayerColor { public: - GameOverLayer():_label(NULL) {}; + GameOverLayer():_label(nullptr) {}; virtual ~GameOverLayer(); bool init(); CREATE_FUNC(GameOverLayer); @@ -19,7 +19,7 @@ public: class GameOverScene : public cocos2d::Scene { public: - GameOverScene():_layer(NULL) {}; + GameOverScene():_layer(nullptr) {}; ~GameOverScene(); bool init(); CREATE_FUNC(GameOverScene); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp index f432a09664..2bfc93c02c 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp @@ -11,8 +11,8 @@ using namespace cocostudio; SceneController::SceneController(void) : _fAddTargetTime(0.0f) , _fElapsedTime(0.0f) -, _targets(NULL) -, _projectiles(NULL) +, _targets(nullptr) +, _projectiles(nullptr) { _name = "SceneController"; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index f7ddf0c777..1af3b06657 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -18,12 +18,12 @@ SceneEditorTestLayer::~SceneEditorTestLayer() SceneEditorTestLayer::SceneEditorTestLayer() { - _curNode = NULL; + _curNode = nullptr; } Scene* SceneEditorTestLayer::scene() { - Scene * scene = NULL; + Scene * scene = nullptr; do { // 'scene' is an autorelease object @@ -63,16 +63,16 @@ bool SceneEditorTestLayer::init() cocos2d::Node* SceneEditorTestLayer::createGameScene() { Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json"); - if (pNode == NULL) + if (pNode == nullptr) { - return NULL; + return nullptr; } _curNode = pNode; MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SceneEditorTestLayer::toExtensionsMainLayer, this)); itemBack->setColor(Color3B(255, 255, 255)); itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, NULL); + Menu *menuBack = Menu::create(itemBack, nullptr); menuBack->setPosition(Point(0.0f, 0.0f)); menuBack->setZOrder(4); From dee5305f7b66b2ead8e1c1a1384b37e51108dd28 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 14 Nov 2013 14:46:44 +0800 Subject: [PATCH 172/185] fixed bugs of widget --- cocos/gui/UIWidget.cpp | 78 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 9 deletions(-) diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index a597a04b7b..8d60fc3908 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -332,10 +332,22 @@ void UIWidget::setSize(const cocos2d::Size &size) { _size = size; } - if (_isRunning) + if (_isRunning && _widgetParent) { - _sizePercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); + cocos2d::Size pSize = _widgetParent->getSize(); + float spx = 0.0f; + float spy = 0.0f; + if (pSize.width > 0.0f) + { + spx = _customSize.width / pSize.width; + } + if (pSize.height > 0.0f) + { + spy = _customSize.height / pSize.height; + } + _sizePercent = cocos2d::Point(spx, spy); } + onSizeChanged(); } @@ -364,6 +376,7 @@ void UIWidget::updateSizeAndPosition() switch (_sizeType) { case SIZE_ABSOLUTE: + { if (_ignoreSize) { _size = getContentSize(); @@ -372,11 +385,26 @@ void UIWidget::updateSizeAndPosition() { _size = _customSize; } - _sizePercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(_customSize.width / _widgetParent->getSize().width, _customSize.height / _widgetParent->getSize().height); + if (_widgetParent) + { + cocos2d::Size pSize = _widgetParent->getSize(); + float spx = 0.0f; + float spy = 0.0f; + if (pSize.width > 0.0f) + { + spx = _customSize.width / pSize.width; + } + if (pSize.height > 0.0f) + { + spy = _customSize.height / pSize.height; + } + _sizePercent = cocos2d::Point(spx, spy); + } break; + } case SIZE_PERCENT: { - cocos2d::Size cSize = (_widgetParent == nullptr) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y); + cocos2d::Size cSize = (_widgetParent == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y); if (_ignoreSize) { _size = getContentSize(); @@ -396,14 +424,38 @@ void UIWidget::updateSizeAndPosition() switch (_positionType) { case POSITION_ABSOLUTE: - _positionPercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(absPos.x / _widgetParent->getSize().width, absPos.y / _widgetParent->getSize().height); + { + if (_widgetParent) + { + cocos2d::Size pSize = _widgetParent->getSize(); + if (pSize.width <= 0.0f || pSize.height <= 0.0f) + { + _positionPercent = cocos2d::Point::ZERO; + } + else + { + _positionPercent = cocos2d::Point(absPos.x / pSize.width, absPos.y / pSize.height); + } + } + else + { + _positionPercent = cocos2d::Point::ZERO; + } break; + } case POSITION_PERCENT: { - cocos2d::Size parentSize = _widgetParent->getSize(); - absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); - } + if (_widgetParent) + { + cocos2d::Size parentSize = _widgetParent->getSize(); + absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); + } + else + { + absPos = cocos2d::Point::ZERO; + } break; + } default: break; } @@ -790,7 +842,15 @@ void UIWidget::setPosition(const cocos2d::Point &pos) { if (_isRunning) { - _positionPercent = (_widgetParent == nullptr) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height); + cocos2d::Size pSize = _widgetParent->getSize(); + if (pSize.width <= 0.0f || pSize.height <= 0.0f) + { + _positionPercent = cocos2d::Point::ZERO; + } + else + { + _positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height); + } } _renderer->setPosition(pos); } From 03c8c8f4fcf1891463e10a9f8bcd894b801415a0 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 14 Nov 2013 14:48:16 +0800 Subject: [PATCH 173/185] Fix bug: use free() in imageCommon_cpp.h --- cocos/2d/platform/CCImageCommon_cpp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index cc0d672841..33906b16f8 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -424,7 +424,7 @@ bool Image::initWithImageFile(const char * strPath) bRet = initWithImageData(buffer, bufferLen); } - CC_SAFE_DELETE_ARRAY(buffer); + free(buffer); #endif // EMSCRIPTEN return bRet; @@ -444,7 +444,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath) { ret = initWithImageData(buffer, dataLen); } - CC_SAFE_DELETE_ARRAY(buffer); + free(buffer); return ret; } From 5f22edf0956b3ed9825b5223a62e6190d902feae Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 14 Nov 2013 15:42:59 +0800 Subject: [PATCH 174/185] fixed bug of widget --- cocos/gui/UIWidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 8d60fc3908..e87aa50a72 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -840,7 +840,7 @@ void UIWidget::checkChildInfo(int handleState, UIWidget *sender, const cocos2d:: void UIWidget::setPosition(const cocos2d::Point &pos) { - if (_isRunning) + if (_isRunning && _widgetParent) { cocos2d::Size pSize = _widgetParent->getSize(); if (pSize.width <= 0.0f || pSize.height <= 0.0f) @@ -849,7 +849,7 @@ void UIWidget::setPosition(const cocos2d::Point &pos) } else { - _positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / _widgetParent->getSize().width, pos.y / _widgetParent->getSize().height); + _positionPercent = (_widgetParent == NULL) ? cocos2d::Point::ZERO : cocos2d::Point(pos.x / pSize.width, pos.y / pSize.height); } } _renderer->setPosition(pos); @@ -858,7 +858,7 @@ void UIWidget::setPosition(const cocos2d::Point &pos) void UIWidget::setPositionPercent(const cocos2d::Point &percent) { _positionPercent = percent; - if (_isRunning) + if (_isRunning && _widgetParent) { cocos2d::Size parentSize = _widgetParent->getSize(); cocos2d::Point absPos = cocos2d::Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); From 6acf422f3b6cc74248942dc8556780eae438d8e6 Mon Sep 17 00:00:00 2001 From: chengstory Date: Thu, 14 Nov 2013 17:03:45 +0800 Subject: [PATCH 175/185] fixed #3185 support for html5. --- .../cocostudio/CCComAttribute.cpp | 45 +++++++++++++++++++ .../cocostudio/CCComAttribute.h | 11 +++++ .../SceneController.cpp | 7 +-- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index cd20cf3c02..c0c590af58 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.cpp +++ b/cocos/editor-support/cocostudio/CCComAttribute.cpp @@ -58,6 +58,51 @@ ComAttribute* ComAttribute::create(void) return pRet; } +void ComAttribute::setInt(const char *key, int value) +{ + CCASSERT(key != NULL, "Argument must be non-nil"); + _jsonDict->insertItem(key, value); +} + +void ComAttribute::setFloat(const char *key, float value) +{ + CCASSERT(key != NULL, "Argument must be non-nil"); + _jsonDict->insertItem(key, value); +} + +void ComAttribute::setBool(const char *key, bool value) +{ + CCASSERT(key != NULL, "Argument must be non-nil"); + _jsonDict->insertItem(key, value); +} + +void ComAttribute::setCString(const char *key, const char *value) +{ + CCASSERT(key != NULL, "Argument must be non-nil"); + _jsonDict->insertItem(key, value); +} + + +int ComAttribute::getInt(const char *key) const +{ + return _jsonDict->getItemIntValue(key, -1); +} + +float ComAttribute::getFloat(const char *key) const +{ + return _jsonDict->getItemFloatValue(key, -1.0f); +} + +bool ComAttribute::getBool(const char *key) const +{ + return _jsonDict->getItemBoolvalue(key, false); +} + +const char* ComAttribute::getCString(const char *key) const +{ + return _jsonDict->getItemStringValue(key); +} + JsonDictionary* ComAttribute::getDict() const { return _jsonDict; diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index dcb1b177e3..dea396c121 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -47,6 +47,17 @@ protected: public: virtual bool init(); static ComAttribute* create(void); + + void setInt(const char *key, int value); + void setFloat(const char *key, float value); + void setBool(const char *key, bool value); + void setCString(const char *key, const char *value); + + int getInt(const char *key) const; + float getFloat(const char *key) const; + bool getBool(const char *key) const; + const char* getCString(const char *key) const; + JsonDictionary* getDict() const; private: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp index 2bfc93c02c..e563377357 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp @@ -39,7 +39,8 @@ void SceneController::onEnter() _projectiles->retain(); ((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true); - ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getDict()->insertItem("KillCount", 0); + ((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0); + } void SceneController::onExit() @@ -102,10 +103,10 @@ void SceneController::spriteMoveFinished(Node* sender) void SceneController::increaseKillCount() { - int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getDict()->getItemIntValue("KillCount", -1); + int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getInt("KillCount"); ComAttribute *p = (ComAttribute*)(_owner->getComponent("ComAttribute")); - p->getDict()->insertItem("KillCount", ++nProjectilesDestroyed); + p->setInt("KillCount", ++nProjectilesDestroyed); if (nProjectilesDestroyed >= 5) { From 489463246725e6720aad27a32261a57e7c232f5b Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 14 Nov 2013 17:14:35 +0800 Subject: [PATCH 176/185] Fix bug: add android, fix android can not compile --- cocos/2d/CCUserDefaultAndroid.cpp | 2 +- cocos/2d/platform/android/CCFileUtilsAndroid.cpp | 4 ++-- cocos/2d/platform/win32/CCFileUtilsWin32.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp index 510c83c14c..8f6895f572 100644 --- a/cocos/2d/CCUserDefaultAndroid.cpp +++ b/cocos/2d/CCUserDefaultAndroid.cpp @@ -75,7 +75,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument(); *doc = xmlDoc; long size; - const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); + char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index c447b5db32..839966a122 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp @@ -191,7 +191,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* off_t fileSize = AAsset_getLength(asset); - data = new unsigned char[fileSize]; + data = (unsigned char*) malloc(fileSize); int bytesread = AAsset_read(asset, (void*)data, fileSize); if (size) @@ -214,7 +214,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* fseek(fp,0,SEEK_END); fileSize = ftell(fp); fseek(fp,0,SEEK_SET); - data = new unsigned char[fileSize]; + data = (unsigned char*) malloc(fileSize); fileSize = fread(data,sizeof(unsigned char), fileSize,fp); fclose(fp); diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index 216797bd9e..a417f34fa1 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -139,7 +139,7 @@ unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mod *size = ::GetFileSize(fileHandle, NULL); - pBuffer = new unsigned char[*size]; + pBuffer = (unsigned char*) malloc(*size); DWORD sizeRead = 0; BOOL successed = FALSE; successed = ::ReadFile(fileHandle, pBuffer, *size, &sizeRead, NULL); @@ -147,7 +147,7 @@ unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mod if (!successed) { - CC_SAFE_DELETE_ARRAY(pBuffer); + free(pBuffer); } } while (0); From 523cb2e8d9f025a60890107c5dd624d04c6228c9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 14 Nov 2013 09:39:25 +0000 Subject: [PATCH 177/185] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index fd5a781004..e76bd3683f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit fd5a7810040fa83d083dc5384ae876f8e3e0847e +Subproject commit e76bd3683fd785d1b23d59d153641a7f5ae6e583 From 2f7f05d1d756ff3ca4ad7325186ad2941146463c Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Nov 2013 18:39:23 +0800 Subject: [PATCH 178/185] fix asynchronize loading bug --- cocos/2d/platform/android/CCFileUtilsAndroid.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index c447b5db32..3ca0e6a25f 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp @@ -153,16 +153,6 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* if (fullPath[0] != '/') { - - // fullPathForFilename is not thread safe. - if (forAsync) { - LOGD("Async loading not supported. fullPathForFilename is not thread safe."); - return NULL; - } - - string fullPath = fullPathForFilename(filename); - LOGD("full path = %s", fullPath.c_str()); - string relativePath = string(); size_t position = fullPath.find("assets/"); From e14295c404b0ec66a3732f622347472e7b1ebc4f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 15 Nov 2013 09:45:03 +0800 Subject: [PATCH 179/185] Merge branch 'develop' into free_instead_of_delete --- .../cocostudio/CCSGUIReader.cpp | 4 +- .../cocostudio/CCSSceneReader.cpp | 439 +++++++++--------- 2 files changed, 223 insertions(+), 220 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 7179c41172..cbfe527b68 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -122,7 +122,7 @@ const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const UIWidget* GUIReader::widgetFromJsonFile(const char *fileName) { DictionaryHelper* dicHelper = DICTOOL; - const char *des = nullptr; + char *des = nullptr; std::string jsonpath; JsonDictionary *jsonDict = nullptr; jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName); @@ -164,7 +164,7 @@ UIWidget* GUIReader::widgetFromJsonFile(const char *fileName) CC_SAFE_DELETE(pReader); CC_SAFE_DELETE(jsonDict); - CC_SAFE_DELETE_ARRAY(des); + free(des); return widget; } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 452bfca276..385c147e27 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -30,40 +30,42 @@ using namespace gui; namespace cocostudio { - SceneReader* SceneReader::s_sharedReader = nullptr; + SceneReader* SceneReader::s_sharedReader = nullptr; SceneReader::SceneReader() { - } + } SceneReader::~SceneReader() { } - const char* SceneReader::sceneReaderVersion() - { - return "1.0.0.0"; - } + const char* SceneReader::sceneReaderVersion() + { + return "1.0.0.0"; + } cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName) { long size = 0; - const char* pData = 0; - cocos2d::Node *pNode = nullptr; - do { - CC_BREAK_IF(pszFileName == nullptr); - pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size)); - CC_BREAK_IF(pData == nullptr || strcmp(pData, "") == 0); - JsonDictionary *jsonDict = new JsonDictionary(); - jsonDict->initWithDescription(pData); - pNode = createObject(jsonDict,nullptr); - CC_SAFE_DELETE(jsonDict); + char* pData = 0; + cocos2d::Node *pNode = nullptr; + do + { + CC_BREAK_IF(pszFileName == nullptr); + pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pszFileName, "r", &size)); + CC_BREAK_IF(pData == nullptr || strcmp(pData, "") == 0); + JsonDictionary *jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(pData); + pNode = createObject(jsonDict,nullptr); + CC_SAFE_DELETE(jsonDict); + free(pData); } while (0); return pNode; - } + } - Node* SceneReader::createObject(JsonDictionary * inputFiles, Node* parenet) + Node* SceneReader::createObject(JsonDictionary * inputFiles, Node* parenet) { const char *className = inputFiles->getItemStringValue("classname"); if(strcmp(className, "CCNode") == 0) @@ -86,63 +88,63 @@ namespace cocostudio { { JsonDictionary * subDict = inputFiles->getSubItemFromArray("components", i); if (!subDict) - { - CC_SAFE_DELETE(subDict); - break; - } - const char *comName = subDict->getItemStringValue("classname"); - const char *pComName = subDict->getItemStringValue("name"); - - JsonDictionary *fileData = subDict->getSubDictionary("fileData"); - std::string pPath; - std::string pPlistFile; - int nResType = 0; - if (fileData != nullptr) { - const char *file = fileData->getItemStringValue("path"); - nResType = fileData->getItemIntValue("resourceType", -1); - const char *plistFile = fileData->getItemStringValue("plistFile"); - if (file != nullptr) - { - pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); - } + CC_SAFE_DELETE(subDict); + break; + } + const char *comName = subDict->getItemStringValue("classname"); + const char *pComName = subDict->getItemStringValue("name"); + + JsonDictionary *fileData = subDict->getSubDictionary("fileData"); + std::string pPath; + std::string pPlistFile; + int nResType = 0; + if (fileData != nullptr) + { + const char *file = fileData->getItemStringValue("path"); + nResType = fileData->getItemIntValue("resourceType", -1); + const char *plistFile = fileData->getItemStringValue("plistFile"); + if (file != nullptr) + { + pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); + } - if (plistFile != nullptr) - { - pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile)); - } - CC_SAFE_DELETE(fileData); + if (plistFile != nullptr) + { + pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile)); + } + CC_SAFE_DELETE(fileData); } if (comName != nullptr && strcmp(comName, "CCSprite") == 0) { - cocos2d::Sprite *pSprite = nullptr; + cocos2d::Sprite *pSprite = nullptr; - if (nResType == 0) - { - if (pPath.find(".png") == pPath.npos) - { - continue; - } - pSprite = Sprite::create(pPath.c_str()); - } - else if (nResType == 1) - { - std::string pngFile = pPlistFile; - std::string::size_type pos = pngFile.find(".plist"); - if (pos == pPath.npos) - { - continue; - } - pngFile.replace(pos, pngFile.length(), ".png"); - CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); - pSprite = Sprite::createWithSpriteFrameName(pPath.c_str()); - } - else - { - continue; - } - + if (nResType == 0) + { + if (pPath.find(".png") == pPath.npos) + { + continue; + } + pSprite = Sprite::create(pPath.c_str()); + } + else if (nResType == 1) + { + std::string pngFile = pPlistFile; + std::string::size_type pos = pngFile.find(".plist"); + if (pos == pPath.npos) + { + continue; + } + pngFile.replace(pos, pngFile.length(), ".png"); + CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); + pSprite = Sprite::createWithSpriteFrameName(pPath.c_str()); + } + else + { + continue; + } + ComRender *pRender = ComRender::create(pSprite, "CCSprite"); if (pComName != nullptr) { @@ -153,19 +155,19 @@ namespace cocostudio { } else if(comName != nullptr && strcmp(comName, "CCTMXTiledMap") == 0) { - cocos2d::TMXTiledMap *pTmx = nullptr; - if (nResType == 0) - { - if (pPath.find(".tmx") == pPath.npos) - { - continue; - } - pTmx = TMXTiledMap::create(pPath.c_str()); - } - else - { - continue; - } + cocos2d::TMXTiledMap *pTmx = nullptr; + if (nResType == 0) + { + if (pPath.find(".tmx") == pPath.npos) + { + continue; + } + pTmx = TMXTiledMap::create(pPath.c_str()); + } + else + { + continue; + } ComRender *pRender = ComRender::create(pTmx, "CCTMXTiledMap"); if (pComName != nullptr) @@ -182,17 +184,17 @@ namespace cocostudio { continue; } - cocos2d::ParticleSystemQuad *pParticle = nullptr; - if (nResType == 0) - { - pParticle = ParticleSystemQuad::create(pPath.c_str()); - } - else - { - CCLOG("unknown resourcetype on CCParticleSystemQuad!"); - } + cocos2d::ParticleSystemQuad *pParticle = nullptr; + if (nResType == 0) + { + pParticle = ParticleSystemQuad::create(pPath.c_str()); + } + else + { + CCLOG("unknown resourcetype on CCParticleSystemQuad!"); + } - pParticle->setPosition(0, 0); + pParticle->setPosition(0, 0); ComRender *pRender = ComRender::create(pParticle, "CCParticleSystemQuad"); if (pComName != nullptr) { @@ -202,133 +204,134 @@ namespace cocostudio { } else if(comName != nullptr && strcmp(comName, "CCArmature") == 0) { - if (nResType != 0) - { - continue; - } - std::string reDir = pPath; - std::string file_path = ""; - size_t pos = reDir.find_last_of('/'); - if (pos != std::string::npos) - { - file_path = reDir.substr(0, pos+1); - } - long size = 0; - const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size)); - JsonDictionary *jsonDict = new JsonDictionary(); - jsonDict->initWithDescription(des); - if(nullptr == des || strcmp(des, "") == 0) - { - CCLOG("read json file[%s] error!\n", pPath.c_str()); - } + if (nResType != 0) + { + continue; + } + std::string reDir = pPath; + std::string file_path = ""; + size_t pos = reDir.find_last_of('/'); + if (pos != std::string::npos) + { + file_path = reDir.substr(0, pos+1); + } + long size = 0; + char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size)); + JsonDictionary *jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(des); + if(nullptr == des || strcmp(des, "") == 0) + { + CCLOG("read json file[%s] error!\n", pPath.c_str()); + } - int childrenCount = DICTOOL->getArrayCount_json(jsonDict, "armature_data"); - JsonDictionary* subData = DICTOOL->getDictionaryFromArray_json(jsonDict, "armature_data", 0); - const char *name = DICTOOL->getStringValue_json(subData, "name"); + int childrenCount = DICTOOL->getArrayCount_json(jsonDict, "armature_data"); + JsonDictionary* subData = DICTOOL->getDictionaryFromArray_json(jsonDict, "armature_data", 0); + const char *name = DICTOOL->getStringValue_json(subData, "name"); - childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path"); - for (long j = 0; j < childrenCount; ++j) - { - const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", j); - std::string plistpath; - plistpath += file_path; - plistpath.append(plist); - cocos2d::Dictionary *root = Dictionary::createWithContentsOfFile(plistpath.c_str()); - Dictionary* metadata = DICTOOL->getSubDictionary(root, "metadata"); - const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName"); + childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path"); + for (long j = 0; j < childrenCount; ++j) + { + const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", j); + std::string plistpath; + plistpath += file_path; + plistpath.append(plist); + cocos2d::Dictionary *root = Dictionary::createWithContentsOfFile(plistpath.c_str()); + Dictionary* metadata = DICTOOL->getSubDictionary(root, "metadata"); + const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName"); - std::string textupath; - textupath += file_path; - textupath.append(textureFileName); + std::string textupath; + textupath += file_path; + textupath.append(textureFileName); - ArmatureDataManager::getInstance()->addArmatureFileInfo(textupath.c_str(), plistpath.c_str(), pPath.c_str()); + ArmatureDataManager::getInstance()->addArmatureFileInfo(textupath.c_str(), plistpath.c_str(), pPath.c_str()); - } + } - Armature *pAr = Armature::create(name); - ComRender *pRender = ComRender::create(pAr, "CCArmature"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); + Armature *pAr = Armature::create(name); + ComRender *pRender = ComRender::create(pAr, "CCArmature"); + if (pComName != nullptr) + { + pRender->setName(pComName); + } + gb->addComponent(pRender); - const char *actionName = subDict->getItemStringValue("selectedactionname"); - if (actionName != nullptr && pAr->getAnimation() != nullptr) - { - pAr->getAnimation()->play(actionName); - } + const char *actionName = subDict->getItemStringValue("selectedactionname"); + if (actionName != nullptr && pAr->getAnimation() != nullptr) + { + pAr->getAnimation()->play(actionName); + } - CC_SAFE_DELETE(jsonDict); - CC_SAFE_DELETE(subData); - CC_SAFE_DELETE_ARRAY(des); + CC_SAFE_DELETE(jsonDict); + CC_SAFE_DELETE(subData); + free(des); } else if(comName != nullptr && strcmp(comName, "CCComAudio") == 0) { - ComAudio *pAudio = nullptr; - if (nResType == 0) - { - pAudio = ComAudio::create(); - } - else - { - continue; - } + ComAudio *pAudio = nullptr; + if (nResType == 0) + { + pAudio = ComAudio::create(); + } + else + { + continue; + } pAudio->preloadEffect(pPath.c_str()); gb->addComponent(pAudio); } else if(comName != nullptr && strcmp(comName, "CCComAttribute") == 0) { ComAttribute *pAttribute = nullptr; - if (nResType == 0) - { - pAttribute = ComAttribute::create(); - long size = 0; - const char* pData = 0; - pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size)); - if(pData != nullptr && strcmp(pData, "") != 0) - { - pAttribute->getDict()->initWithDescription(pData); - } - } - else - { - CCLOG("unknown resourcetype on CCComAttribute!"); - continue; - } + if (nResType == 0) + { + pAttribute = ComAttribute::create(); + long size = 0; + char* pData = 0; + pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size)); + if(pData != nullptr && strcmp(pData, "") != 0) + { + pAttribute->getDict()->initWithDescription(pData); + } + free(pData); + } + else + { + CCLOG("unknown resourcetype on CCComAttribute!"); + continue; + } gb->addComponent(pAttribute); } else if (comName != nullptr && strcmp(comName, "CCBackgroundAudio") == 0) { - ComAudio *pAudio = nullptr; - if (nResType == 0) - { - pAudio = ComAudio::create(); - } - else - { - continue; - } + ComAudio *pAudio = nullptr; + if (nResType == 0) + { + pAudio = ComAudio::create(); + } + else + { + continue; + } pAudio->preloadBackgroundMusic(pPath.c_str()); - pAudio->setFile(pPath.c_str()); - const bool bLoop = (subDict->getItemIntValue("loop", 0) != 0); - pAudio->setLoop(bLoop); + pAudio->setFile(pPath.c_str()); + const bool bLoop = (subDict->getItemIntValue("loop", 0) != 0); + pAudio->setLoop(bLoop); gb->addComponent(pAudio); - pAudio->playBackgroundMusic(pPath.c_str(), bLoop); + pAudio->playBackgroundMusic(pPath.c_str(), bLoop); } - else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0) - { + else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0) + { gui::UILayer *pLayer = gui::UILayer::create(); - pLayer->scheduleUpdate(); - UIWidget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str()); - pLayer->addWidget(widget); - ComRender *pRender = ComRender::create(pLayer, "GUIComponent"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); - } + pLayer->scheduleUpdate(); + UIWidget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str()); + pLayer->addWidget(widget); + ComRender *pRender = ComRender::create(pLayer, "GUIComponent"); + if (pComName != nullptr) + { + pRender->setName(pComName); + } + gb->addComponent(pRender); + } CC_SAFE_DELETE(subDict); } @@ -353,41 +356,41 @@ namespace cocostudio { void SceneReader::setPropertyFromJsonDict(cocos2d::Node *node, JsonDictionary* dict) { - int x = dict->getItemIntValue("x", 0); - int y = dict->getItemIntValue("y", 0); - node->setPosition(Point(x, y)); - - const bool bVisible = (dict->getItemIntValue("visible", 1) != 0); - node->setVisible(bVisible); - - int nTag = dict->getItemIntValue("objecttag", -1); + int x = dict->getItemIntValue("x", 0); + int y = dict->getItemIntValue("y", 0); + node->setPosition(Point(x, y)); + + const bool bVisible = (dict->getItemIntValue("visible", 1) != 0); + node->setVisible(bVisible); + + int nTag = dict->getItemIntValue("objecttag", -1); node->setTag(nTag); - - int nZorder = dict->getItemIntValue("zorder", 0); - node->setZOrder(nZorder); - - float fScaleX = dict->getItemFloatValue("scalex", 1.0); - float fScaleY = dict->getItemFloatValue("scaley", 1.0); + + int nZorder = dict->getItemIntValue("zorder", 0); + node->setZOrder(nZorder); + + float fScaleX = dict->getItemFloatValue("scalex", 1.0); + float fScaleY = dict->getItemFloatValue("scaley", 1.0); node->setScaleX(fScaleX); node->setScaleY(fScaleY); - float fRotationZ = dict->getItemIntValue("rotation", 0); + float fRotationZ = dict->getItemIntValue("rotation", 0); node->setRotation(fRotationZ); } - SceneReader* SceneReader::getInstance() - { - if (s_sharedReader == nullptr) - { - s_sharedReader = new SceneReader(); - } - return s_sharedReader; - } + SceneReader* SceneReader::getInstance() + { + if (s_sharedReader == nullptr) + { + s_sharedReader = new SceneReader(); + } + return s_sharedReader; + } void SceneReader::purgeSceneReader() { - CC_SAFE_DELETE(s_sharedReader); - DictionaryHelper::shareHelper()->purgeDictionaryHelper(); + CC_SAFE_DELETE(s_sharedReader); + DictionaryHelper::shareHelper()->purgeDictionaryHelper(); } } From 1730fcddcb98f3ee80682e88590a70b0b95b4cdf Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 15 Nov 2013 13:29:39 +0800 Subject: [PATCH 180/185] Modify layout --- cocos/gui/UILayout.cpp | 43 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 3cbd5fef8a..be152ec817 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -853,26 +853,61 @@ void UILayout::doLayout() break; case RELATIVE_LOCATION_ABOVE_LEFTALIGN: - case RELATIVE_LOCATION_ABOVE_CENTER: + finalPosY += mg.bottom; + finalPosY += relativeWidgetMargin.top; + finalPosX += mg.left; + break; case RELATIVE_LOCATION_ABOVE_RIGHTALIGN: finalPosY += mg.bottom; finalPosY += relativeWidgetMargin.top; + finalPosX -= mg.right; break; + case RELATIVE_LOCATION_ABOVE_CENTER: + finalPosY += mg.bottom; + finalPosY += relativeWidgetMargin.top; + break; + case RELATIVE_LOCATION_LEFT_OF_TOPALIGN: - case RELATIVE_LOCATION_LEFT_OF_CENTER: + finalPosX -= mg.right; + finalPosX -= relativeWidgetMargin.left; + finalPosY -= mg.top; + break; case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN: finalPosX -= mg.right; finalPosX -= relativeWidgetMargin.left; + finalPosY += mg.bottom; break; + case RELATIVE_LOCATION_LEFT_OF_CENTER: + finalPosX -= mg.right; + finalPosX -= relativeWidgetMargin.left; + break; + case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN: - case RELATIVE_LOCATION_RIGHT_OF_CENTER: + finalPosX += mg.left; + finalPosX += relativeWidgetMargin.right; + finalPosY -= mg.top; + break; case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN: finalPosX += mg.left; finalPosX += relativeWidgetMargin.right; + finalPosY += mg.bottom; break; + case RELATIVE_LOCATION_RIGHT_OF_CENTER: + finalPosX += mg.left; + finalPosX += relativeWidgetMargin.right; + break; + case RELATIVE_LOCATION_BELOW_LEFTALIGN: - case RELATIVE_LOCATION_BELOW_CENTER: + finalPosY -= mg.top; + finalPosY -= relativeWidgetMargin.bottom; + finalPosX += mg.left; + break; case RELATIVE_LOCATION_BELOW_RIGHTALIGN: + finalPosY -= mg.top; + finalPosY -= relativeWidgetMargin.bottom; + finalPosX -= mg.right; + break; + case RELATIVE_LOCATION_BELOW_CENTER: finalPosY -= mg.top; finalPosY -= relativeWidgetMargin.bottom; break; From ec9bc0069ffd2fbda85f4eed8d261b603194b239 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Fri, 15 Nov 2013 13:48:34 +0800 Subject: [PATCH 181/185] Modify template of lua ios_mac config and some bugs --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/scripting/lua/bindings/CCLuaStack.cpp | 8 + cocos/scripting/lua/bindings/CCLuaStack.h | 2 + cocos/scripting/lua/script/CCBReaderLoad.lua | 2 +- .../CocoStudioSceneTest.lua | 1 - .../CocoStudioTest/CocoStudioTest.lua | 10 +- .../HelloLua.xcodeproj/project.pbxproj | 515 ++++++++---------- 7 files changed, 228 insertions(+), 312 deletions(-) diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index 5562fe8565..c0057afb57 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -bb6b434fc4b6f0865e841fd87dddff603200c029 \ No newline at end of file +9490bdedbc6e817240a1661c6bcbcafc9095c267 \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index 9016d111df..7d0357d78b 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.cpp +++ b/cocos/scripting/lua/bindings/CCLuaStack.cpp @@ -103,6 +103,14 @@ int lua_print(lua_State * luastate) NS_CC_BEGIN +LuaStack::~LuaStack() +{ + if (nullptr != _state) + { + lua_close(_state); + } +} + LuaStack *LuaStack::create(void) { LuaStack *stack = new LuaStack(); diff --git a/cocos/scripting/lua/bindings/CCLuaStack.h b/cocos/scripting/lua/bindings/CCLuaStack.h index dc066ac745..8d00e2ff4c 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.h +++ b/cocos/scripting/lua/bindings/CCLuaStack.h @@ -41,6 +41,8 @@ public: static LuaStack *create(void); static LuaStack *attach(lua_State *L); + virtual ~LuaStack(); + /** @brief Method used to get a pointer to the lua_State that the script module is attached to. @return A pointer to the lua_State that the script module is attached to. diff --git a/cocos/scripting/lua/script/CCBReaderLoad.lua b/cocos/scripting/lua/script/CCBReaderLoad.lua index 3919dfce6e..6acfe432fa 100644 --- a/cocos/scripting/lua/script/CCBReaderLoad.lua +++ b/cocos/scripting/lua/script/CCBReaderLoad.lua @@ -2,7 +2,7 @@ ccb = ccb or {} function CCBReaderLoad(strFilePath,proxy,owner) if nil == proxy then - return + return nil end local ccbReader = proxy:createCCBReader() diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index fe46748cf0..c7f557b0be 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -48,7 +48,6 @@ end function SceneEditorTestLayer.create() local scene = cc.Scene:create() local layer = SceneEditorTestLayer.extend(cc.LayerColor:create()) - layer:initWithColor(cc.c4b(0,0,0,255)) layer:addChild(layer:createGameScene(), 0, 1) scene:addChild(layer) return scene diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua index fdc95dae89..f830bc194e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua @@ -13,24 +13,20 @@ local cocoStudioTestItemNames = runArmatureTestScene() end }, + { itemTitle = "CocoStudioGUITest", testScene = function () runCocosGUITestScene() end }, - { - itemTitle = "CocoStudioComponentsTest", - testScene = function () - --runComponentsTestLayer() - end - }, + { itemTitle = "CocoStudioSceneTest", testScene = function () runCocosSceneTestScene() end - } + }, } local CocoStudioTestScene = class("CocoStudioTestScene") diff --git a/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj index 67d6e16713..ec0d5f7366 100644 --- a/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj @@ -7,17 +7,48 @@ objects = { /* Begin PBXBuildFile section */ - 1525771E17CEFBD400BE417B /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771B17CEFBD400BE417B /* DeprecatedClass.lua */; }; - 1525771F17CEFBD400BE417B /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771C17CEFBD400BE417B /* DeprecatedEnum.lua */; }; - 1525772017CEFBD400BE417B /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771D17CEFBD400BE417B /* DeprecatedOpenglEnum.lua */; }; - 15C1568E1683131500D239F2 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C1568D1683131500D239F2 /* libcurl.a */; }; - 1A0227AC17A3AA3500B867AD /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A517A3AA3500B867AD /* AudioEngine.lua */; }; - 1A0227AD17A3AA3500B867AD /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A617A3AA3500B867AD /* CCBReaderLoad.lua */; }; - 1A0227AE17A3AA3500B867AD /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A717A3AA3500B867AD /* Cocos2dConstants.lua */; }; - 1A0227AF17A3AA3500B867AD /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A817A3AA3500B867AD /* Deprecated.lua */; }; - 1A0227B017A3AA3500B867AD /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A917A3AA3500B867AD /* DrawPrimitives.lua */; }; - 1A0227B117A3AA3500B867AD /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227AA17A3AA3500B867AD /* Opengl.lua */; }; - 1A0227B217A3AA3500B867AD /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227AB17A3AA3500B867AD /* OpenglConstants.lua */; }; + 15A8A4441834C43700142BE0 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4291834BDA200142BE0 /* libchipmunk iOS.a */; }; + 15A8A4451834C43700142BE0 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4251834BDA200142BE0 /* libcocos2dx iOS.a */; }; + 15A8A4461834C43700142BE0 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4271834BDA200142BE0 /* libcocos2dx-extensions iOS.a */; }; + 15A8A4471834C43700142BE0 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A42D1834BDA200142BE0 /* libCocosDenshion iOS.a */; }; + 15A8A4481834C43700142BE0 /* libluabindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4311834BDA200142BE0 /* libluabindings iOS.a */; }; + 15A8A4491834C64F00142BE0 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810C17EBBCAC00990C9B /* Icon-114.png */; }; + 15A8A4641834C6AD00142BE0 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */; }; + 15A8A4651834C6AD00142BE0 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */; }; + 15A8A4661834C6AD00142BE0 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */; }; + 15A8A4671834C6AD00142BE0 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */; }; + 15A8A4681834C6AD00142BE0 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */; }; + 15A8A4691834C6AD00142BE0 /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */; }; + 15A8A46A1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */; }; + 15A8A46B1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */; }; + 15A8A46C1834C6AD00142BE0 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4591834C6AD00142BE0 /* Deprecated.lua */; }; + 15A8A46D1834C6AD00142BE0 /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4591834C6AD00142BE0 /* Deprecated.lua */; }; + 15A8A46E1834C6AD00142BE0 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */; }; + 15A8A46F1834C6AD00142BE0 /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */; }; + 15A8A4701834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */; }; + 15A8A4711834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */; }; + 15A8A4721834C6AD00142BE0 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */; }; + 15A8A4731834C6AD00142BE0 /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */; }; + 15A8A4741834C6AD00142BE0 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */; }; + 15A8A4751834C6AD00142BE0 /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */; }; + 15A8A4761834C6AD00142BE0 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45E1834C6AD00142BE0 /* json.lua */; }; + 15A8A4771834C6AD00142BE0 /* json.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45E1834C6AD00142BE0 /* json.lua */; }; + 15A8A4781834C6AD00142BE0 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45F1834C6AD00142BE0 /* luaj.lua */; }; + 15A8A4791834C6AD00142BE0 /* luaj.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A45F1834C6AD00142BE0 /* luaj.lua */; }; + 15A8A47A1834C6AD00142BE0 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4601834C6AD00142BE0 /* luaoc.lua */; }; + 15A8A47B1834C6AD00142BE0 /* luaoc.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4601834C6AD00142BE0 /* luaoc.lua */; }; + 15A8A47C1834C6AD00142BE0 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4611834C6AD00142BE0 /* Opengl.lua */; }; + 15A8A47D1834C6AD00142BE0 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4611834C6AD00142BE0 /* Opengl.lua */; }; + 15A8A47E1834C6AD00142BE0 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */; }; + 15A8A47F1834C6AD00142BE0 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */; }; + 15A8A4801834C6AD00142BE0 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */; }; + 15A8A4811834C6AD00142BE0 /* StudioConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */; }; + 15A8A4821834C73500142BE0 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A41B1834BDA200142BE0 /* libchipmunk Mac.a */; }; + 15A8A4831834C73500142BE0 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4171834BDA200142BE0 /* libcocos2dx Mac.a */; }; + 15A8A4841834C73500142BE0 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4191834BDA200142BE0 /* libcocos2dx-extensions Mac.a */; }; + 15A8A4851834C73500142BE0 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A41F1834BDA200142BE0 /* libCocosDenshion Mac.a */; }; + 15A8A4861834C73500142BE0 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4231834BDA200142BE0 /* libluabindings Mac.a */; }; + 15A8A4881834C90F00142BE0 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4871834C90E00142BE0 /* libcurl.dylib */; }; 1AC3622F16D47C5C000847F2 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622316D47C5C000847F2 /* background.mp3 */; }; 1AC3623016D47C5C000847F2 /* background.ogg in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622416D47C5C000847F2 /* background.ogg */; }; 1AC3623116D47C5C000847F2 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622516D47C5C000847F2 /* crop.png */; }; @@ -30,13 +61,11 @@ 1AC3623816D47C5C000847F2 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622C16D47C5C000847F2 /* land.png */; }; 1AC3623916D47C5C000847F2 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622D16D47C5C000847F2 /* menu1.png */; }; 1AC3623A16D47C5C000847F2 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622E16D47C5C000847F2 /* menu2.png */; }; - 1ADB273817CCA0C200634B5E /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1ADB273717CCA0C200634B5E /* Cocos2d.lua */; }; 1AF4C403178663F200122817 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C402178663F200122817 /* libz.dylib */; }; 5023811817EBBCAC00990C9B /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5023810817EBBCAC00990C9B /* AppController.mm */; }; 5023811917EBBCAC00990C9B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810917EBBCAC00990C9B /* Default-568h@2x.png */; }; 5023811A17EBBCAC00990C9B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810A17EBBCAC00990C9B /* Default.png */; }; 5023811B17EBBCAC00990C9B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810B17EBBCAC00990C9B /* Default@2x.png */; }; - 5023811C17EBBCAC00990C9B /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810C17EBBCAC00990C9B /* Icon-114.png */; }; 5023811D17EBBCAC00990C9B /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810D17EBBCAC00990C9B /* Icon-120.png */; }; 5023811E17EBBCAC00990C9B /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810E17EBBCAC00990C9B /* Icon-144.png */; }; 5023811F17EBBCAC00990C9B /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 5023810F17EBBCAC00990C9B /* Icon-152.png */; }; @@ -65,17 +94,6 @@ 5023815317EBBCE400990C9B /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622C16D47C5C000847F2 /* land.png */; }; 5023815617EBBCE400990C9B /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622D16D47C5C000847F2 /* menu1.png */; }; 5023815717EBBCE400990C9B /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC3622E16D47C5C000847F2 /* menu2.png */; }; - 5023815917EBBCE400990C9B /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A517A3AA3500B867AD /* AudioEngine.lua */; }; - 5023815A17EBBCE400990C9B /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A617A3AA3500B867AD /* CCBReaderLoad.lua */; }; - 5023815B17EBBCE400990C9B /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A717A3AA3500B867AD /* Cocos2dConstants.lua */; }; - 5023815C17EBBCE400990C9B /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A817A3AA3500B867AD /* Deprecated.lua */; }; - 5023815D17EBBCE400990C9B /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227A917A3AA3500B867AD /* DrawPrimitives.lua */; }; - 5023815E17EBBCE400990C9B /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227AA17A3AA3500B867AD /* Opengl.lua */; }; - 5023816117EBBCE400990C9B /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1A0227AB17A3AA3500B867AD /* OpenglConstants.lua */; }; - 5023816217EBBCE400990C9B /* Cocos2d.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1ADB273717CCA0C200634B5E /* Cocos2d.lua */; }; - 5023816317EBBCE400990C9B /* DeprecatedClass.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771B17CEFBD400BE417B /* DeprecatedClass.lua */; }; - 5023816417EBBCE400990C9B /* DeprecatedEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771C17CEFBD400BE417B /* DeprecatedEnum.lua */; }; - 5023816717EBBCE400990C9B /* DeprecatedOpenglEnum.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1525771D17CEFBD400BE417B /* DeprecatedOpenglEnum.lua */; }; 5023817617EBBE3400990C9B /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 5023817217EBBE3400990C9B /* Icon.icns */; }; 5023817817EBBE3400990C9B /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5023817417EBBE3400990C9B /* main.cpp */; }; 5023817A17EBBE8300990C9B /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5023817917EBBE8300990C9B /* OpenGLES.framework */; }; @@ -86,21 +104,9 @@ 5091733917ECE17A00D62437 /* Icon-58.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091733317ECE17A00D62437 /* Icon-58.png */; }; 5091733A17ECE17A00D62437 /* Icon-80.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091733417ECE17A00D62437 /* Icon-80.png */; }; 5091733B17ECE17A00D62437 /* Icon-100.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091733517ECE17A00D62437 /* Icon-100.png */; }; - 50D7C96517EBBECA005D0B91 /* libbox2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3E11786631700122817 /* libbox2d iOS.a */; }; - 50D7C96617EBBECA005D0B91 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DF1786631700122817 /* libchipmunk iOS.a */; }; - 50D7C96717EBBECA005D0B91 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DB1786631700122817 /* libcocos2dx iOS.a */; }; - 50D7C96817EBBECA005D0B91 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DD1786631700122817 /* libcocos2dx-extensions iOS.a */; }; - 50D7C96917EBBECA005D0B91 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3E31786631700122817 /* libCocosDenshion iOS.a */; }; - 50D7C96A17EBBECB005D0B91 /* libluabindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3E71786631700122817 /* libluabindings iOS.a */; }; 50D7C96C17EBBEDF005D0B91 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50D7C96B17EBBEDF005D0B91 /* OpenGL.framework */; }; 50D7C96E17EBBEE6005D0B91 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50D7C96D17EBBEE6005D0B91 /* AppKit.framework */; }; 50D7C97017EBBEEC005D0B91 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50D7C96F17EBBEEC005D0B91 /* IOKit.framework */; }; - 50D7C97117EBBEF7005D0B91 /* libbox2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3D31786631700122817 /* libbox2d Mac.a */; }; - 50D7C97217EBBEF7005D0B91 /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3D11786631700122817 /* libchipmunk Mac.a */; }; - 50D7C97317EBBEF7005D0B91 /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3CD1786631700122817 /* libcocos2dx Mac.a */; }; - 50D7C97417EBBEF7005D0B91 /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3CF1786631700122817 /* libcocos2dx-extensions Mac.a */; }; - 50D7C97517EBBEF7005D0B91 /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3D51786631700122817 /* libCocosDenshion Mac.a */; }; - 50D7C97617EBBEF7005D0B91 /* libluabindings Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3D91786631700122817 /* libluabindings Mac.a */; }; D6B061351803AC000077942B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B061341803AC000077942B /* CoreMotion.framework */; }; F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CC15EB7BE500256477 /* QuartzCore.framework */; }; F293B3D115EB7BE500256477 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3D015EB7BE500256477 /* OpenAL.framework */; }; @@ -112,132 +118,125 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 1AF4C3CC1786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4161834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1551A33F158F2AB200E66CFE; remoteInfo = "cocos2dx Mac"; }; - 1AF4C3CE1786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4181834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2FD617814595006731B9; remoteInfo = "cocos2dx-extensions Mac"; }; - 1AF4C3D01786631700122817 /* PBXContainerItemProxy */ = { + 15A8A41A1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2CB81780BD04006731B9; remoteInfo = "chipmunk Mac"; }; - 1AF4C3D21786631700122817 /* PBXContainerItemProxy */ = { + 15A8A41C1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2D9B1780BDF7006731B9; remoteInfo = "box2d Mac"; }; - 1AF4C3D41786631700122817 /* PBXContainerItemProxy */ = { + 15A8A41E1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F2ED617814268006731B9; remoteInfo = "CocosDenshion Mac"; }; - 1AF4C3D61786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4201834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A03F31FD1781479B006731B9; remoteInfo = "jsbindings Mac"; }; - 1AF4C3D81786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4221834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1A6FB53017854BC300CDF010; remoteInfo = "luabindings Mac"; }; - 1AF4C3DA1786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4241834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4D641783777C0073F6A7; remoteInfo = "cocos2dx iOS"; }; - 1AF4C3DC1786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4261834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4EFC1783867C0073F6A7; remoteInfo = "cocos2dx-extensions iOS"; }; - 1AF4C3DE1786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4281834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4F3B178387670073F6A7; remoteInfo = "chipmunk iOS"; }; - 1AF4C3E01786631700122817 /* PBXContainerItemProxy */ = { + 15A8A42A1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4F9E1783876B0073F6A7; remoteInfo = "box2d iOS"; }; - 1AF4C3E21786631700122817 /* PBXContainerItemProxy */ = { + 15A8A42C1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A4FB4178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; - 1AF4C3E41786631700122817 /* PBXContainerItemProxy */ = { + 15A8A42E1834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = A07A5030178387750073F6A7; remoteInfo = "jsbindings iOS"; }; - 1AF4C3E61786631700122817 /* PBXContainerItemProxy */ = { + 15A8A4301834BDA200142BE0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + containerPortal = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; proxyType = 2; remoteGlobalIDString = 1A119791178526AA00D62A44; remoteInfo = "luabindings iOS"; }; - 5023816D17EBBDBE00990C9B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = A03F2E8E178141C1006731B9; - remoteInfo = "build-all-libs Mac"; - }; - 5023816F17EBBDC600990C9B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = A07A4E0B178386390073F6A7; - remoteInfo = "build-all-libs iOS"; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 1525771B17CEFBD400BE417B /* DeprecatedClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedClass.lua; path = ../../../scripting/lua/script/DeprecatedClass.lua; sourceTree = ""; }; - 1525771C17CEFBD400BE417B /* DeprecatedEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedEnum.lua; path = ../../../scripting/lua/script/DeprecatedEnum.lua; sourceTree = ""; }; - 1525771D17CEFBD400BE417B /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = ../../../scripting/lua/script/DeprecatedOpenglEnum.lua; sourceTree = ""; }; + 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../build/cocos2d_libs.xcodeproj; sourceTree = ""; }; + 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../../../cocos/scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; + 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../../../cocos/scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; + 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../../../cocos/scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; + 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../../../cocos/scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; + 15A8A4591834C6AD00142BE0 /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Deprecated.lua; path = ../../../cocos/scripting/lua/script/Deprecated.lua; sourceTree = ""; }; + 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedClass.lua; path = ../../../cocos/scripting/lua/script/DeprecatedClass.lua; sourceTree = ""; }; + 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedEnum.lua; path = ../../../cocos/scripting/lua/script/DeprecatedEnum.lua; sourceTree = ""; }; + 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = ../../../cocos/scripting/lua/script/DeprecatedOpenglEnum.lua; sourceTree = ""; }; + 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = ../../../cocos/scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; + 15A8A45E1834C6AD00142BE0 /* json.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json.lua; path = ../../../cocos/scripting/lua/script/json.lua; sourceTree = ""; }; + 15A8A45F1834C6AD00142BE0 /* luaj.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaj.lua; path = ../../../cocos/scripting/lua/script/luaj.lua; sourceTree = ""; }; + 15A8A4601834C6AD00142BE0 /* luaoc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaoc.lua; path = ../../../cocos/scripting/lua/script/luaoc.lua; sourceTree = ""; }; + 15A8A4611834C6AD00142BE0 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../../../cocos/scripting/lua/script/Opengl.lua; sourceTree = ""; }; + 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../../../cocos/scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; + 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = ../../../cocos/scripting/lua/script/StudioConstants.lua; sourceTree = ""; }; + 15A8A4871834C90E00142BE0 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; 15C1568D1683131500D239F2 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; - 1A0227A517A3AA3500B867AD /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../../../scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; - 1A0227A617A3AA3500B867AD /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../../../scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; - 1A0227A717A3AA3500B867AD /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../../../scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; - 1A0227A817A3AA3500B867AD /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Deprecated.lua; path = ../../../scripting/lua/script/Deprecated.lua; sourceTree = ""; }; - 1A0227A917A3AA3500B867AD /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = ../../../scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; - 1A0227AA17A3AA3500B867AD /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../../../scripting/lua/script/Opengl.lua; sourceTree = ""; }; - 1A0227AB17A3AA3500B867AD /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../../../scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; 1AC3622316D47C5C000847F2 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = background.mp3; path = ../Resources/background.mp3; sourceTree = ""; }; 1AC3622416D47C5C000847F2 /* background.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.ogg; path = ../Resources/background.ogg; sourceTree = ""; }; 1AC3622516D47C5C000847F2 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = crop.png; path = ../Resources/crop.png; sourceTree = ""; }; @@ -250,8 +249,6 @@ 1AC3622C16D47C5C000847F2 /* land.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = land.png; path = ../Resources/land.png; sourceTree = ""; }; 1AC3622D16D47C5C000847F2 /* menu1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu1.png; path = ../Resources/menu1.png; sourceTree = ""; }; 1AC3622E16D47C5C000847F2 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu2.png; path = ../Resources/menu2.png; sourceTree = ""; }; - 1ADB273717CCA0C200634B5E /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../../../scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; - 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../cocos2d_libs.xcodeproj; sourceTree = ""; }; 1AF4C402178663F200122817 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 5023810717EBBCAC00990C9B /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; 5023810817EBBCAC00990C9B /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; @@ -305,12 +302,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 50D7C97117EBBEF7005D0B91 /* libbox2d Mac.a in Frameworks */, - 50D7C97217EBBEF7005D0B91 /* libchipmunk Mac.a in Frameworks */, - 50D7C97317EBBEF7005D0B91 /* libcocos2dx Mac.a in Frameworks */, - 50D7C97417EBBEF7005D0B91 /* libcocos2dx-extensions Mac.a in Frameworks */, - 50D7C97517EBBEF7005D0B91 /* libCocosDenshion Mac.a in Frameworks */, - 50D7C97617EBBEF7005D0B91 /* libluabindings Mac.a in Frameworks */, + 15A8A4881834C90F00142BE0 /* libcurl.dylib in Frameworks */, + 15A8A4821834C73500142BE0 /* libchipmunk Mac.a in Frameworks */, + 15A8A4831834C73500142BE0 /* libcocos2dx Mac.a in Frameworks */, + 15A8A4841834C73500142BE0 /* libcocos2dx-extensions Mac.a in Frameworks */, + 15A8A4851834C73500142BE0 /* libCocosDenshion Mac.a in Frameworks */, + 15A8A4861834C73500142BE0 /* libluabindings Mac.a in Frameworks */, 50D7C97017EBBEEC005D0B91 /* IOKit.framework in Frameworks */, 50D7C96E17EBBEE6005D0B91 /* AppKit.framework in Frameworks */, 50D7C96C17EBBEDF005D0B91 /* OpenGL.framework in Frameworks */, @@ -328,15 +325,13 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 15A8A4441834C43700142BE0 /* libchipmunk iOS.a in Frameworks */, + 15A8A4451834C43700142BE0 /* libcocos2dx iOS.a in Frameworks */, + 15A8A4461834C43700142BE0 /* libcocos2dx-extensions iOS.a in Frameworks */, + 15A8A4471834C43700142BE0 /* libCocosDenshion iOS.a in Frameworks */, + 15A8A4481834C43700142BE0 /* libluabindings iOS.a in Frameworks */, D6B061351803AC000077942B /* CoreMotion.framework in Frameworks */, - 50D7C96517EBBECA005D0B91 /* libbox2d iOS.a in Frameworks */, - 50D7C96617EBBECA005D0B91 /* libchipmunk iOS.a in Frameworks */, - 50D7C96717EBBECA005D0B91 /* libcocos2dx iOS.a in Frameworks */, - 50D7C96817EBBECA005D0B91 /* libcocos2dx-extensions iOS.a in Frameworks */, - 50D7C96917EBBECA005D0B91 /* libCocosDenshion iOS.a in Frameworks */, - 50D7C96A17EBBECB005D0B91 /* libluabindings iOS.a in Frameworks */, 1AF4C403178663F200122817 /* libz.dylib in Frameworks */, - 15C1568E1683131500D239F2 /* libcurl.a in Frameworks */, 50805AAF17EBBEAA004CFAD3 /* UIKit.framework in Frameworks */, 5023817A17EBBE8300990C9B /* OpenGLES.framework in Frameworks */, F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */, @@ -351,45 +346,49 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 15A8A4041834BDA200142BE0 /* Products */ = { + isa = PBXGroup; + children = ( + 15A8A4171834BDA200142BE0 /* libcocos2dx Mac.a */, + 15A8A4191834BDA200142BE0 /* libcocos2dx-extensions Mac.a */, + 15A8A41B1834BDA200142BE0 /* libchipmunk Mac.a */, + 15A8A41D1834BDA200142BE0 /* libbox2d Mac.a */, + 15A8A41F1834BDA200142BE0 /* libCocosDenshion Mac.a */, + 15A8A4211834BDA200142BE0 /* libjsbindings Mac.a */, + 15A8A4231834BDA200142BE0 /* libluabindings Mac.a */, + 15A8A4251834BDA200142BE0 /* libcocos2dx iOS.a */, + 15A8A4271834BDA200142BE0 /* libcocos2dx-extensions iOS.a */, + 15A8A4291834BDA200142BE0 /* libchipmunk iOS.a */, + 15A8A42B1834BDA200142BE0 /* libbox2d iOS.a */, + 15A8A42D1834BDA200142BE0 /* libCocosDenshion iOS.a */, + 15A8A42F1834BDA200142BE0 /* libjsbindings iOS.a */, + 15A8A4311834BDA200142BE0 /* libluabindings iOS.a */, + ); + name = Products; + sourceTree = ""; + }; 1A0227A417A3AA1A00B867AD /* Lua Common */ = { isa = PBXGroup; children = ( - 1525771B17CEFBD400BE417B /* DeprecatedClass.lua */, - 1525771C17CEFBD400BE417B /* DeprecatedEnum.lua */, - 1525771D17CEFBD400BE417B /* DeprecatedOpenglEnum.lua */, - 1A0227A517A3AA3500B867AD /* AudioEngine.lua */, - 1A0227A617A3AA3500B867AD /* CCBReaderLoad.lua */, - 1ADB273717CCA0C200634B5E /* Cocos2d.lua */, - 1A0227A717A3AA3500B867AD /* Cocos2dConstants.lua */, - 1A0227A817A3AA3500B867AD /* Deprecated.lua */, - 1A0227A917A3AA3500B867AD /* DrawPrimitives.lua */, - 1A0227AA17A3AA3500B867AD /* Opengl.lua */, - 1A0227AB17A3AA3500B867AD /* OpenglConstants.lua */, + 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */, + 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */, + 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */, + 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */, + 15A8A4591834C6AD00142BE0 /* Deprecated.lua */, + 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */, + 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */, + 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */, + 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */, + 15A8A45E1834C6AD00142BE0 /* json.lua */, + 15A8A45F1834C6AD00142BE0 /* luaj.lua */, + 15A8A4601834C6AD00142BE0 /* luaoc.lua */, + 15A8A4611834C6AD00142BE0 /* Opengl.lua */, + 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */, + 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */, ); name = "Lua Common"; sourceTree = ""; }; - 1AF4C3BA1786631600122817 /* Products */ = { - isa = PBXGroup; - children = ( - 1AF4C3CD1786631700122817 /* libcocos2dx Mac.a */, - 1AF4C3CF1786631700122817 /* libcocos2dx-extensions Mac.a */, - 1AF4C3D11786631700122817 /* libchipmunk Mac.a */, - 1AF4C3D31786631700122817 /* libbox2d Mac.a */, - 1AF4C3D51786631700122817 /* libCocosDenshion Mac.a */, - 1AF4C3D71786631700122817 /* libjsbindings Mac.a */, - 1AF4C3D91786631700122817 /* libluabindings Mac.a */, - 1AF4C3DB1786631700122817 /* libcocos2dx iOS.a */, - 1AF4C3DD1786631700122817 /* libcocos2dx-extensions iOS.a */, - 1AF4C3DF1786631700122817 /* libchipmunk iOS.a */, - 1AF4C3E11786631700122817 /* libbox2d iOS.a */, - 1AF4C3E31786631700122817 /* libCocosDenshion iOS.a */, - 1AF4C3E51786631700122817 /* libjsbindings iOS.a */, - 1AF4C3E71786631700122817 /* libluabindings iOS.a */, - ); - name = Products; - sourceTree = ""; - }; 5023810617EBBCAC00990C9B /* ios */ = { isa = PBXGroup; children = ( @@ -442,7 +441,7 @@ F293B3BD15EB7BE500256477 = { isa = PBXGroup; children = ( - 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */, + 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */, 5023810617EBBCAC00990C9B /* ios */, 5023817117EBBE3400990C9B /* mac */, F293BB7C15EB830F00256477 /* Classes */, @@ -465,6 +464,7 @@ F293B3CB15EB7BE500256477 /* Frameworks */ = { isa = PBXGroup; children = ( + 15A8A4871834C90E00142BE0 /* libcurl.dylib */, D6B061341803AC000077942B /* CoreMotion.framework */, 50D7C96F17EBBEEC005D0B91 /* IOKit.framework */, 50D7C96D17EBBEE6005D0B91 /* AppKit.framework */, @@ -528,7 +528,6 @@ buildRules = ( ); dependencies = ( - 5023816E17EBBDBE00990C9B /* PBXTargetDependency */, ); name = "HelloLua Mac"; productName = HelloLua; @@ -546,7 +545,6 @@ buildRules = ( ); dependencies = ( - 5023817017EBBDC600990C9B /* PBXTargetDependency */, ); name = "HelloLua iOS"; productName = HelloLua; @@ -578,8 +576,8 @@ projectDirPath = ""; projectReferences = ( { - ProductGroup = 1AF4C3BA1786631600122817 /* Products */; - ProjectRef = 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */; + ProductGroup = 15A8A4041834BDA200142BE0 /* Products */; + ProjectRef = 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */; }, ); projectRoot = ""; @@ -591,102 +589,102 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 1AF4C3CD1786631700122817 /* libcocos2dx Mac.a */ = { + 15A8A4171834BDA200142BE0 /* libcocos2dx Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx Mac.a"; - remoteRef = 1AF4C3CC1786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4161834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3CF1786631700122817 /* libcocos2dx-extensions Mac.a */ = { + 15A8A4191834BDA200142BE0 /* libcocos2dx-extensions Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx-extensions Mac.a"; - remoteRef = 1AF4C3CE1786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4181834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3D11786631700122817 /* libchipmunk Mac.a */ = { + 15A8A41B1834BDA200142BE0 /* libchipmunk Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libchipmunk Mac.a"; - remoteRef = 1AF4C3D01786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A41A1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3D31786631700122817 /* libbox2d Mac.a */ = { + 15A8A41D1834BDA200142BE0 /* libbox2d Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libbox2d Mac.a"; - remoteRef = 1AF4C3D21786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A41C1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3D51786631700122817 /* libCocosDenshion Mac.a */ = { + 15A8A41F1834BDA200142BE0 /* libCocosDenshion Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libCocosDenshion Mac.a"; - remoteRef = 1AF4C3D41786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A41E1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3D71786631700122817 /* libjsbindings Mac.a */ = { + 15A8A4211834BDA200142BE0 /* libjsbindings Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libjsbindings Mac.a"; - remoteRef = 1AF4C3D61786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4201834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3D91786631700122817 /* libluabindings Mac.a */ = { + 15A8A4231834BDA200142BE0 /* libluabindings Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libluabindings Mac.a"; - remoteRef = 1AF4C3D81786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4221834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3DB1786631700122817 /* libcocos2dx iOS.a */ = { + 15A8A4251834BDA200142BE0 /* libcocos2dx iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx iOS.a"; - remoteRef = 1AF4C3DA1786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4241834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3DD1786631700122817 /* libcocos2dx-extensions iOS.a */ = { + 15A8A4271834BDA200142BE0 /* libcocos2dx-extensions iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libcocos2dx-extensions iOS.a"; - remoteRef = 1AF4C3DC1786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4261834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3DF1786631700122817 /* libchipmunk iOS.a */ = { + 15A8A4291834BDA200142BE0 /* libchipmunk iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libchipmunk iOS.a"; - remoteRef = 1AF4C3DE1786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4281834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3E11786631700122817 /* libbox2d iOS.a */ = { + 15A8A42B1834BDA200142BE0 /* libbox2d iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libbox2d iOS.a"; - remoteRef = 1AF4C3E01786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A42A1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3E31786631700122817 /* libCocosDenshion iOS.a */ = { + 15A8A42D1834BDA200142BE0 /* libCocosDenshion iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libCocosDenshion iOS.a"; - remoteRef = 1AF4C3E21786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A42C1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3E51786631700122817 /* libjsbindings iOS.a */ = { + 15A8A42F1834BDA200142BE0 /* libjsbindings iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libjsbindings iOS.a"; - remoteRef = 1AF4C3E41786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A42E1834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AF4C3E71786631700122817 /* libluabindings iOS.a */ = { + 15A8A4311834BDA200142BE0 /* libluabindings iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; path = "libluabindings iOS.a"; - remoteRef = 1AF4C3E61786631700122817 /* PBXContainerItemProxy */; + remoteRef = 15A8A4301834BDA200142BE0 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXReferenceProxy section */ @@ -696,30 +694,34 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15A8A4711834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */, 5023814817EBBCE400990C9B /* background.mp3 in Resources */, 5023814917EBBCE400990C9B /* background.ogg in Resources */, 5023814A17EBBCE400990C9B /* crop.png in Resources */, + 15A8A4811834C6AD00142BE0 /* StudioConstants.lua in Resources */, + 15A8A4791834C6AD00142BE0 /* luaj.lua in Resources */, + 15A8A4671834C6AD00142BE0 /* CCBReaderLoad.lua in Resources */, 5023814B17EBBCE400990C9B /* dog.png in Resources */, 5023814D17EBBCE400990C9B /* effect1.wav in Resources */, + 15A8A46B1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */, 5023814F17EBBCE400990C9B /* farm.jpg in Resources */, + 15A8A4771834C6AD00142BE0 /* json.lua in Resources */, + 15A8A46F1834C6AD00142BE0 /* DeprecatedClass.lua in Resources */, + 15A8A47F1834C6AD00142BE0 /* OpenglConstants.lua in Resources */, 5023815017EBBCE400990C9B /* fonts in Resources */, + 15A8A47D1834C6AD00142BE0 /* Opengl.lua in Resources */, + 15A8A4691834C6AD00142BE0 /* Cocos2d.lua in Resources */, + 15A8A4731834C6AD00142BE0 /* DeprecatedOpenglEnum.lua in Resources */, 5023815117EBBCE400990C9B /* hello.lua in Resources */, + 15A8A46D1834C6AD00142BE0 /* Deprecated.lua in Resources */, 5023815217EBBCE400990C9B /* hello2.lua in Resources */, + 15A8A4751834C6AD00142BE0 /* DrawPrimitives.lua in Resources */, + 15A8A47B1834C6AD00142BE0 /* luaoc.lua in Resources */, 5023815317EBBCE400990C9B /* land.png in Resources */, 5023815617EBBCE400990C9B /* menu1.png in Resources */, 5023815717EBBCE400990C9B /* menu2.png in Resources */, - 5023815917EBBCE400990C9B /* AudioEngine.lua in Resources */, 5023817617EBBE3400990C9B /* Icon.icns in Resources */, - 5023815A17EBBCE400990C9B /* CCBReaderLoad.lua in Resources */, - 5023815B17EBBCE400990C9B /* Cocos2dConstants.lua in Resources */, - 5023815C17EBBCE400990C9B /* Deprecated.lua in Resources */, - 5023815D17EBBCE400990C9B /* DrawPrimitives.lua in Resources */, - 5023815E17EBBCE400990C9B /* Opengl.lua in Resources */, - 5023816117EBBCE400990C9B /* OpenglConstants.lua in Resources */, - 5023816217EBBCE400990C9B /* Cocos2d.lua in Resources */, - 5023816317EBBCE400990C9B /* DeprecatedClass.lua in Resources */, - 5023816417EBBCE400990C9B /* DeprecatedEnum.lua in Resources */, - 5023816717EBBCE400990C9B /* DeprecatedOpenglEnum.lua in Resources */, + 15A8A4651834C6AD00142BE0 /* AudioEngine.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -727,45 +729,49 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15A8A46E1834C6AD00142BE0 /* DeprecatedClass.lua in Resources */, + 15A8A4491834C64F00142BE0 /* Icon-114.png in Resources */, 5023811D17EBBCAC00990C9B /* Icon-120.png in Resources */, + 15A8A47E1834C6AD00142BE0 /* OpenglConstants.lua in Resources */, 5091733B17ECE17A00D62437 /* Icon-100.png in Resources */, + 15A8A4781834C6AD00142BE0 /* luaj.lua in Resources */, 1AC3622F16D47C5C000847F2 /* background.mp3 in Resources */, 1AC3623016D47C5C000847F2 /* background.ogg in Resources */, 1AC3623116D47C5C000847F2 /* crop.png in Resources */, + 15A8A47C1834C6AD00142BE0 /* Opengl.lua in Resources */, + 15A8A4741834C6AD00142BE0 /* DrawPrimitives.lua in Resources */, 1AC3623216D47C5C000847F2 /* dog.png in Resources */, 5023811B17EBBCAC00990C9B /* Default@2x.png in Resources */, 1AC3623316D47C5C000847F2 /* effect1.wav in Resources */, + 15A8A4681834C6AD00142BE0 /* Cocos2d.lua in Resources */, 5091733617ECE17A00D62437 /* Icon-29.png in Resources */, + 15A8A4801834C6AD00142BE0 /* StudioConstants.lua in Resources */, 5023811917EBBCAC00990C9B /* Default-568h@2x.png in Resources */, 1AC3623416D47C5C000847F2 /* farm.jpg in Resources */, 1AC3623516D47C5C000847F2 /* fonts in Resources */, + 15A8A4721834C6AD00142BE0 /* DeprecatedOpenglEnum.lua in Resources */, + 15A8A4701834C6AD00142BE0 /* DeprecatedEnum.lua in Resources */, + 15A8A46A1834C6AD00142BE0 /* Cocos2dConstants.lua in Resources */, 1AC3623616D47C5C000847F2 /* hello.lua in Resources */, 5091733917ECE17A00D62437 /* Icon-58.png in Resources */, + 15A8A4641834C6AD00142BE0 /* AudioEngine.lua in Resources */, 1AC3623716D47C5C000847F2 /* hello2.lua in Resources */, 1AC3623816D47C5C000847F2 /* land.png in Resources */, + 15A8A4661834C6AD00142BE0 /* CCBReaderLoad.lua in Resources */, 5023811F17EBBCAC00990C9B /* Icon-152.png in Resources */, 5023812017EBBCAC00990C9B /* Icon-57.png in Resources */, 1AC3623916D47C5C000847F2 /* menu1.png in Resources */, + 15A8A47A1834C6AD00142BE0 /* luaoc.lua in Resources */, 1AC3623A16D47C5C000847F2 /* menu2.png in Resources */, 5023812217EBBCAC00990C9B /* Icon-76.png in Resources */, + 15A8A46C1834C6AD00142BE0 /* Deprecated.lua in Resources */, 5091733A17ECE17A00D62437 /* Icon-80.png in Resources */, - 1A0227AC17A3AA3500B867AD /* AudioEngine.lua in Resources */, - 1A0227AD17A3AA3500B867AD /* CCBReaderLoad.lua in Resources */, - 1A0227AE17A3AA3500B867AD /* Cocos2dConstants.lua in Resources */, - 1A0227AF17A3AA3500B867AD /* Deprecated.lua in Resources */, - 1A0227B017A3AA3500B867AD /* DrawPrimitives.lua in Resources */, 5091733717ECE17A00D62437 /* Icon-40.png in Resources */, - 1A0227B117A3AA3500B867AD /* Opengl.lua in Resources */, 5023811E17EBBCAC00990C9B /* Icon-144.png in Resources */, + 15A8A4761834C6AD00142BE0 /* json.lua in Resources */, 5023811A17EBBCAC00990C9B /* Default.png in Resources */, - 1A0227B217A3AA3500B867AD /* OpenglConstants.lua in Resources */, 5091733817ECE17A00D62437 /* Icon-50.png in Resources */, - 1ADB273817CCA0C200634B5E /* Cocos2d.lua in Resources */, - 1525771E17CEFBD400BE417B /* DeprecatedClass.lua in Resources */, - 1525771F17CEFBD400BE417B /* DeprecatedEnum.lua in Resources */, 5023812117EBBCAC00990C9B /* Icon-72.png in Resources */, - 5023811C17EBBCAC00990C9B /* Icon-114.png in Resources */, - 1525772017CEFBD400BE417B /* DeprecatedOpenglEnum.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -794,24 +800,11 @@ }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 5023816E17EBBDBE00990C9B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "build-all-libs Mac"; - targetProxy = 5023816D17EBBDBE00990C9B /* PBXContainerItemProxy */; - }; - 5023817017EBBDC600990C9B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "build-all-libs iOS"; - targetProxy = 5023816F17EBBDC600990C9B /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin XCBuildConfiguration section */ 5023816917EBBCE400990C9B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; + ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; COMBINE_HIDPI_IMAGES = YES; GCC_DYNAMIC_NO_PIC = NO; @@ -821,30 +814,9 @@ CC_TARGET_OS_MAC, "$(inherited)", ); - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../scripting/lua/tolua\"", - "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", - "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", - "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/mac\"", - "\"$(SRCROOT)/../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../CocosDenshion/include\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/constraints\"", - "\"$(SRCROOT)/../../../external\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/mac\"", - "\"$(SRCROOT)/../../../extensions\"", - "\"$(SRCROOT)/../../../external/libwebsockets/mac/include\"", - ); + HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = mac/Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx/platform/third_party/mac/libraries", - "$(inherited)", - "\"$(SRCROOT)/../../../scripting/lua/luajit/mac\"", - "\"$(SRCROOT)/../../../external/libwebsockets/mac/lib\"", - ); + LIBRARY_SEARCH_PATHS = ""; OTHER_LDFLAGS = ( "-image_base", 100000000, @@ -852,13 +824,14 @@ 10000, ); SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/mac $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../external/glfw3/include/mac $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; }; name = Debug; }; 5023816A17EBBCE400990C9B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; + ALWAYS_SEARCH_USER_PATHS = YES; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -867,30 +840,9 @@ CC_TARGET_OS_MAC, "$(inherited)", ); - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../scripting/lua/tolua\"", - "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", - "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", - "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/mac\"", - "\"$(SRCROOT)/../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../CocosDenshion/include\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/constraints\"", - "\"$(SRCROOT)/../../../external\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/mac\"", - "\"$(SRCROOT)/../../../extensions\"", - "\"$(SRCROOT)/../../../external/libwebsockets/mac/include\"", - ); + HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = mac/Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx/platform/third_party/mac/libraries", - "$(inherited)", - "\"$(SRCROOT)/../../../scripting/lua/luajit/mac\"", - "\"$(SRCROOT)/../../../external/libwebsockets/mac/lib\"", - ); + LIBRARY_SEARCH_PATHS = ""; OTHER_LDFLAGS = ( "-image_base", 100000000, @@ -898,6 +850,7 @@ 10000, ); SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/mac $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../external/glfw3/include/mac $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; }; name = Release; }; @@ -973,7 +926,7 @@ F293B6C515EB7BEA00256477 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; + ALWAYS_SEARCH_USER_PATHS = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_DYNAMIC_NO_PIC = NO; @@ -983,41 +936,20 @@ CC_TARGET_OS_IPHONE, "$(inherited)", ); - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../scripting/lua/tolua\"", - "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", - "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", - "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../audio/include\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/constraints\"", - "\"$(SRCROOT)/../../../external\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/ios/Simulation\"", - "\"$(SRCROOT)/../../../extensions\"", - "\"$(SRCROOT)/../../../external/libwebsockets/ios/include\"", - ); + HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries", - "$(inherited)", - "\"$(SRCROOT)/../../../scripting/lua/luajit/ios\"", - "\"$(SRCROOT)/../../../external/libwebsockets/ios/lib\"", - ); + LIBRARY_SEARCH_PATHS = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/ios $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; }; name = Debug; }; F293B6C615EB7BEA00256477 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; + ALWAYS_SEARCH_USER_PATHS = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; COMPRESS_PNG_FILES = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1026,34 +958,13 @@ CC_TARGET_OS_IPHONE, "$(inherited)", ); - HEADER_SEARCH_PATHS = ( - "\"$(SRCROOT)/../../../cocos2dx\"", - "\"$(SRCROOT)/../../../cocos2dx/kazmath/include\"", - "\"$(SRCROOT)/../../../scripting/lua/tolua\"", - "\"$(SRCROOT)/../../../scripting/lua/luajit/include\"", - "\"$(SRCROOT)/../../../scripting/auto-generated/lua-bindings\"", - "\"$(SRCROOT)/../../../scripting/lua/cocos2dx_support\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/ios\"", - "\"$(SRCROOT)/../../../cocos2dx/include\"", - "\"$(SRCROOT)/../../../audio/include\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/chipmunk\"", - "\"$(SRCROOT)/../../../external/chipmunk/include/constraints\"", - "\"$(SRCROOT)/../../../external\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios\"", - "\"$(SRCROOT)/../../../cocos2dx/platform/ios/Simulation\"", - "\"$(SRCROOT)/../../../extensions\"", - "\"$(SRCROOT)/../../../external/libwebsockets/ios/include\"", - ); + HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; - LIBRARY_SEARCH_PATHS = ( - "$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries", - "$(inherited)", - "\"$(SRCROOT)/../../../scripting/lua/luajit/ios\"", - "\"$(SRCROOT)/../../../external/libwebsockets/ios/lib\"", - ); + LIBRARY_SEARCH_PATHS = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/ios $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; }; name = Release; }; From 050a47c4eb5720b3120a10dbdd9515d66d0f3a77 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 15 Nov 2013 14:35:55 +0800 Subject: [PATCH 182/185] issue #2854:Disable CDT Builder on Eclipse --- .../AssetsManagerTest/proj.android/.classpath | 1 + .../AssetsManagerTest/proj.android/.project | 64 ++----------------- samples/Cpp/HelloCpp/proj.android/.classpath | 2 +- samples/Cpp/HelloCpp/proj.android/.project | 64 ++----------------- .../Cpp/SimpleGame/proj.android/.classpath | 2 +- samples/Cpp/SimpleGame/proj.android/.project | 64 ++----------------- samples/Cpp/TestCpp/proj.android/.project | 64 ++----------------- .../CocosDragonJS/proj.android/.classpath | 1 + .../CocosDragonJS/proj.android/.project | 64 ++----------------- .../CrystalCraze/proj.android/.classpath | 1 + .../CrystalCraze/proj.android/.project | 64 ++----------------- .../MoonWarriors/proj.android/.classpath | 1 + .../MoonWarriors/proj.android/.project | 64 ++----------------- .../TestJavascript/proj.android/.classpath | 1 + .../TestJavascript/proj.android/.project | 64 ++----------------- .../WatermelonWithMe/proj.android/.classpath | 1 + .../WatermelonWithMe/proj.android/.project | 64 ++----------------- samples/Lua/HelloLua/proj.android/.classpath | 1 + samples/Lua/HelloLua/proj.android/.project | 52 ++------------- samples/Lua/TestLua/proj.android/.classpath | 1 + samples/Lua/TestLua/proj.android/.project | 52 ++------------- .../proj.android/.classpath | 5 +- .../multi-platform-cpp/proj.android/.project | 60 ++--------------- .../multi-platform-js/proj.android/.classpath | 5 +- .../multi-platform-js/proj.android/.project | 64 +------------------ .../proj.android/.classpath | 5 +- 26 files changed, 72 insertions(+), 759 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/proj.android/.classpath b/samples/Cpp/AssetsManagerTest/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/.classpath +++ b/samples/Cpp/AssetsManagerTest/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Cpp/AssetsManagerTest/proj.android/.project b/samples/Cpp/AssetsManagerTest/proj.android/.project index 3ce737b86e..87fc1c9e0e 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/.project +++ b/samples/Cpp/AssetsManagerTest/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch diff --git a/samples/Cpp/HelloCpp/proj.android/.classpath b/samples/Cpp/HelloCpp/proj.android/.classpath index 0b08408342..c06dfcb8e5 100644 --- a/samples/Cpp/HelloCpp/proj.android/.classpath +++ b/samples/Cpp/HelloCpp/proj.android/.classpath @@ -2,8 +2,8 @@ + - diff --git a/samples/Cpp/HelloCpp/proj.android/.project b/samples/Cpp/HelloCpp/proj.android/.project index 00f27149c6..93335a6f16 100644 --- a/samples/Cpp/HelloCpp/proj.android/.project +++ b/samples/Cpp/HelloCpp/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (5).launch diff --git a/samples/Cpp/SimpleGame/proj.android/.classpath b/samples/Cpp/SimpleGame/proj.android/.classpath index 0b08408342..c06dfcb8e5 100644 --- a/samples/Cpp/SimpleGame/proj.android/.classpath +++ b/samples/Cpp/SimpleGame/proj.android/.classpath @@ -2,8 +2,8 @@ + - diff --git a/samples/Cpp/SimpleGame/proj.android/.project b/samples/Cpp/SimpleGame/proj.android/.project index c9f6aeb48d..4e2c99e96f 100644 --- a/samples/Cpp/SimpleGame/proj.android/.project +++ b/samples/Cpp/SimpleGame/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (8).launch diff --git a/samples/Cpp/TestCpp/proj.android/.project b/samples/Cpp/TestCpp/proj.android/.project index ba4ce24ee5..b02e99a830 100644 --- a/samples/Cpp/TestCpp/proj.android/.project +++ b/samples/Cpp/TestCpp/proj.android/.project @@ -21,68 +21,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (9).launch diff --git a/samples/Javascript/CocosDragonJS/proj.android/.classpath b/samples/Javascript/CocosDragonJS/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/.classpath +++ b/samples/Javascript/CocosDragonJS/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Javascript/CocosDragonJS/proj.android/.project b/samples/Javascript/CocosDragonJS/proj.android/.project index 0855474886..0a89f1ca12 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/.project +++ b/samples/Javascript/CocosDragonJS/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (3).launch diff --git a/samples/Javascript/CrystalCraze/proj.android/.classpath b/samples/Javascript/CrystalCraze/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Javascript/CrystalCraze/proj.android/.classpath +++ b/samples/Javascript/CrystalCraze/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Javascript/CrystalCraze/proj.android/.project b/samples/Javascript/CrystalCraze/proj.android/.project index 37434e64a4..274dcabae3 100644 --- a/samples/Javascript/CrystalCraze/proj.android/.project +++ b/samples/Javascript/CrystalCraze/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (4).launch diff --git a/samples/Javascript/MoonWarriors/proj.android/.classpath b/samples/Javascript/MoonWarriors/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Javascript/MoonWarriors/proj.android/.classpath +++ b/samples/Javascript/MoonWarriors/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Javascript/MoonWarriors/proj.android/.project b/samples/Javascript/MoonWarriors/proj.android/.project index ce591a7d55..6c9a469ace 100644 --- a/samples/Javascript/MoonWarriors/proj.android/.project +++ b/samples/Javascript/MoonWarriors/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (7).launch diff --git a/samples/Javascript/TestJavascript/proj.android/.classpath b/samples/Javascript/TestJavascript/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Javascript/TestJavascript/proj.android/.classpath +++ b/samples/Javascript/TestJavascript/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Javascript/TestJavascript/proj.android/.project b/samples/Javascript/TestJavascript/proj.android/.project index dd20aeed95..4474f112c9 100644 --- a/samples/Javascript/TestJavascript/proj.android/.project +++ b/samples/Javascript/TestJavascript/proj.android/.project @@ -36,68 +36,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (10).launch diff --git a/samples/Javascript/WatermelonWithMe/proj.android/.classpath b/samples/Javascript/WatermelonWithMe/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/.classpath +++ b/samples/Javascript/WatermelonWithMe/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Javascript/WatermelonWithMe/proj.android/.project b/samples/Javascript/WatermelonWithMe/proj.android/.project index a4e3c72357..e6fddbb64c 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/.project +++ b/samples/Javascript/WatermelonWithMe/proj.android/.project @@ -31,68 +31,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (12).launch diff --git a/samples/Lua/HelloLua/proj.android/.classpath b/samples/Lua/HelloLua/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Lua/HelloLua/proj.android/.classpath +++ b/samples/Lua/HelloLua/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Lua/HelloLua/proj.android/.project b/samples/Lua/HelloLua/proj.android/.project index 6b0e37d723..633e8ba316 100644 --- a/samples/Lua/HelloLua/proj.android/.project +++ b/samples/Lua/HelloLua/proj.android/.project @@ -6,56 +6,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (6).launch diff --git a/samples/Lua/TestLua/proj.android/.classpath b/samples/Lua/TestLua/proj.android/.classpath index 3f9691c5dd..0b08408342 100644 --- a/samples/Lua/TestLua/proj.android/.classpath +++ b/samples/Lua/TestLua/proj.android/.classpath @@ -4,5 +4,6 @@ + diff --git a/samples/Lua/TestLua/proj.android/.project b/samples/Lua/TestLua/proj.android/.project index 3c1261c623..6c0b0be311 100644 --- a/samples/Lua/TestLua/proj.android/.project +++ b/samples/Lua/TestLua/proj.android/.project @@ -6,56 +6,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.buildArguments - ${ProjDirPath}/build_native.sh - - - org.eclipse.cdt.make.core.buildCommand - bash - - - org.eclipse.cdt.make.core.buildLocation - ${ProjDirPath} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (11).launch diff --git a/template/multi-platform-cpp/proj.android/.classpath b/template/multi-platform-cpp/proj.android/.classpath index a4763d1eec..0b08408342 100644 --- a/template/multi-platform-cpp/proj.android/.classpath +++ b/template/multi-platform-cpp/proj.android/.classpath @@ -1,8 +1,9 @@ - - + + + diff --git a/template/multi-platform-cpp/proj.android/.project b/template/multi-platform-cpp/proj.android/.project index b0bd2f6953..c07874533a 100644 --- a/template/multi-platform-cpp/proj.android/.project +++ b/template/multi-platform-cpp/proj.android/.project @@ -21,60 +21,12 @@ - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -C ${ProjDirPath} NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt -j2 - - - org.eclipse.cdt.make.core.buildCommand - ${ProjDirPath}/ANDROID_NDK/ndk-build - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + LaunchConfigHandle + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder (1).launch @@ -102,7 +54,7 @@ Classes 2 - COCOS2DX/projects/HelloCpp/Classes + COCOS2DX/projects/HelloCpp/Classes cocos2dx @@ -112,7 +64,7 @@ extensions 2 - COCOS2DX/extensions + COCOS2DX/extensions scripting diff --git a/template/multi-platform-js/proj.android/.classpath b/template/multi-platform-js/proj.android/.classpath index a4763d1eec..0b08408342 100644 --- a/template/multi-platform-js/proj.android/.classpath +++ b/template/multi-platform-js/proj.android/.classpath @@ -1,8 +1,9 @@ - - + + + diff --git a/template/multi-platform-js/proj.android/.project b/template/multi-platform-js/proj.android/.project index ea6400b5fb..c65124f88e 100644 --- a/template/multi-platform-js/proj.android/.project +++ b/template/multi-platform-js/proj.android/.project @@ -26,65 +26,7 @@ LaunchConfigHandle - <project>/.externalToolBuilders/Javah_jni_builder.launch - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -C ${ProjDirPath} NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt -j2 - - - org.eclipse.cdt.make.core.buildCommand - ${ProjDirPath}/ANDROID_NDK/ndk-build - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false + <project>/.externalToolBuilders/org.eclipse.cdt.managedbuilder.core.genmakebuilder.launch @@ -112,7 +54,7 @@ Classes 2 - COCOS2DX/projects/HelloJavascript/Classes + COCOS2DX/projects/HelloJavascript/Classes cocos2dx @@ -122,7 +64,7 @@ extensions 2 - COCOS2DX/extensions + COCOS2DX/extensions scripting diff --git a/template/multi-platform-lua/proj.android/.classpath b/template/multi-platform-lua/proj.android/.classpath index a4763d1eec..0b08408342 100644 --- a/template/multi-platform-lua/proj.android/.classpath +++ b/template/multi-platform-lua/proj.android/.classpath @@ -1,8 +1,9 @@ - - + + + From 75d9bde4596d714b20b268c0b49063e397910be0 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 15 Nov 2013 14:37:34 +0800 Subject: [PATCH 183/185] Modify relative layout --- cocos/gui/UILayout.cpp | 94 +++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 14 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index be152ec817..c7c48dfb24 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -813,9 +813,9 @@ void UILayout::doLayout() } UIMargin relativeWidgetMargin; UIMargin mg = layoutParameter->getMargin(); - if (relativeWidget) + if (relativeWidgetLP) { - relativeWidgetMargin = relativeWidget->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)->getMargin(); + relativeWidgetMargin = relativeWidgetLP->getMargin(); } //handle margin switch (align) @@ -854,62 +854,128 @@ void UILayout::doLayout() case RELATIVE_LOCATION_ABOVE_LEFTALIGN: finalPosY += mg.bottom; - finalPosY += relativeWidgetMargin.top; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) + { + finalPosY += relativeWidgetMargin.top; + } finalPosX += mg.left; break; case RELATIVE_LOCATION_ABOVE_RIGHTALIGN: finalPosY += mg.bottom; - finalPosY += relativeWidgetMargin.top; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) + { + finalPosY += relativeWidgetMargin.top; + } finalPosX -= mg.right; break; case RELATIVE_LOCATION_ABOVE_CENTER: finalPosY += mg.bottom; - finalPosY += relativeWidgetMargin.top; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT) + { + finalPosY += relativeWidgetMargin.top; + } break; case RELATIVE_LOCATION_LEFT_OF_TOPALIGN: finalPosX -= mg.right; - finalPosX -= relativeWidgetMargin.left; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) + { + finalPosX -= relativeWidgetMargin.left; + } finalPosY -= mg.top; break; case RELATIVE_LOCATION_LEFT_OF_BOTTOMALIGN: finalPosX -= mg.right; - finalPosX -= relativeWidgetMargin.left; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) + { + finalPosX -= relativeWidgetMargin.left; + } finalPosY += mg.bottom; break; case RELATIVE_LOCATION_LEFT_OF_CENTER: finalPosX -= mg.right; - finalPosX -= relativeWidgetMargin.left; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_LEFT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_NONE + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL) + { + finalPosX -= relativeWidgetMargin.left; + } break; case RELATIVE_LOCATION_RIGHT_OF_TOPALIGN: finalPosX += mg.left; - finalPosX += relativeWidgetMargin.right; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) + { + finalPosX += relativeWidgetMargin.right; + } finalPosY -= mg.top; break; case RELATIVE_LOCATION_RIGHT_OF_BOTTOMALIGN: finalPosX += mg.left; - finalPosX += relativeWidgetMargin.right; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) + { + finalPosX += relativeWidgetMargin.right; + } finalPosY += mg.bottom; break; case RELATIVE_LOCATION_RIGHT_OF_CENTER: finalPosX += mg.left; - finalPosX += relativeWidgetMargin.right; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_TOP_RIGHT + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL) + { + finalPosX += relativeWidgetMargin.right; + } break; case RELATIVE_LOCATION_BELOW_LEFTALIGN: finalPosY -= mg.top; - finalPosY -= relativeWidgetMargin.bottom; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) + { + finalPosY -= relativeWidgetMargin.bottom; + } finalPosX += mg.left; break; case RELATIVE_LOCATION_BELOW_RIGHTALIGN: finalPosY -= mg.top; - finalPosY -= relativeWidgetMargin.bottom; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) + { + finalPosY -= relativeWidgetMargin.bottom; + } finalPosX -= mg.right; break; case RELATIVE_LOCATION_BELOW_CENTER: finalPosY -= mg.top; - finalPosY -= relativeWidgetMargin.bottom; + if (relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_LEFT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM + && relativeWidgetLP->getAlign() != RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL) + { + finalPosY -= relativeWidgetMargin.bottom; + } break; default: break; From 0c309acbe7e0e517926af081d4f0f25001507080 Mon Sep 17 00:00:00 2001 From: boyu0 Date: Fri, 15 Nov 2013 15:41:43 +0800 Subject: [PATCH 184/185] fix CCBReader magic bytes compare bug which cause CocosBuilderTest turns black --- cocos/editor-support/cocosbuilder/CCBReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/cocosbuilder/CCBReader.cpp b/cocos/editor-support/cocosbuilder/CCBReader.cpp index baf81a6f55..bf566770fe 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.cpp +++ b/cocos/editor-support/cocosbuilder/CCBReader.cpp @@ -387,7 +387,7 @@ bool CCBReader::readHeader() int magicBytes = *((int*)(this->_bytes + this->_currentByte)); this->_currentByte += 4; - if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != (*reinterpret_cast("ccbi"))) { + if(CC_SWAP_INT32_BIG_TO_HOST(magicBytes) != (*reinterpret_cast("ccbi"))) { return false; } From 6db31508cc165de2f99b26ae0af5cae7719bc09b Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 15 Nov 2013 16:01:03 +0800 Subject: [PATCH 185/185] fix Incomplete helloLua project configuration. --- samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj | 2 +- .../multi-platform-lua/proj.win32/HelloLua.sln | 14 ++++++-------- .../multi-platform-lua/proj.win32/HelloLua.vcxproj | 5 ++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj index fb17ddfe2e..aae3a8cf1f 100644 --- a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj +++ b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj @@ -97,7 +97,7 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) - lua51.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows diff --git a/template/multi-platform-lua/proj.win32/HelloLua.sln b/template/multi-platform-lua/proj.win32/HelloLua.sln index 5fdeacb7a4..d5769661f0 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.sln +++ b/template/multi-platform-lua/proj.win32/HelloLua.sln @@ -7,7 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua.vcxpro {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject @@ -15,12 +14,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\e ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} - {929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libBox2D", "..\..\..\external\Box2D\proj.win32\Box2D.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" @@ -35,6 +31,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\..\.. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\..\..\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\..\..\cocos\gui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -49,10 +47,6 @@ Global {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32 {21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 - {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.ActiveCfg = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Debug|Win32.Build.0 = Debug|Win32 {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}.Release|Win32.ActiveCfg = Release|Win32 @@ -81,6 +75,10 @@ Global {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Debug|Win32.Build.0 = Debug|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.ActiveCfg = Release|Win32 {B57CF53F-2E49-4031-9822-047CC0E6BDE2}.Release|Win32.Build.0 = Release|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.Build.0 = Debug|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.ActiveCfg = Release|Win32 + {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj index b15be7cabb..6762f6a744 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj @@ -84,7 +84,7 @@ MachineX86 true $(OutDir);%(AdditionalLibraryDirectories) - lua51.lib;websockets.lib;%(AdditionalDependencies) + libcurl_imp.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) 0x0409 @@ -187,6 +187,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} + {df2638c0-8128-4847-867c-6eafe3dee7b5}