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 + diff --git a/AUTHORS b/AUTHORS index 37e302de05..576904e3bf 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,7 @@ Core Developers: Qingkui Hu (samuele3hu) Huabing Xu (dabingnn) Bo Yu (boyu0) + Wenhai Lin(Dhilan007) Developers: @@ -594,9 +595,12 @@ 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() + Configuration of VAO in runtime + Add setUniformLocationWithMatrix2fv, setUniformLocationWithMatrix3fv mothed into GLProgram class metadao make create_project.py more pythonic and fix some typoes @@ -612,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. @@ -629,6 +634,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. @@ -642,6 +648,16 @@ 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. + + xhcnb + Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + + bopohaa + Fixed a bug that Webp test crashes. Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 93e703edb1..ec818494f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,8 +14,19 @@ 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. + [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. + [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 + [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. @@ -30,6 +41,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] @@ -37,6 +49,8 @@ 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 + [FIX] Wrong convention to jsval in cccolor4f_to_jsval and cccolor3b_to_jsval [Lua Binding] [NEW] Added Armature lua binding and added test samples. diff --git a/README.md b/README.md index 1cfd3a014d..c5d464e62f 100644 --- a/README.md +++ b/README.md @@ -97,11 +97,15 @@ $ open samples.xcodeproj * For Linux ``` -$ cd cocos2d-x -$ cmake CMakeLists.txt +$ cd cocos2d-x/build +$ ./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. `install-deps-linux.sh` only has to be run onece. + * For Windows Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln` 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/android-build.py b/build/android-build.py index d1a272c2db..34ac6010d9 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 @@ -95,7 +96,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): @@ -131,13 +133,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": @@ -205,4 +220,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) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 1ebbc707a8..6fdbc42758 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 +e1cdac55b4aa56ff532e0d23fe27272510058a42 \ No newline at end of file diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index 420d377772..c0057afb57 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 +9490bdedbc6e817240a1661c6bcbcafc9095c267 \ No newline at end of file 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/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 4a01fd7663..dd2b528bce 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) { @@ -327,10 +327,10 @@ 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_INT(_targets, &target, element); + HASH_FIND_PTR(_targets, &target, element); if (element) { return element->actions ? element->actions->num : 0; 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/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..b756a36193 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); } @@ -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/CCConfiguration.cpp b/cocos/2d/CCConfiguration.cpp index 6e5b5cf966..48b4156ca5 100644 --- a/cocos/2d/CCConfiguration.cpp +++ b/cocos/2d/CCConfiguration.cpp @@ -259,7 +259,11 @@ bool Configuration::supportsDiscardFramebuffer() const bool Configuration::supportsShareableVAO() const { - return _supportsShareableVAO; + #if CC_TEXTURE_ATLAS_USE_VAO + return _supportsShareableVAO; + #else + return false; + #endif } // diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 130d170d30..f948b099bf 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) @@ -437,7 +462,7 @@ void Director::purgeCachedData(void) if (s_SharedDirector->getOpenGLView()) { SpriteFrameCache::getInstance()->removeUnusedSpriteFrames(); - TextureCache::getInstance()->removeUnusedTextures(); + _textureCache->removeUnusedTextures(); } FileUtils::getInstance()->purgeCachedEntries(); } @@ -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 @@ -841,14 +867,13 @@ void Director::getFPSImageData(unsigned char** datapointer, long* length) void Director::createStatsLabel() { Texture2D *texture = nullptr; - TextureCache *textureCache = TextureCache::getInstance(); 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(); } @@ -865,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); /* 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/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index d373709686..67ba1075b1 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -25,6 +25,7 @@ #include "CCGL.h" #include "CCNotificationCenter.h" #include "CCEventType.h" +#include "CCConfiguration.h" NS_CC_BEGIN @@ -114,11 +115,12 @@ 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 +161,11 @@ 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 +182,10 @@ 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 +210,24 @@ 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/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 */ 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; } 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/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 5e2173204f..25063eb023 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) { } @@ -136,7 +136,7 @@ FontFreeType::~FontFreeType() } if (_ttfData) { - delete _ttfData; + free(_ttfData); _ttfData = nullptr; } } 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); 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/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..4c64ca3418 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); } @@ -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); } @@ -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..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); @@ -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 { @@ -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) @@ -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'; @@ -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/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/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/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/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); } 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/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..e85ea6a3c4 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; @@ -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); } @@ -396,17 +396,17 @@ 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); - // 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(); } @@ -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/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 3cf7d9e1d4..36d2567809 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -37,6 +37,7 @@ THE SOFTWARE. #include "TransformUtils.h" #include "CCNotificationCenter.h" #include "CCEventType.h" +#include "CCConfiguration.h" // extern #include "kazmath/GL/matrix.h" @@ -57,11 +58,14 @@ 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 +85,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 +97,11 @@ 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 +358,48 @@ 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 +458,14 @@ 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 +475,6 @@ void ParticleSystemQuad::setTotalParticles(int tp) resetSystem(); } -#if CC_TEXTURE_ATLAS_USE_VAO void ParticleSystemQuad::setupVBOandVAO() { // clean VAO @@ -508,7 +514,6 @@ void ParticleSystemQuad::setupVBOandVAO() CHECK_GL_ERROR_DEBUG(); } -#else void ParticleSystemQuad::setupVBO() { @@ -527,15 +532,16 @@ 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 +584,14 @@ 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 +606,12 @@ 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/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index 0106118b43..594810cf96 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/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/cocos/2d/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp index 1db8ba0678..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) { } @@ -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/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/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/CCScene.cpp b/cocos/2d/CCScene.cpp index 6c2a0db436..97d4fbec65 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()) { @@ -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/2d/CCScheduler.cpp b/cocos/2d/CCScheduler.cpp index 3f9c9da9f8..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) @@ -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); } } @@ -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; @@ -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/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/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index fa6f4878b0..186f569676 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); @@ -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); @@ -1107,7 +1113,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 +1122,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/CCSprite.h b/cocos/2d/CCSprite.h index 7ebf7ff616..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 @@ -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 @@ -542,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 // @@ -574,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 }; @@ -584,4 +585,4 @@ protected: NS_CC_END -#endif // __SPITE_NODE_CCSPRITE_H__ +#endif // __SPRITE_NODE_CCSPRITE_H__ diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 820a999401..03a71abf1c 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); } @@ -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/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/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 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/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 934b88a091..895aab58de 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 +const std::string& TextFieldTTF::getString() const { - return _inputText->c_str(); + return _inputText; } // 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..a6ae42dc8e 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 const char* getString(void) const; + virtual void setString(const std::string& text) override; + virtual const std::string& getString() const override; 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/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 397bdbf68a..d8c0bfbaf8 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); @@ -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(); @@ -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; @@ -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 ); @@ -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/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index 3ef2a365c4..ec42b9dbfd 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -32,7 +32,9 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCNotificationCenter.h" #include "CCEventType.h" +#include "CCDirector.h" #include "CCGL.h" +#include "CCConfiguration.h" // support #include "CCTexture2D.h" #include "CCString.h" @@ -60,10 +62,11 @@ 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 @@ -71,12 +74,12 @@ TextureAtlas::~TextureAtlas() #endif } -int TextureAtlas::getTotalQuads() const +long TextureAtlas::getTotalQuads() const { return _totalQuads; } -int TextureAtlas::getCapacity() const +long TextureAtlas::getCapacity() const { return _capacity; } @@ -134,7 +137,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) { @@ -190,11 +193,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity) this->setupIndices(); -#if CC_TEXTURE_ATLAS_USE_VAO - setupVBOandVAO(); -#else - setupVBO(); -#endif + if (Configuration::getInstance()->supportsShareableVAO()) + { + setupVBOandVAO(); + } + else + { + setupVBO(); + } _dirty = true; @@ -203,11 +209,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long 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; @@ -215,7 +224,7 @@ void TextureAtlas::listenBackToForeground(Object *obj) const char* TextureAtlas::description() const { - return String::createWithFormat("", _totalQuads)->getCString(); + return String::createWithFormat("", _totalQuads)->getCString(); } @@ -248,7 +257,6 @@ void TextureAtlas::setupIndices() //TextureAtlas - VAO / VBO specific -#if CC_TEXTURE_ATLAS_USE_VAO void TextureAtlas::setupVBOandVAO() { glGenVertexArrays(1, &_VAOname); @@ -283,14 +291,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() { @@ -356,7 +363,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) @@ -366,9 +373,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++; @@ -389,9 +396,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; @@ -411,7 +418,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 ) @@ -430,7 +437,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; @@ -455,7 +462,7 @@ bool TextureAtlas::resizeCapacity(long newCapacity) { return true; } - int oldCapactiy = _capacity; + long oldCapactiy = _capacity; // update capacity and totolQuads _totalQuads = MIN(_totalQuads, newCapacity); _capacity = newCapacity; @@ -574,8 +581,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; } @@ -603,90 +610,89 @@ void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start) GL::bindTexture2D(_texture->getName()); -#if CC_TEXTURE_ATLAS_USE_VAO - - // - // Using VBO and VAO - // - - // XXX: update is done in draw... perhaps it should be done in a timer - if (_dirty) + if (Configuration::getInstance()->supportsShareableVAO()) { - 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); + // + // Using VBO and VAO + // - _dirty = false; - } + // 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); - GL::bindVAO(_VAOname); + _dirty = false; + } + + 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/cocos/2d/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h index 1e5ec742d7..86f0ba209f 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; @@ -217,23 +217,18 @@ 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 */ - 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 8f3fc6fe3a..15b30ccb6a 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -51,19 +51,9 @@ NS_CC_BEGIN // implementation TextureCache -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() @@ -73,7 +63,6 @@ TextureCache::TextureCache() , _needQuit(false) , _asyncRefCount(0) { - CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton."); } TextureCache::~TextureCache() @@ -84,20 +73,19 @@ TextureCache::~TextureCache() (it->second)->release(); CC_SAFE_DELETE(_loadingThread); - _sharedTextureCache = nullptr; } 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); - } +} + +TextureCache * TextureCache::sharedTextureCache() +{ + return Director::getInstance()->getTextureCache(); +} + +void TextureCache::purgeSharedTextureCache() +{ } const char* TextureCache::description() const @@ -260,7 +248,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) ); @@ -320,7 +308,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) ); @@ -370,7 +358,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; @@ -438,9 +426,18 @@ Texture2D* TextureCache::getTextureForKey(const std::string &key) const void TextureCache::reloadAllTextures() { -#if CC_ENABLE_CACHE_TEXTURE_DATA - VolatileTexture::reloadAllTextures(); -#endif +//will do nothing +// #if CC_ENABLE_CACHE_TEXTURE_DATA +// VolatileTextureMgr::reloadAllTextures(); +// #endif +} + +void TextureCache::waitForQuit() +{ + // notify sub thread to quick + _needQuit = true; + _sleepCondition.notify_one(); + if (_loadingThread) _loadingThread->join(); } void TextureCache::dumpCachedTextureInfo() const @@ -453,7 +450,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", @@ -471,8 +468,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) @@ -487,16 +484,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) { @@ -505,20 +500,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(); @@ -535,12 +530,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) { @@ -549,14 +545,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) { @@ -565,12 +561,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); @@ -584,7 +580,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()) @@ -592,13 +588,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; @@ -611,7 +608,7 @@ void VolatileTexture::reloadAllTextures() switch (vt->_cashedImageType) { - case kImageFile: + case VolatileTexture::kImageFile: { Image* image = new Image(); long size = 0; @@ -625,11 +622,11 @@ void VolatileTexture::reloadAllTextures() Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); } - CC_SAFE_DELETE_ARRAY(pBuffer); + free(pBuffer); CC_SAFE_RELEASE(image); } break; - case kImageData: + case VolatileTexture::kImageData: { vt->_texture->initWithData(vt->_textureData, vt->_dataLen, @@ -639,12 +636,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 ec87d891d8..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 @@ -59,23 +63,24 @@ 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(); } + CC_DEPRECATED_ATTRIBUTE static TextureCache * sharedTextureCache(); /** 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(); } + CC_DEPRECATED_ATTRIBUTE static void purgeSharedTextureCache(); /** 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: /** @@ -158,6 +163,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(); @@ -196,8 +205,6 @@ protected: int _asyncRefCount; std::unordered_map _textures; - - static TextureCache *_sharedTextureCache; }; #if CC_ENABLE_CACHE_TEXTURE_DATA @@ -212,7 +219,7 @@ class VolatileTexture kImage, }ccCachedImageType; -public: +private: VolatileTexture(Texture2D *t); /** * @js NA @@ -220,25 +227,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; @@ -257,6 +247,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 diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 3bde055c59..e291bcd84e 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -32,6 +32,9 @@ THE SOFTWARE. NS_CC_BEGIN +float TransitionPageTurn::POLYGON_OFFSET_FACTOR = -20.f; +float TransitionPageTurn::POLYGON_OFFSET_UNITS = -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(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(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); + _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..3f0eca219d 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 POLYGON_OFFSET_FACTOR; + static float POLYGON_OFFSET_UNITS; }; // end of transition group diff --git a/cocos/2d/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp index 2104051f76..1d40acf461 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() @@ -479,7 +480,7 @@ bool UserDefault::createXMLFile() { return false; } - tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration("1.0"); + tinyxml2::XMLDeclaration *pDeclaration = pDoc->NewDeclaration(nullptr); if (NULL==pDeclaration) { return false; 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 38c09c2a90..8f6895f572 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; + char* pXmlBuffer = (char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size); //const char* pXmlBuffer = (const char*)data.getBuffer(); if(NULL == pXmlBuffer) { @@ -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/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/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..26681d7bca 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,18 +309,21 @@ 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)) + if (static_cast(len) < sizeof(struct CCZHeader)) { return false; } @@ -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..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,7 +65,8 @@ namespace cocos2d * @since v0.8.1 */ - static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out); + 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); /** * Inflates either zlib or gzip deflated memory. The inflated memory is @@ -76,7 +78,8 @@ namespace cocos2d * @since v1.0.0 */ - static int ccInflateMemoryWithHint(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,7 +87,8 @@ namespace cocos2d * * @since v0.99.5 */ - static int ccInflateGZipFile(const char *filename, unsigned char **out); + 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,7 +96,8 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsGZipFile(const char *filename); + 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,7 +105,8 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsGZipBuffer(const unsigned char *buffer, long len); + 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,7 +114,8 @@ namespace cocos2d * * @since v0.99.5 */ - static int ccInflateCCZFile(const char *filename, unsigned char **out); + 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,7 +123,8 @@ namespace cocos2d * * @since v3.0 */ - static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out); + 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,7 +132,8 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsCCZFile(const char *filename); + 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,7 +141,8 @@ namespace cocos2d * * @since v3.0 */ - static bool ccIsCCZBuffer(const unsigned char *buffer, long len); + 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 * security. @@ -141,10 +151,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 +162,16 @@ 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); + 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. * @@ -168,14 +179,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 +195,13 @@ 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); + 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: - 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 +260,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/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index 0e8054bd40..c4de9784b8 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/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,20 @@ 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/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; diff --git a/cocos/2d/platform/CCEGLViewProtocol.cpp b/cocos/2d/platform/CCEGLViewProtocol.cpp index 0296eb5a17..ebeba6b203 100644 --- a/cocos/2d/platform/CCEGLViewProtocol.cpp +++ b/cocos/2d/platform/CCEGLViewProtocol.cpp @@ -354,8 +354,8 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode for (auto& touch : touchEvent._touches) { - // delete the touch object. - delete touch; + // release the touch object. + touch->release(); } } 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..33906b16f8 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) { } @@ -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; } @@ -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 { @@ -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; } @@ -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) 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/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/CCEGLView.cpp b/cocos/2d/platform/android/CCEGLView.cpp index 0347d70a87..c22babd3c1 100644 --- a/cocos/2d/platform/android/CCEGLView.cpp +++ b/cocos/2d/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/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index d15e4f874a..af910cfe71 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; } @@ -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/"); @@ -189,14 +179,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 = (unsigned char*) malloc(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 +197,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 = (unsigned char*) malloc(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/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/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index 12e25d597d..e92d9e5b78 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; @@ -127,7 +131,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(); } @@ -558,6 +562,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 @@ -586,6 +595,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) { @@ -673,5 +685,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/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/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/EAGLView.mm b/cocos/2d/platform/ios/EAGLView.mm index 5536a63752..f16f399b7d 100644 --- a/cocos/2d/platform/ios/EAGLView.mm +++ b/cocos/2d/platform/ios/EAGLView.mm @@ -237,8 +237,11 @@ static CCEAGLView *__view = 0; context_ = [renderer_ context]; - - //discardFramebufferSupported_ = [[Configuration sharedConfiguration] supportsDiscardFramebuffer]; + #if GL_EXT_discard_framebuffer == 1 + discardFramebufferSupported_ = YES; + #else + discardFramebufferSupported_ = NO; + #endif CHECK_GL_ERROR(); @@ -288,7 +291,7 @@ static CCEAGLView *__view = 0; glResolveMultisampleFramebufferAPPLE(); } - if( discardFramebufferSupported_) + if(discardFramebufferSupported_) { if (multiSampling_) { 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/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; } 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/2d/platform/mac/EAGLView.h b/cocos/2d/platform/mac/EAGLView.h old mode 100755 new mode 100644 diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index a5c94dac90..a417f34fa1 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."); @@ -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); 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/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/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/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 deleted file mode 100755 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 100755 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/base/CCGeometry.cpp b/cocos/base/CCGeometry.cpp index 8ab9e39dda..fe5086cba9 100644 --- a/cocos/base/CCGeometry.cpp +++ b/cocos/base/CCGeometry.cpp @@ -293,7 +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::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 diff --git a/cocos/base/CCGeometry.h b/cocos/base/CCGeometry.h index 3b6b8c2655..f1a080fdc5 100644 --- a/cocos/base/CCGeometry.h +++ b/cocos/base/CCGeometry.h @@ -433,7 +433,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/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/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..bf566770fe 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); @@ -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_BIG_TO_HOST(magicBytes) != (*reinterpret_cast("ccbi"))) { return false; } @@ -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(); @@ -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..bf4bd84106 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; } @@ -577,7 +581,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 +639,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 { @@ -926,7 +930,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/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 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/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/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 49aa8e1c6f..4f8b22f17c 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) @@ -70,8 +71,7 @@ ArmatureAnimation::~ArmatureAnimation(void) CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); - CC_SAFE_RELEASE_NULL(_movementEventTarget); - CC_SAFE_RELEASE_NULL(_frameEventTarget); + CC_SAFE_RELEASE_NULL(_userObject); } bool ArmatureAnimation::init(Armature *armature) @@ -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) @@ -423,26 +423,23 @@ 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; } +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..040c316672 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. * @@ -202,6 +203,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 +272,8 @@ protected: bool _ignoreFrameEvent; std::queue _frameEventQueue; + + cocos2d::Object *_userObject; protected: /** * MovementEvent CallFunc. diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 4d67c41e2e..8a603c1ad3 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -112,6 +112,7 @@ public: */ Bone *getParentBone(); + using Node::removeFromParent; /** * Remove itself from its parent. * @param recursion whether or not to remove childBone's display 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/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index f3e57eddbc..c0c590af58 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(nullptr) { _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; } @@ -66,123 +61,46 @@ ComAttribute* ComAttribute::create(void) 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); + _jsonDict->insertItem(key, value); } void ComAttribute::setFloat(const char *key, float value) { CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Float::create(value), key); + _jsonDict->insertItem(key, value); } void ComAttribute::setBool(const char *key, bool value) { CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(Bool::create(value), key); + _jsonDict->insertItem(key, value); } void ComAttribute::setCString(const char *key, const char *value) { CCASSERT(key != NULL, "Argument must be non-nil"); - _attributes->setObject(String::create(value), key); + _jsonDict->insertItem(key, value); } -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; + return _jsonDict->getItemIntValue(key, -1); } 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; + return _jsonDict->getItemFloatValue(key, -1.0f); } 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; + return _jsonDict->getItemBoolvalue(key, 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); + return _jsonDict->getItemStringValue(key); } JsonDictionary* ComAttribute::getDict() const diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index 53c7c2c885..dea396c121 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -47,24 +47,20 @@ 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/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/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index defb268ada..27b0a70bb8 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) { } @@ -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) @@ -579,8 +582,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); @@ -595,10 +597,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 +825,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov } int length = 0; - int i = 0; + int index = 0; int parentTotalDuration = 0; int currentDuration = 0; @@ -864,13 +866,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++; } } @@ -888,21 +889,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/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/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index a8c8f5d760..3c502f2fe7 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->getObjectAtIndex(i)); + SpriteDisplayData *sdd = static_cast(dd->getDisplayData()); + if (sdd) + { + find = true; + skin->setSkinData(sdd->skinData); + static_cast(displayData)->skinData = sdd->skinData; + break; + } + } + + if (!find) + { + BaseData baseData; + skin->setSkinData(baseData); + } } } else if (dynamic_cast(display)) 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/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/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp old mode 100755 new mode 100644 index de644e6ec6..cbfe527b68 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -34,35 +34,36 @@ namespace cocostudio { -static CCSGUIReader* sharedReader = NULL; +static GUIReader* sharedReader = nullptr; -CCSGUIReader::CCSGUIReader(): -m_strFilePath(""), -m_bOlderVersion(false) +GUIReader::GUIReader(): +m_strFilePath("") { - + _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; @@ -97,11 +98,132 @@ int CCSGUIReader::getVersionInteger(const char *str) /************************/ } -UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) +void GUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) { - UIWidget* widget = NULL; - const char* classname = DICTOOL->getStringValue_json(data, "classname"); - JsonDictionary* uiOptions = DICTOOL->getSubDictionary_json(data, "options"); + 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; + char *des = nullptr; + std::string jsonpath; + 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(nullptr == des || strcmp(des, "") == 0) + { + printf("read json file[%s] error!\n", fileName); + return nullptr; + } + std::string strDes(des); + jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(strDes.c_str()); + + UIWidget* widget = nullptr; + const char* fileVersion = dicHelper->getStringValue_json(jsonDict, "version"); + WidgetPropertiesReader * pReader = nullptr; + 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); + free(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 = nullptr; + const char* classname = dicHelper->getStringValue_json(data, "classname"); + JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) { widget = UIButton::create(); @@ -133,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) { @@ -153,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():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) + { + 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():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) + { + 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 = nullptr; + 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 = nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():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); + } + 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():nullptr; + 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():nullptr; + 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 = nullptr; + 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 = nullptr; + 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(); @@ -170,1371 +1021,518 @@ 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); + UILayout* layout = dynamic_cast(widget); + if (layout) + { + layout->doLayout(); + } + + CC_SAFE_DELETE(uiOptions); return widget; } - - -UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) +void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) { - 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(); -// CCUIHELPER->setFileDesignWidth(winSize.width); -// CCUIHELPER->setFileDesignHeight(winSize.height); - } - else - { -// CCUIHELPER->setFileDesignWidth(fileDesignWidth); -// CCUIHELPER->setFileDesignHeight(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"); + 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)); - 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); + + JsonDictionary* layoutParameterDic = dicHelper->getSubDictionary_json(options, "layoutParameter"); + if (layoutParameterDic) + { + int paramType = dicHelper->getIntValue_json(layoutParameterDic, "type"); + UILayoutParameter* parameter = nullptr; + 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); + } + CC_SAFE_DELETE(layoutParameterDic); } -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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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 = nullptr; + 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: @@ -1544,28 +1542,407 @@ 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():nullptr; + 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)); + } + panel->setLayoutType((LayoutType)dicHelper->getIntValue_json(options, "layoutType")); + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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():nullptr; + 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 = nullptr; + 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 old mode 100755 new mode 100644 index d39c349ee0..19a37292fd --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -31,45 +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/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index f26b337d6a..385c147e27 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -30,46 +30,48 @@ using namespace gui; namespace cocostudio { - SceneReader* SceneReader::s_sharedReader = NULL; + 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 = 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); + 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) { - Node* gb = NULL; - if(NULL == parenet) + Node* gb = nullptr; + if(nullptr == parenet) { gb = Node::create(); } @@ -86,95 +88,95 @@ 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 != NULL) { - const char *file = fileData->getItemStringValue("path"); - nResType = fileData->getItemIntValue("resourceType", -1); - const char *plistFile = fileData->getItemStringValue("plistFile"); - if (file != NULL) - { - 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 != NULL) - { - 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 != NULL && strcmp(comName, "CCSprite") == 0) + if (comName != nullptr && strcmp(comName, "CCSprite") == 0) { - cocos2d::Sprite *pSprite = NULL; + 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 != 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; - 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 != 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,153 +184,154 @@ namespace cocostudio { continue; } - cocos2d::ParticleSystemQuad *pParticle = NULL; - 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 != 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) - { - 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(NULL == 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 i = 0; i < childrenCount; ++i) - { - const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i); - 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 != NULL) - { - 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 != NULL && pAr->getAnimation() != NULL) - { - 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 != NULL && strcmp(comName, "CCComAudio") == 0) + else if(comName != nullptr && strcmp(comName, "CCComAudio") == 0) { - ComAudio *pAudio = NULL; - 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 != NULL && strcmp(comName, "CCComAttribute") == 0) + else if(comName != nullptr && strcmp(comName, "CCComAttribute") == 0) { - ComAttribute *pAttribute = NULL; - 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) - { - pAttribute->getDict()->initWithDescription(pData); - } - } - else - { - CCLOG("unknown resourcetype on CCComAttribute!"); - continue; - } + ComAttribute *pAttribute = nullptr; + 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 != NULL && strcmp(comName, "CCBackgroundAudio") == 0) + else if (comName != nullptr && strcmp(comName, "CCBackgroundAudio") == 0) { - ComAudio *pAudio = NULL; - 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 != NULL && strcmp(comName, "GUIComponent") == 0) - { + else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0) + { gui::UILayer *pLayer = gui::UILayer::create(); - pLayer->scheduleUpdate(); -// UIWidget* widget= gui::UIHelper::instance()->createWidgetFromJsonFile(pPath.c_str()); -// pLayer->addWidget(widget); - ComRender *pRender = ComRender::create(pLayer, "GUIComponent"); - if (pComName != NULL) - { - 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); } @@ -347,47 +350,47 @@ namespace cocostudio { return gb; } - return NULL; + return nullptr; } 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 == NULL) - { - 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(); } } 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/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 * 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/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/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); } 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/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/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/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) { 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/editor-support/spine/SkeletonJson.cpp b/cocos/editor-support/spine/SkeletonJson.cpp index 98e4be4334..6c1e039b10 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; @@ -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/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; 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/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index 43d6b27ecf..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 @@ -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..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,15 +164,15 @@ 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 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); @@ -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.cpp b/cocos/gui/UICheckBox.cpp index a826fa40ef..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), -_selectedStateEventListener(NULL), -_selectedStateEventSelector(NULL), +_checkBoxEventListener(nullptr), +_checkBoxEventSelector(nullptr), _backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL), @@ -51,7 +51,8 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - + _checkBoxEventListener = nullptr; + _checkBoxEventSelector = nullptr; } UICheckBox* UICheckBox::create() @@ -63,7 +64,7 @@ UICheckBox* UICheckBox::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UICheckBox::init() @@ -284,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..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 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); + 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; @@ -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/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/UIHelper.h b/cocos/gui/UIHelper.h index 75ccba81eb..838875adf4 100644 --- a/cocos/gui/UIHelper.h +++ b/cocos/gui/UIHelper.h @@ -72,7 +72,6 @@ public: /*temp action*/ static UIWidget* seekActionWidgetByActionTag(UIWidget* root, int tag); }; - } #endif /* defined(__CocoGUI__UISystem__) */ 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/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/UIInputManager.cpp b/cocos/gui/UIInputManager.cpp index bb36043855..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(); @@ -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/UILabel.cpp b/cocos/gui/UILabel.cpp index 4c8779c9eb..44fde58cd8 100644 --- a/cocos/gui/UILabel.cpp +++ b/cocos/gui/UILabel.cpp @@ -29,11 +29,12 @@ namespace gui { UILabel::UILabel(): _touchScaleChangeEnabled(false), -_normalScaleValue(1.0f), +_normalScaleValueX(1.0f), +_normalScaleValueY(1.0f), _fontName("Thonburi"), _fontSize(10), _onSelectedScaleOffset(0.5), -_labelRenderer(NULL) +_labelRenderer(nullptr) { } @@ -51,7 +52,7 @@ UILabel* UILabel::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UILabel::init() @@ -70,26 +71,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 +97,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); @@ -127,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() @@ -141,7 +158,7 @@ void UILabel::onPressStateChangedToNormal() { return; } - clickScale(_normalScaleValue); + clickScale(_normalScaleValueX, _normalScaleValueY); } void UILabel::onPressStateChangedToPressed() @@ -150,7 +167,7 @@ void UILabel::onPressStateChangedToPressed() { return; } - clickScale(_normalScaleValue + _onSelectedScaleOffset); + clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset); } void UILabel::onPressStateChangedToDisabled() @@ -158,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 5c6a4a105b..58e6d11a7a 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. @@ -100,50 +100,79 @@ 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) override; + + /** + * 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) override; + + /** + * 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; + //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(); - void clickScale(float scale); + 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 _normalScaleValue; + float _normalScaleValueX; + float _normalScaleValueY; std::string _fontName; int _fontSize; float _onSelectedScaleOffset; diff --git a/cocos/gui/UILabelAtlas.cpp b/cocos/gui/UILabelAtlas.cpp index 8e8db6c422..8a3bcc2677 100644 --- a/cocos/gui/UILabelAtlas.cpp +++ b/cocos/gui/UILabelAtlas.cpp @@ -47,15 +47,15 @@ UICCLabelAtlas* UICCLabelAtlas::create() } CC_SAFE_DELETE(pRet); - return NULL; + return nullptr; } -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); } @@ -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() @@ -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..1db648884f 100644 --- a/cocos/gui/UILabelAtlas.h +++ b/cocos/gui/UILabelAtlas.h @@ -50,10 +50,10 @@ 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); - virtual void updateDisplayedOpacity(GLubyte opacity); - virtual void draw(void); + 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) override; + virtual void draw(void) override; }; /** * @js NA @@ -78,34 +78,34 @@ 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); + 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.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/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.cpp b/cocos/gui/UILayer.cpp index a935f9efc5..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) { } @@ -48,7 +48,6 @@ bool UILayer::init() { _rootWidget = UIRootWidget::create(); _rootWidget->retain(); - _rootWidget->onEnter(); addChild(_rootWidget->getRenderer()); _inputManager = new UIInputManager(); _inputManager->setRootWidget(_rootWidget); @@ -68,7 +67,7 @@ UILayer* UILayer::create(void) else { CC_SAFE_DELETE(pRet); - return NULL; + return nullptr; } } @@ -85,10 +84,12 @@ void UILayer::onEnter() listener->onTouchCancelled = CC_CALLBACK_2(UILayer::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + _rootWidget->onEnter(); } void UILayer::onExit() { + _rootWidget->onExit(); CCLayer::onExit(); } @@ -117,7 +118,7 @@ UIWidget* UILayer::getWidgetByTag(int tag) { if (!_rootWidget) { - return NULL; + return nullptr; } return UIHelper::seekWidgetByTag(_rootWidget, tag); } @@ -126,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/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.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..c7c48dfb24 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() @@ -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)); @@ -155,7 +165,7 @@ void UILayout::setBackGroundImageScale9Enabled(bool able) return; } _renderer->removeChild(_backGroundImage, true); - _backGroundImage = NULL; + _backGroundImage = nullptr; _backGroundScale9Enabled = able; if (_backGroundScale9Enabled) { @@ -178,7 +188,7 @@ void UILayout::setBackGroundImage(const char* fileName,TextureResType texType) { return; } - if (_backGroundImage == NULL) + if (_backGroundImage == nullptr) { addBackGroundImage(); } @@ -295,7 +305,7 @@ void UILayout::removeBackGroundImage() return; } _renderer->removeChild(_backGroundImage, true); - _backGroundImage = NULL; + _backGroundImage = nullptr; _backGroundImageFileName = ""; _backGroundImageTextureSize = cocos2d::Size::ZERO; } @@ -312,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: @@ -586,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, "")) @@ -803,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) @@ -843,28 +853,129 @@ void UILayout::doLayout() break; case RELATIVE_LOCATION_ABOVE_LEFTALIGN: - case RELATIVE_LOCATION_ABOVE_CENTER: + finalPosY += mg.bottom; + 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; + 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: - case RELATIVE_LOCATION_LEFT_OF_CENTER: + finalPosX -= mg.right; + 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; + 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: - case RELATIVE_LOCATION_RIGHT_OF_CENTER: + finalPosX += mg.left; + 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; + 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: - case RELATIVE_LOCATION_BELOW_CENTER: + finalPosY -= mg.top; + 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; + 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; @@ -917,7 +1028,7 @@ void UILayout::copySpecialProperties(UIWidget *widget) } UIRectClippingNode::UIRectClippingNode(): -_innerStencil(NULL), +_innerStencil(nullptr), _enabled(true), _clippingSize(cocos2d::Size(50.0f, 50.0f)), _clippingEnabled(false) @@ -953,7 +1064,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 +1082,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); } 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/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 { /** 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 81baaad41d..8e45662c3e 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -29,10 +29,13 @@ namespace gui { UIListView::UIListView(): -_model(NULL), -_items(NULL), +_model(nullptr), +_items(nullptr), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), -_itemsMargin(0.0f) +_itemsMargin(0.0f), +_listViewEventListener(nullptr), +_listViewEventSelector(nullptr), +_curSelectedIndex(0) { } @@ -41,6 +44,8 @@ UIListView::~UIListView() { _items->removeAllObjects(); CC_SAFE_RELEASE(_items); + _listViewEventListener = nullptr; + _listViewEventSelector = nullptr; } UIListView* UIListView::create() @@ -52,7 +57,7 @@ UIListView* UIListView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIListView::init() @@ -298,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]); } @@ -376,7 +381,44 @@ void UIListView::refreshView() remedyLayoutParameter(item); } 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_ONSELECTEDITEM); + } +} + +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..14b91806b8 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_ONSELECTEDITEM +}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. * @@ -152,24 +164,33 @@ 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) override; protected: UIWidget* _model; cocos2d::Array* _items; ListViewGravity _gravity; float _itemsMargin; + cocos2d::Object* _listViewEventListener; + SEL_ListViewEvent _listViewEventSelector; + int _curSelectedIndex; }; } 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/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.cpp b/cocos/gui/UIPageView.cpp index 8498e79d88..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), -_eventListener(NULL), -_eventSelector(NULL) +_pageViewEventListener(nullptr), +_pageViewEventSelector(nullptr) { } @@ -51,6 +51,8 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); + _pageViewEventListener = nullptr; + _pageViewEventSelector = nullptr; } UIPageView* UIPageView::create() @@ -62,7 +64,7 @@ UIPageView* UIPageView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIPageView::init() @@ -217,13 +219,18 @@ void UIPageView::removePageAtIndex(int index) removePage(page); } } + +void UIPageView::removeAllPages() +{ + removeAllChildren(); +} void UIPageView::updateBoundaryPages() { if (_pages->count() <= 0) { - _leftChild = NULL; - _rightChild = NULL; + _leftChild = nullptr; + _rightChild = nullptr; return; } _leftChild = dynamic_cast(_pages->getObjectAtIndex(0)); @@ -245,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() @@ -563,16 +569,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 @@ -584,6 +590,15 @@ cocos2d::Array* UIPageView::getPages() { return _pages; } + +UILayout* UIPageView::getPage(int index) +{ + if (index < 0 || index >= (int)(_pages->count())) + { + return nullptr; + } + return (UILayout*)_pages->getObjectAtIndex(index); +} const char* UIPageView::getDescription() const { diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index ec78df8bbd..99ae26deb6 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,59 +119,78 @@ public: cocos2d::Array* getPages(); + UILayout* getPage(int index); + // event - void addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector); + 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); + 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. + * + * @see LayoutType + * + * @param LayoutType + */ + virtual void setLayoutType(LayoutType type) override{}; + + /** + * Gets LayoutType. + * + * @see LayoutType + * + * @return LayoutType + */ + 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 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; @@ -186,8 +207,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/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/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.cpp b/cocos/gui/UIScrollView.cpp index 1270c78682..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,14 +69,15 @@ _bouncing(false), _bounceDir(cocos2d::Point::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), -_eventListener(NULL), -_eventSelector(NULL) +_scrollViewEventListener(nullptr), +_scrollViewEventSelector(nullptr) { } UIScrollView::~UIScrollView() { - + _scrollViewEventListener = nullptr; + _scrollViewEventSelector = nullptr; } UIScrollView* UIScrollView::create() @@ -88,7 +89,7 @@ UIScrollView* UIScrollView::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIScrollView::init() @@ -1457,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..09fc21a7a8 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -231,36 +231,36 @@ 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); + 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; @@ -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 f3c0a90b97..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), -_slidPercentListener(NULL), -_slidPercentSelector(NULL), +_sliderEventListener(nullptr), +_sliderEventSelector(nullptr), _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), @@ -58,7 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - + _sliderEventListener = nullptr; + _sliderEventSelector = nullptr; } UISlider* UISlider::create() @@ -70,7 +71,7 @@ UISlider* UISlider::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } void UISlider::initRenderer() @@ -197,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(); @@ -410,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..d4c09c5fdf 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -162,46 +162,46 @@ 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); + 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; @@ -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 7eb30518cd..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() @@ -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) { @@ -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()); } } } @@ -271,18 +271,20 @@ bool UICCTextField::getDeleteBackward() UITextField::UITextField(): -_textFieldRenderer(NULL), +_textFieldRenderer(nullptr), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), -_eventListener(NULL), -_eventSelector(NULL), +_textFieldEventListener(nullptr), +_textFieldEventSelector(nullptr), _passwordStyleText("") { } UITextField::~UITextField() { + _textFieldEventListener = nullptr; + _textFieldEventSelector = nullptr; } UITextField* UITextField::create() @@ -294,7 +296,7 @@ UITextField* UITextField::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UITextField::init() @@ -321,18 +323,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 +344,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 +355,7 @@ void UITextField::didNotSelectSelf() _textFieldRenderer->detachWithIME(); } -const char* UITextField::getStringValue() +const std::string& UITextField::getStringValue() { return _textFieldRenderer->getString(); } @@ -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 ac5641114f..23ee0bcb6b 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -106,16 +106,16 @@ 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 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(); - virtual bool onTouchBegan(const cocos2d::Point &touchPoint); + const std::string& getStringValue(); + 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(); @@ -132,19 +132,19 @@ 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); - 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; @@ -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/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 00ee50680c..e87aa50a72 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -44,42 +44,50 @@ _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) +_isRunning(false), +_userObject(nullptr) { } UIWidget::~UIWidget() { - releaseResoures(); - setParent(NULL); + _touchEventListener = nullptr; + _touchEventSelector = nullptr; + removeAllChildren(); + _children->release(); + _renderer->removeAllChildrenWithCleanup(true); + _renderer->removeFromParentAndCleanup(true); + _renderer->release(); + setParent(nullptr); _layoutParameterDictionary->removeAllObjects(); CC_SAFE_RELEASE(_layoutParameterDictionary); CC_SAFE_RELEASE(_scheduler); + CC_SAFE_RELEASE(_userObject); } UIWidget* UIWidget::create() @@ -91,7 +99,7 @@ UIWidget* UIWidget::create() return widget; } CC_SAFE_DELETE(widget); - return NULL; + return nullptr; } bool UIWidget::init() @@ -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*); @@ -137,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) { @@ -204,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; @@ -326,21 +332,33 @@ void UIWidget::setSize(const cocos2d::Size &size) { _size = size; } - if (_isRunning) + if (_isRunning && _widgetParent) { - _sizePercent = (_widgetParent == NULL) ? 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(); } void UIWidget::setSizePercent(const cocos2d::Point &percent) { _sizePercent = percent; - if (!_isRunning) + cocos2d::Size cSize = _customSize; + if (_isRunning) { - return; + cSize = (_widgetParent == nullptr) ? 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(); @@ -358,6 +376,7 @@ void UIWidget::updateSizeAndPosition() switch (_sizeType) { case SIZE_ABSOLUTE: + { if (_ignoreSize) { _size = getContentSize(); @@ -366,8 +385,23 @@ void UIWidget::updateSizeAndPosition() { _size = _customSize; } - _sizePercent = (_widgetParent == NULL) ? 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 == NULL) ? cocos2d::Size::ZERO : cocos2d::Size(_widgetParent->getSize().width * _sizePercent.x , _widgetParent->getSize().height * _sizePercent.y); @@ -390,14 +424,38 @@ 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); + { + 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; } @@ -734,7 +792,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); @@ -782,9 +840,17 @@ void UIWidget::checkChildInfo(int handleState, UIWidget *sender, const cocos2d:: void UIWidget::setPosition(const cocos2d::Point &pos) { - if (_isRunning) + if (_isRunning && _widgetParent) { - _positionPercent = (_widgetParent == NULL) ? 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 / pSize.width, pos.y / pSize.height); + } } _renderer->setPosition(pos); } @@ -792,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); @@ -1109,6 +1175,10 @@ WidgetType UIWidget::getWidgetType() const void UIWidget::setLayoutParameter(UILayoutParameter *parameter) { + if (!parameter) + { + return; + } _layoutParameterDictionary->setObject(parameter, parameter->getLayoutType()); } diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index d8f35578f4..741d580fee 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -880,6 +880,27 @@ public: virtual void onEnter(); virtual void onExit(); + + void updateSizeAndPosition(); + + 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(); @@ -907,13 +928,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(); virtual void copySpecialProperties(UIWidget* model); @@ -958,6 +972,7 @@ protected: PositionType _positionType; cocos2d::Point _positionPercent; bool _isRunning; + cocos2d::Object* _userObject; }; /** * @js NA 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 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/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/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index bcf43ed902..e41b04fc2e 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; } 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/auto-generated b/cocos/scripting/auto-generated index 52e968dfe0..e76bd3683f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 52e968dfe02f077f56d4df6cc04e38c8b76e22b9 +Subproject commit e76bd3683fd785d1b23d59d153641a7f5ae6e583 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 580a3b845e..0f7fca11f4 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -60,14 +60,15 @@ 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); 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; @@ -246,7 +247,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); @@ -377,7 +378,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; @@ -535,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 @@ -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) @@ -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; @@ -1164,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)); - } - 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) @@ -2302,240 +1500,58 @@ void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) JS_REMOVE_PROXY(nativeProxy, jsProxy); } -static Color3B getColorFromJSObject(JSContext *cx, JSObject *colorObject) +// JSStringWrapper +JSStringWrapper::JSStringWrapper() +: _buffer(nullptr) { - 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) +JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) +: _buffer(nullptr) { - 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; + set(str, cx); } -JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) +JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) +: _buffer(nullptr) { - 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); - if ( wrapper ) - { - out->_fontName = (char*)wrapper; - } - 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; + set(val, cx); } + +JSStringWrapper::~JSStringWrapper() +{ + CC_SAFE_DELETE_ARRAY(_buffer); +} + +void JSStringWrapper::set(jsval val, JSContext* cx) +{ + if (val.isString()) + { + this->set(val.toString(), cx); + } + else + { + CC_SAFE_DELETE_ARRAY(_buffer); + } +} + +void JSStringWrapper::set(JSString* str, JSContext* cx) +{ + CC_SAFE_DELETE_ARRAY(_buffer); + + 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..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,98 +205,25 @@ 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 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. */ + 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/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.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/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/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index bc82fe5227..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 @@ -927efea93a520eeb9db9f62c8d8eb7a7b93b08dc \ No newline at end of file +5bc5339bd77792b57c97cebbe7dfd3b634038e38 \ 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..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; } /** @@ -101,19 +110,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/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_bindings_core.cpp b/cocos/scripting/javascript/bindings/js_bindings_core.cpp index fbb6e808fb..19d63c30e3 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) { @@ -68,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; @@ -88,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); @@ -107,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; @@ -123,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/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 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/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index 521d1be2aa..411ce359ec 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.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); + } + 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.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); + } + 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.b), 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/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); 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 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!! 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"); 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/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index dfbf607e84..85f491032b 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, "Armature"); + _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, "Bone"); + _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, 1); + } + 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/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index a0269bf318..7d0357d78b 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) @@ -102,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(); @@ -140,6 +149,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/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/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/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 1914d3a930..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) @@ -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..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); @@ -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/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h index 2f8a769cc3..3d0acfc87e 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, + ARMATURE_EVENT, }; typedef int Handler; 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/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 new file mode 100644 index 0000000000..71e1e59a93 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -0,0 +1,916 @@ +#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" +#include "CocoStudio.h" + +using namespace gui; +using namespace cocostudio; + +class LuaCocoStudioEventListener:public Object +{ +public: + LuaCocoStudioEventListener(); + virtual ~LuaCocoStudioEventListener(); + + static LuaCocoStudioEventListener* create(); + + virtual void eventCallbackFunc(Object* sender,int eventType); +}; + +LuaCocoStudioEventListener::LuaCocoStudioEventListener() +{ + +} + +LuaCocoStudioEventListener::~LuaCocoStudioEventListener() +{ + +} + +LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() +{ + LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); + if (nullptr == listener) + return nullptr; + + listener->autorelease(); + + return listener; +} + +void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + if (0 != handler) + { + LuaCocoStudioEventListenerData eventData(sender,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 + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + 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, 1); + 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_addEventListenerCheckBox(lua_State* L) +{ + if (nullptr == 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_addEventListenerCheckBox'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + 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 'addEventListenerCheckBox'.",&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, "addEventListenerCheckBox", lua_cocos2dx_UICheckBox_addEventListenerCheckBox); + } +} + +static int lua_cocos2dx_UISlider_addEventListenerSlider(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_addEventListenerSlider'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + 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 'addEventListenerSlider'.",&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, "addEventListenerSlider", lua_cocos2dx_UISlider_addEventListenerSlider); + } +} + +static int lua_cocos2dx_UITextField_addEventListenerTextField(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_addEventListenerTextField'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + 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 'addEventListenerTextField'.",&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, "addEventListenerTextField", lua_cocos2dx_UITextField_addEventListenerTextField); + } +} + +static int lua_cocos2dx_UIPageView_addEventListenerPageView(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_addEventListenerPageView'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + 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 'addEventListenerPageView'.",&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, "addEventListenerPageView", lua_cocos2dx_UIPageView_addEventListenerPageView); + } +} + +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) +{ + 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, "UILayoutParameter"); + 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 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); +}; + +LuaArmatureWrapper::LuaArmatureWrapper() +{ + +} + +LuaArmatureWrapper::~LuaArmatureWrapper() +{ + +} + +void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strMovementID = movementID; + LuaArmatureMovementEventData movementData(armature,(int)type, strMovementID); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); + + BasicScriptData data(this,(void*)&wrapperData); + + 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 (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setUserObject(wrapper); + 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, 1); + + 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 (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setUserObject(wrapper); + 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); + 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 (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isstring(L, 2, 0, &tolua_err) || + !toluafix_isfunction(L,3,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + const char* configFilePath = tolua_tostring(L, 2, ""); + LUA_FUNCTION handler = ( toluafix_ref_function(L, 3, 0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->addArmatureFileInfoAsync(configFilePath, wrapper, schedule_selector(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback)); + + return 0; + } + 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) || + !toluafix_isfunction(L,5,"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, ""); + + LUA_FUNCTION handler = ( toluafix_ref_function(L,5,0)); + + LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); + wrapper->autorelease(); + + 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); + 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); + extendUITextField(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 new file mode 100644 index 0000000000..179f2a115b --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp @@ -0,0 +1,66 @@ +#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 + +#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/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index e74dbac377..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); } @@ -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); diff --git a/cocos/scripting/lua/bindings/tolua_fix.c b/cocos/scripting/lua/bindings/tolua_fix.c index 870db00d75..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)) @@ -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, LUA_REGISTRYINDEX); + lua_setfenv(L, -2); + ud = (void**)lua_touserdata(L, -1); lua_pop(L, 1); /* stack: mt ubox */ if (ud == NULL) @@ -137,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; @@ -154,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); } 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/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") diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua new file mode 100644 index 0000000000..001ebe7341 --- /dev/null +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -0,0 +1,182 @@ +ccs = ccs or {} + + +ccs.MovementEventType = { + START = 0, + COMPLETE = 1, + LOOP_COMPLETE = 2, +} + +ccs.BrightStyle = +{ + none = -1, + normal = 0, + highlight = 1, +} + +ccs.WidgetType = +{ + widget = 0, --control + container = 1, --container +} + +-- ccs.TextureResType = +-- { +-- "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, + both = 3, +} + +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, +} + +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/cocos/scripting/lua/script/json.lua b/cocos/scripting/lua/script/json.lua old mode 100755 new mode 100644 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..14fe782823 --- /dev/null +++ b/docs/CODING_STYLE.md.REMOVED.git-id @@ -0,0 +1 @@ +811c4efefbe80ac5bcc88d74e56cc093166dd64a \ No newline at end of file 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 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/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..0a7b9c8c4b 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. @@ -651,8 +692,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..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. */ @@ -237,6 +238,8 @@ private: class AssetsManagerDelegateProtocol { +public: + virtual ~AssetsManagerDelegateProtocol(){}; public: /* @brief Call back function for error @param errorCode Type of error 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 -} 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/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/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/Classes/AccelerometerTest/AccelerometerTest.cpp b/samples/Cpp/TestCpp/Classes/AccelerometerTest/AccelerometerTest.cpp index db535fe321..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() @@ -32,6 +33,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/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/BugsTest/Bug-624.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-624.cpp index e0c4ba23ed..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()) @@ -20,6 +25,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); @@ -50,6 +56,11 @@ void Bug624Layer::onAcceleration(Acceleration* acc, Event* event) // Bug624Layer2 // //////////////////////////////////////////////////////// +Bug624Layer2::~Bug624Layer2() +{ + Device::setAccelerometerEnabled(false); +} + bool Bug624Layer2::init() { if(BugsTestBaseLayer::init()) @@ -60,6 +71,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/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 50d5dc7252..3faf685bf1 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); @@ -46,7 +47,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); @@ -90,6 +91,8 @@ ChipmunkTestLayer::~ChipmunkTestLayer() } cpSpaceFree( _space ); + + Device::setAccelerometerEnabled(false); } 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/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/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.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/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/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/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..e563377357 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"; } @@ -40,6 +40,7 @@ void SceneController::onEnter() ((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true); ((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0); + } void SceneController::onExit() 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); 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/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/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 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/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index 38344c9490..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")); @@ -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(); @@ -74,6 +75,7 @@ void UIScene::previousCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->previousUIScene()); } } @@ -82,6 +84,7 @@ void UIScene::restartCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->currentUIScene()); } } @@ -90,6 +93,7 @@ void UIScene::nextCallback(Object* sender, TouchEventType type) { if (type == TOUCH_EVENT_ENDED) { + m_pUiLayer->removeFromParent(); CCDirector::getInstance()->replaceScene(UISceneManager::sharedUISceneManager()->nextUIScene()); } } 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; 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); 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) }; 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/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/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/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/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/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp index e11b3fa7f7..b3845e1874 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -99,8 +99,8 @@ void PhysicsTestScene::toggleDebug() PhysicsDemo::PhysicsDemo() : _scene(nullptr) -, _ball(nullptr) , _spriteTexture(nullptr) +, _ball(nullptr) { } @@ -201,6 +201,11 @@ void PhysicsDemo::toggleDebugCallback(Object* sender) #endif } +PhysicsDemoClickAdd::~PhysicsDemoClickAdd() +{ + Device::setAccelerometerEnabled(false); +} + void PhysicsDemoClickAdd::onEnter() { PhysicsDemo::onEnter(); @@ -211,6 +216,7 @@ void PhysicsDemoClickAdd::onEnter() touchListener->onTouchesEnded = CC_CALLBACK_2(PhysicsDemoClickAdd::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + Device::setAccelerometerEnabled(true); auto accListener = EventListenerAcceleration::create(CC_CALLBACK_2(PhysicsDemoClickAdd::onAcceleration, this)); _eventDispatcher->addEventListenerWithSceneGraphPriority(accListener, this); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index d93fb7a0cb..15d5e0ce12 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; @@ -56,6 +54,7 @@ protected: class PhysicsDemoClickAdd : public PhysicsDemo { public: + virtual ~PhysicsDemoClickAdd(); void onEnter() override; std::string subtitle() override; 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..cade29ab94 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 +c37b913119295ed7f6bcbb7e04cce322722ea1a5 \ 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/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. 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); 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(); } }, 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/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/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/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/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..ca5791ada7 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000000..c7f557b0be --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -0,0 +1,59 @@ +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:createGameScene() + local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/FishJoy2.json") + if nil == node then + return + end + self._curNode = node + + local function menuCloseCallback( sender ) + ccs.SceneReader:getInstance():destroySceneReader() + ccs.ActionManagerEx:destroyActionManager() + 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(430,30) ) + 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: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 new file mode 100644 index 0000000000..f830bc194e --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioTest.lua @@ -0,0 +1,111 @@ +require "luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest" +require "luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest" +require "luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest" + +local LINE_SPACE = 40 +local ITEM_TAG_BASIC = 1000 + +local cocoStudioTestItemNames = +{ + { + itemTitle = "CocoStudioArmatureTest", + testScene = function () + runArmatureTestScene() + end + }, + + { + itemTitle = "CocoStudioGUITest", + testScene = function () + runCocosGUITestScene() + end + }, + + { + itemTitle = "CocoStudioSceneTest", + testScene = function () + runCocosSceneTestScene() + 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/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/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 3abb47dc4e..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" @@ -17,6 +18,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 +69,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/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/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/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-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-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/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 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-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/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/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 @@ - - + + + 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; }; 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 { 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} diff --git a/tools/android-mk-generator/android_mk_generator.py b/tools/android-mk-generator/android_mk_generator.py index 3e42d908d5..8078f6f58c 100755 --- a/tools/android-mk-generator/android_mk_generator.py +++ b/tools/android-mk-generator/android_mk_generator.py @@ -6,15 +6,26 @@ 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 +35,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 +76,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() @@ -73,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()) 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 diff --git a/tools/bindings-generator b/tools/bindings-generator index d41959ab0b..2f3c19e01d 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit d41959ab0b15c20aa0802ab5c9ef92be7b742bd4 +Subproject commit 2f3c19e01d5043485d0887ad69a3f02e312ad690 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() 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 diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 8959fd0005..5fd5cacc31 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/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$ +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 @@ -36,16 +36,25 @@ 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 setBody 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], + GUIReader::[setPropsForImageButtonFromJsonDictionary], + UIWidget::[(s|g)etUserObject], + UIImageView::[doubleClickEvent] + +rename_functions = UIHelper::[instance=getInstance], + ArmatureDataManager::[sharedArmatureDataManager=getInstance], + GUIReader::[shareReader=getInstance], + ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager], + SceneReader::[purgeSceneReader=destroySceneReader] -rename_functions = ArmatureDataManager::[sharedArmatureDataManager=getInstance] rename_classes = diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index e8d45a1415..b609c7cc43 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 ../../template/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 ..."