diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index b224457f2d..99cb9b0f5e 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -b8bc5839895bfc413816baa425d43a2b8e48205d \ No newline at end of file +874372f8d3779318a2f70b74984575e632ff0dc8 \ No newline at end of file diff --git a/README.md b/README.md index 862ef12264..5562ebd9f7 100644 --- a/README.md +++ b/README.md @@ -31,42 +31,41 @@ Example: $ cd cocos2d-x $ ./setup.py $ source FILE_TO_SAVE_SYSTEM_VARIABLE - $ cocos new mygame -p com.your_company.mygame -l cpp -d /home/mygame - $ cd /home/mygame + $ cocos new MyGame -p com.your_company.mygame -l cpp -d /home + $ cd /home/MyGame -### Build new project for android ### +### Build and run new project for android ### - $ cd proj.android - $ ./build_native.py + $ cocos run -p -j 4 android -### Build new project for ios & osx ### +### Build and run new project for iOS ### -* Enter *proj.ios_mac* folder, open *mygame.xcodeproj* -* Select ios or osx targets in scheme toolbar + $ cocos run -p ios + +### Build and run new project for OSX ### -### Build new project for linux ### + $ cocos run -p mac + +### Build and run new project for linux ### if you never run cocos2d-x on linux, you need to install all dependences by the script in **cocos2d/build/install-deps-linux.sh** - $ cd cocos2d/build + $ cd cocos2d-x/build $ ./install-deps-linux.sh - $ ../.. Then - $ mkdir build - $ cd build - $ cmake .. - $ make -j4 + $ cd /home/MyGame + $ cocos run -p linux Run - $ bin/mygame + $ bin/MyGame -### Build new project for win32 ### +### Build and run new project for win32 ### -* Enter *proj.win32*, open *mygame.sln* by vs2012 + $ cocos run -p win32 Main features @@ -107,6 +106,7 @@ Build Requirements * Mac OS X 10.7+, Xcode 4.6+ * or Ubuntu 12.10+, CMake 2.6+ * or Windows 7+, VS 2012+ +* Python 2.7.5 Runtime Requirements @@ -127,7 +127,7 @@ Select the test you want from Xcode Scheme chooser. ``` $ cd cocos2d-x/build -$ open samples.xcodeproj +$ open cocos_tests.xcodeproj ``` * For Linux @@ -142,9 +142,9 @@ $ make Run Samples ``` -$ bin/hellocpp/hellocpp +$ bin/cpp-empty-test/cpp-empty-test or -$ bin/testlua/testlua +$ bin/lua-empty-test/lua-empty-test ``` You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, @@ -158,10 +158,11 @@ Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln` ``` $ cd cocos2d-x/build -$ python ./android-build.py hellocpp +$ python ./android-build.py cpp-empty-test -p 10 +$ adb install ../tests/cpp-empty-tst/proj.android/bin/CppEmptyTest-debug.apk ``` -Import HelloCpp Android project using Eclipse(released with Android SDK). The path to be imported is `cocos2d-x/samples/Cpp/HelloCpp/proj.android`. +Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10. Contributing to the Project diff --git a/build/android-build.py b/build/android-build.py index b2fbc48a3c..1bdf09370a 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -1,6 +1,6 @@ #!/usr/bin/python # android-build.py -# Build android +# Build android import sys import os, os.path @@ -12,21 +12,21 @@ LUA_SAMPLES = ['lua-empty-test', 'lua-tests'] ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES def get_num_of_cpu(): - ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. - ''' - try: - platform = sys.platform - if platform == 'win32': - if 'NUMBER_OF_PROCESSORS' in os.environ: - return int(os.environ['NUMBER_OF_PROCESSORS']) - else: - return 1 - else: - from numpy.distutils import cpuinfo - return cpuinfo.cpu._getNCPUs() - except Exception: - print "Can't know cpuinfo, use default 1 cpu" - return 1 + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + platform = sys.platform + if platform == 'win32': + if 'NUMBER_OF_PROCESSORS' in os.environ: + return int(os.environ['NUMBER_OF_PROCESSORS']) + else: + return 1 + else: + from numpy.distutils import cpuinfo + return cpuinfo.cpu._getNCPUs() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 def check_environment_variables(): ''' Checking the environment NDK_ROOT, which will be used for building @@ -39,7 +39,7 @@ def check_environment_variables(): sys.exit(1) return NDK_ROOT - + def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building ''' @@ -74,7 +74,7 @@ def select_toolchain_version(): def caculate_built_samples(args): ''' Compute the sampels to be built 'cpp' for short of all cpp tests - 'lua' for short of all lua tests + 'lua' for short of all lua tests ''' if 'all' in args: @@ -115,17 +115,17 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: - sdk_tool_path = os.path.join(sdk_root, "tools/android") - cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java") - command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) - if os.system(command) != 0: - raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") - command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) - if os.system(command) != 0: - raise Exception("update project [ " + app_android_root + " ] fails!") - buildfile_path = os.path.join(app_android_root, "build.xml") - command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) - os.system(command) + sdk_tool_path = os.path.join(sdk_root, "tools/android") + cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java") + command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) + if os.system(command) != 0: + raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") + command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) + if os.system(command) != 0: + raise Exception("update project [ " + app_android_root + " ] fails!") + buildfile_path = os.path.join(app_android_root, "build.xml") + command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) + os.system(command) def copy_files(src, dst): @@ -166,7 +166,7 @@ def copy_resources(target, app_android_root): assets_src_dir = os.path.join(assets_dir, "src"); os.mkdir(assets_src_dir) copy_files(resources_dir, assets_src_dir) - + resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/lua-bindings/script") copy_files(resources_dir, assets_dir) @@ -184,20 +184,20 @@ def build_samples(target,ndk_build_param,android_platform,build_mode): current_dir = os.path.dirname(os.path.realpath(__file__)) cocos_root = os.path.join(current_dir, "..") - + if android_platform is not None: - sdk_root = check_environment_variables_sdk() - if android_platform.isdigit(): - android_platform = 'android-'+android_platform - else: - print 'please use vaild android platform' - exit(1) - + sdk_root = check_environment_variables_sdk() + if android_platform.isdigit(): + android_platform = 'android-'+android_platform + else: + print 'please use vaild android platform' + exit(1) + if build_mode is None: - build_mode = 'debug' + build_mode = 'debug' elif build_mode != 'release': build_mode = 'debug' - + app_android_root = '' target_proj_path_map = { @@ -214,8 +214,8 @@ def build_samples(target,ndk_build_param,android_platform,build_mode): print 'unknown target: %s' % target continue - copy_resources(target, app_android_root) - do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode) + copy_resources(target, app_android_root) + do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode) # -------------- main -------------- if __name__ == '__main__': @@ -223,8 +223,8 @@ if __name__ == '__main__': #parse the params usage = """ This script is mainy used for building tests built-in with cocos2d-x. - - Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests] + + Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests|cpp|lua|all] If you are new to cocos2d-x, I recommend you start with cpp-empty-test, lua-empty-test. @@ -237,16 +237,17 @@ if __name__ == '__main__': """ parser = OptionParser(usage=usage) - parser.add_option("-n", "--ndk", dest="ndk_build_param", + parser.add_option("-n", "--ndk", dest="ndk_build_param", help='Parameter for ndk-build') - parser.add_option("-p", "--platform", dest="android_platform", + parser.add_option("-p", "--platform", dest="android_platform", help='Parameter for android-update. Without the parameter,the script just build dynamic library for the projects. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]') - parser.add_option("-b", "--build", dest="build_mode", + parser.add_option("-b", "--build", dest="build_mode", help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html') (opts, args) = parser.parse_args() if len(args) == 0: parser.print_help() + sys.exit(1) else: try: build_samples(args, opts.ndk_build_param,opts.android_platform,opts.build_mode) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 8088b36f0b..df0f90e563 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -bbf0323293cba3d7ee58ef36706831a8761692d8 \ No newline at end of file +b8986c04c89d3861f82fb99b0df633ac2cc4a13c \ No newline at end of file diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id index e6f0599f23..e4fd4a2b00 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -66526d30a3e76bb1b54c7615a18c467845798e78 \ No newline at end of file +2c5a07d179e9514618036dfb7cfedd3f9cf4c506 \ No newline at end of file diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index e1fc7ad829..a0cf4c2070 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -27,16 +27,22 @@ #include "CCFontFreeType.h" #include "ccUTF8.h" #include "CCDirector.h" +#include "CCEventListenerCustom.h" +#include "CCEventDispatcher.h" +#include "CCEventType.h" NS_CC_BEGIN const int FontAtlas::CacheTextureWidth = 1024; const int FontAtlas::CacheTextureHeight = 1024; +const char* FontAtlas::EVENT_PURGE_TEXTURES = "__cc_FontAtlasPurgeTextures"; FontAtlas::FontAtlas(Font &theFont) : _font(&theFont) , _currentPageData(nullptr) , _fontAscender(0) +, _toForegroundListener(nullptr) +, _toBackgroundListener(nullptr) { _font->retain(); @@ -61,15 +67,40 @@ FontAtlas::FontAtlas(Font &theFont) _currentPageDataSize *= 2; } - _currentPageData = new unsigned char[_currentPageDataSize]; + _currentPageData = new unsigned char[_currentPageDataSize]; memset(_currentPageData, 0, _currentPageDataSize); addTexture(texture,0); texture->release(); +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto eventDispatcher = Director::getInstance()->getEventDispatcher(); + _toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(FontAtlas::listenToBackground, this)); + eventDispatcher->addEventListenerWithFixedPriority(_toBackgroundListener, 1); + _toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(FontAtlas::listenToForeground, this)); + eventDispatcher->addEventListenerWithFixedPriority(_toForegroundListener, 1); +#endif } } FontAtlas::~FontAtlas() { +#if CC_ENABLE_CACHE_TEXTURE_DATA + FontFreeType* fontTTf = dynamic_cast(_font); + if (fontTTf) + { + auto eventDispatcher = Director::getInstance()->getEventDispatcher(); + if (_toForegroundListener) + { + eventDispatcher->removeEventListener(_toForegroundListener); + _toForegroundListener = nullptr; + } + if (_toBackgroundListener) + { + eventDispatcher->removeEventListener(_toBackgroundListener); + _toBackgroundListener = nullptr; + } + } +#endif + _font->release(); relaseTextures(); @@ -82,6 +113,82 @@ void FontAtlas::relaseTextures() { item.second->release(); } + _atlasTextures.clear(); +} + +void FontAtlas::purgeTexturesAtlas() +{ + FontFreeType* fontTTf = dynamic_cast(_font); + if (fontTTf && _atlasTextures.size() > 1) + { + for( auto &item: _atlasTextures) + { + if (item.first != 0) + { + item.second->release(); + } + } + auto temp = _atlasTextures[0]; + _atlasTextures.clear(); + _atlasTextures[0] = temp; + + _fontLetterDefinitions.clear(); + memset(_currentPageData,0,_currentPageDataSize); + _currentPage = 0; + _currentPageOrigX = 0; + _currentPageOrigY = 0; + + auto eventDispatcher = Director::getInstance()->getEventDispatcher(); + eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this); + } +} + +void FontAtlas::listenToBackground(EventCustom *event) +{ +#if CC_ENABLE_CACHE_TEXTURE_DATA + FontFreeType* fontTTf = dynamic_cast(_font); + if (fontTTf && _atlasTextures.size() > 1) + { + for( auto &item: _atlasTextures) + { + if (item.first != 0) + { + item.second->release(); + } + } + auto temp = _atlasTextures[0]; + _atlasTextures.clear(); + _atlasTextures[0] = temp; + + _fontLetterDefinitions.clear(); + memset(_currentPageData,0,_currentPageDataSize); + _currentPage = 0; + _currentPageOrigX = 0; + _currentPageOrigY = 0; + } +#endif +} + +void FontAtlas::listenToForeground(EventCustom *event) +{ +#if CC_ENABLE_CACHE_TEXTURE_DATA + FontFreeType* fontTTf = dynamic_cast(_font); + if (fontTTf) + { + if (_currentPageOrigX == 0 && _currentPageOrigY == 0) + { + auto eventDispatcher = Director::getInstance()->getEventDispatcher(); + eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this); + } + else + { + auto contentSize = Size(CacheTextureWidth,CacheTextureHeight); + auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8; + + _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize ); + } + } +#endif } void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition) @@ -107,10 +214,10 @@ bool FontAtlas::getLetterDefinitionForChar(unsigned short letteCharUTF16, FontL bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String) { - if(_currentPageData == nullptr) + FontFreeType* fontTTf = dynamic_cast(_font); + if(fontTTf == nullptr) return false; - FontFreeType* fontTTf = (FontFreeType*)_font; int length = cc_wcslen(utf16String); float offsetAdjust = _letterPadding / 2; @@ -150,11 +257,6 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String) { _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize ); _currentPageOrigY = 0; - - delete []_currentPageData; - _currentPageData = new unsigned char[_currentPageDataSize]; - if(_currentPageData == nullptr) - return false; memset(_currentPageData, 0, _currentPageDataSize); _currentPage++; auto tex = new Texture2D; diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index 31a2110e4c..9059e119c9 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -34,6 +34,8 @@ NS_CC_BEGIN //fwd class Font; class Texture2D; +class EventCustom; +class EventListenerCustom; struct FontLetterDefinition { @@ -54,6 +56,7 @@ class CC_DLL FontAtlas : public Ref public: static const int CacheTextureWidth; static const int CacheTextureHeight; + static const char* EVENT_PURGE_TEXTURES; /** * @js ctor */ @@ -76,7 +79,22 @@ public: Texture2D* getTexture(int slot); const Font* getFont() const; + + /** Listen "come to background" message, and clear the texture atlas. + It only has effect on Android. + */ + void listenToBackground(EventCustom *event); + + /** Listen "come to foreground" message and restore the texture atlas. + It only has effect on Android. + */ + void listenToForeground(EventCustom *event); + /** Removes textures atlas. + It will purge the textures atlas and if multiple texture exist in the FontAtlas. + */ + void purgeTexturesAtlas(); + private: void relaseTextures(); @@ -95,6 +113,8 @@ private: bool _makeDistanceMap; int _fontAscender; + EventListenerCustom* _toBackgroundListener; + EventListenerCustom* _toForegroundListener; }; diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index ab76eeb28a..119332d009 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -36,6 +36,14 @@ NS_CC_BEGIN std::unordered_map FontAtlasCache::_atlasMap; +void FontAtlasCache::purgeCachedData() +{ + for (auto & atlas:_atlasMap) + { + atlas.second->purgeTexturesAtlas(); + } +} + FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config) { bool useDistanceField = config.distanceFieldEnabled; @@ -46,7 +54,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config) int fontSize = config.fontSize; if (useDistanceField) { - fontSize = Label::DefultFontSize; + fontSize = Label::DistanceFieldFontSize / CC_CONTENT_SCALE_FACTOR(); } std::string atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField); diff --git a/cocos/2d/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h index 1806ff83f8..18c1e88b6c 100644 --- a/cocos/2d/CCFontAtlasCache.h +++ b/cocos/2d/CCFontAtlasCache.h @@ -45,6 +45,11 @@ public: static FontAtlas * getFontAtlasCharMap(const std::string& plistFile); static bool releaseFontAtlas(FontAtlas *atlas); + + /** Removes cached data. + It will purge the textures atlas and if multiple texture exist in one FontAtlas. + */ + static void purgeCachedData(); private: static std::string generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 574a3f33ec..448dc2c0b1 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -33,10 +33,14 @@ #include "CCDirector.h" #include "renderer/CCRenderer.h" #include "CCFont.h" +#include "CCEventListenerCustom.h" +#include "CCEventDispatcher.h" +#include "CCEventType.h" +#include "CCEventCustom.h" NS_CC_BEGIN -const int Label::DefultFontSize = 50; +const int Label::DistanceFieldFontSize = 50; Label* Label::create() { @@ -208,15 +212,15 @@ bool Label::setCharMap(const std::string& plistFile) FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile); if (!newAtlas) - return false; - - if (initWithFontAtlas(newAtlas)) { - _currentLabelType = LabelType::CHARMAP; - return true; + reset(); + return false; } - return false; + setFontAtlas(newAtlas); + _currentLabelType = LabelType::CHARMAP; + + return true; } bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) @@ -224,15 +228,15 @@ bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int st FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(texture,itemWidth,itemHeight,startCharMap); if (!newAtlas) - return false; - - if (initWithFontAtlas(newAtlas)) { - _currentLabelType = LabelType::CHARMAP; - return true; + reset(); + return false; } - return false; + setFontAtlas(newAtlas); + _currentLabelType = LabelType::CHARMAP; + + return true; } bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) @@ -240,15 +244,15 @@ bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHe FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap); if (!newAtlas) - return false; - - if (initWithFontAtlas(newAtlas)) { - _currentLabelType = LabelType::CHARMAP; - return true; + reset(); + return false; } - return false; + setFontAtlas(newAtlas); + _currentLabelType = LabelType::CHARMAP; + + return true; } Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, @@ -274,17 +278,18 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te , _currNumLines(-1) , _textSprite(nullptr) , _contentDirty(false) -, _currentLabelType(LabelType::STRING_TEXTURE) -, _currLabelEffect(LabelEffect::NORMAL) -, _shadowBlurRadius(0) { _cascadeColorEnabled = true; - _batchNodes.push_back(this); + + reset(); - _fontDefinition._fontName = "Helvetica"; - _fontDefinition._fontSize = 12; - _fontDefinition._alignment = TextHAlignment::LEFT; - _fontDefinition._vertAlignment = TextVAlignment::TOP; +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(Label::listenToBackground, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this); +#endif + + auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, CC_CALLBACK_1(Label::listenToFontAtlasPurge, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(purgeTextureListener, this); } Label::~Label() @@ -301,28 +306,40 @@ Label::~Label() CC_SAFE_RELEASE_NULL(_reusedLetter); } -bool Label::init() -{ - bool ret = true; - if(_fontAtlas) - { - ret = SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30); - if (_reusedLetter == nullptr) - { - _reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0)); - _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); - _reusedLetter->retain(); - _reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT); - _reusedLetter->setBatchNode(this); - } - } - _currLabelEffect = LabelEffect::NORMAL; - initProgram(); +void Label::reset() +{ + TTFConfig temp; + _fontConfig = temp; - return ret; + _fontDefinition._fontName = "Helvetica"; + _fontDefinition._fontSize = 12; + _fontDefinition._alignment = _hAlignment; + _fontDefinition._vertAlignment = _vAlignment; + + _fontDirty = false; + _fontName = "Helvetica"; + _fontSize = 12; + + _batchNodes.clear(); + _batchNodes.push_back(this); + + if (_fontAtlas) + { + FontAtlasCache::releaseFontAtlas(_fontAtlas); + _fontAtlas = nullptr; + } + + _currentLabelType = LabelType::STRING_TEXTURE; + _currLabelEffect = LabelEffect::NORMAL; + _shadowBlurRadius = 0; + + Node::removeAllChildrenWithCleanup(true); + _textSprite = nullptr; + + CC_SAFE_RELEASE_NULL(_reusedLetter); } -void Label::initProgram() +void Label::updateShaderProgram() { switch (_currLabelEffect) { @@ -349,32 +366,33 @@ void Label::initProgram() _uniformEffectColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_effectColor"); } -bool Label::initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */) +void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */) { - FontAtlas *oldAtlas = _fontAtlas; - bool oldDistanceFieldEnable = _useDistanceField; - bool oldA8ShaderEnabel = _useA8Shader; + if (atlas == _fontAtlas) + { + FontAtlasCache::releaseFontAtlas(atlas); + return; + } + + if (_fontAtlas) + { + FontAtlasCache::releaseFontAtlas(_fontAtlas); + _fontAtlas = nullptr; + } _fontAtlas = atlas; - _useDistanceField = distanceFieldEnabled; - _useA8Shader = useA8Shader; - - bool ret = Label::init(); - if (oldAtlas) + SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30); + if (_reusedLetter == nullptr) { - if (ret) - { - FontAtlasCache::releaseFontAtlas(oldAtlas); - } - else - { - _fontAtlas = oldAtlas; - _useDistanceField = oldDistanceFieldEnable; - _useA8Shader = oldA8ShaderEnabel; - Label::init(); - - FontAtlasCache::releaseFontAtlas(atlas); - } + _reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0)); + _reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB); + _reusedLetter->retain(); + _reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT); + _reusedLetter->setBatchNode(this); + } + else + { + _reusedLetter->setTexture(_fontAtlas->getTexture(0)); } if (_fontAtlas) @@ -382,8 +400,10 @@ bool Label::initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = fa _commonLineHeight = _fontAtlas->getCommonLineHeight(); _contentDirty = true; } - - return ret; + _useDistanceField = distanceFieldEnabled; + _useA8Shader = useA8Shader; + _currLabelEffect = LabelEffect::NORMAL; + updateShaderProgram(); } bool Label::setTTFConfig(const TTFConfig& ttfConfig) @@ -391,30 +411,30 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig) FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig); if (!newAtlas) + { + reset(); return false; + } - if (initWithFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true)) + setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true); + + _fontConfig = ttfConfig; + if (_fontConfig.outlineSize > 0) { - _fontConfig = ttfConfig; - if (ttfConfig.outlineSize > 0) - { - _fontConfig.distanceFieldEnabled = false; - _useDistanceField = false; - _useA8Shader = false; - _currLabelEffect = LabelEffect::OUTLINE; - initProgram(); - } - else if(ttfConfig.distanceFieldEnabled) - { - this->setFontScale(1.0f * ttfConfig.fontSize / DefultFontSize); - } - _currentLabelType = LabelType::TTF; - return true; + _fontConfig.distanceFieldEnabled = false; + _useDistanceField = false; + _useA8Shader = false; + _currLabelEffect = LabelEffect::OUTLINE; + updateShaderProgram(); } - else + else if(ttfConfig.distanceFieldEnabled) { - return false; + this->setFontScale(1.0f * ttfConfig.fontSize / DistanceFieldFontSize); } + + _currentLabelType = LabelType::TTF; + + return true; } bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset /* = Point::ZERO */) @@ -422,21 +442,23 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& im FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset); if (!newAtlas) - return false; - - if (initWithFontAtlas(newAtlas)) { - _currentLabelType = LabelType::BMFONT; - return true; + reset(); + return false; } - return false; + setFontAtlas(newAtlas); + _currentLabelType = LabelType::BMFONT; + + return true; } void Label::setFontDefinition(const FontDefinition& textDefinition) { + reset(); _fontDefinition = textDefinition; - _currentLabelType = LabelType::STRING_TEXTURE; + _fontName = textDefinition._fontName; + _fontSize = textDefinition._fontSize; _contentDirty = true; } @@ -744,7 +766,7 @@ void Label::enableGlow(const Color3B& glowColor) return; _currLabelEffect = LabelEffect::GLOW; _effectColor = glowColor; - initProgram(); + updateShaderProgram(); } void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = 1 */) @@ -760,7 +782,7 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = 1 */) auto config = _fontConfig; config.outlineSize = outlineSize; setTTFConfig(config); - initProgram(); + updateShaderProgram(); } } _fontDefinition._stroke._strokeEnabled = true; @@ -797,13 +819,13 @@ void Label::disableEffect() setTTFConfig(_fontConfig); } _currLabelEffect = LabelEffect::NORMAL; - initProgram(); + updateShaderProgram(); _contentDirty = true; } void Label::setFontScale(float fontScale) { - _fontScale = fontScale; + _fontScale = fontScale * CC_CONTENT_SCALE_FACTOR(); Node::setScale(_fontScale); } @@ -940,12 +962,30 @@ void Label::updateContent() _contentDirty = false; } +void Label::updateFont() +{ + if (_fontName.find('.') != _fontName.npos) + { + _fontConfig.fontFilePath = _fontName; + _fontConfig.fontSize = _fontSize; + setTTFConfig(_fontConfig); + } + _fontDefinition._fontName = _fontName; + _fontDefinition._fontSize = _fontSize; + _contentDirty = true; + _fontDirty = false; +} + void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) { if (! _visible || _originalUTF8String.empty()) { return; } + if (_fontDirty) + { + updateFont(); + } if (_contentDirty) { updateContent(); @@ -987,72 +1027,30 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent void Label::setFontName(const std::string& fontName) { - if (fontName.find('.') != fontName.npos) + if (fontName != _fontName) { - auto config = _fontConfig; - config.fontFilePath = fontName; - if (setTTFConfig(config)) - { - return; - } - } - if (_fontDefinition._fontName != fontName) - { - _fontDefinition._fontName = fontName; - _contentDirty = true; + _fontName = fontName; + _fontDirty = true; } } const std::string& Label::getFontName() const { - switch (_currentLabelType) - { - case LabelType::TTF: - return _fontConfig.fontFilePath; - default: - return _fontDefinition._fontName; - } + return _fontName; } void Label::setFontSize(int fontSize) { - if (_currentLabelType == LabelType::TTF) + if (_fontSize != fontSize) { - if (_fontConfig.fontSize == fontSize) - { - return; - } - if (_fontConfig.distanceFieldEnabled) - { - _fontConfig.fontSize = fontSize; - this->setFontScale(1.0f * fontSize / DefultFontSize); - } - else - { - auto fontConfig = _fontConfig; - fontConfig.fontSize = fontSize; - setTTFConfig(fontConfig); - } - } - else if(_fontDefinition._fontSize != fontSize) - { - _fontDefinition._fontSize = fontSize; - _fontConfig.fontSize = fontSize; - _contentDirty = true; + _fontSize = fontSize; + _fontDirty = true; } } int Label::getFontSize() const { - switch (_currentLabelType) - { - case LabelType::TTF: - return _fontConfig.fontSize; - case LabelType::STRING_TEXTURE: - return _fontDefinition._fontSize; - default: - return 0; - } + return _fontSize; } ///// PROTOCOL STUFF @@ -1204,6 +1202,10 @@ std::string Label::getDescription() const const Size& Label::getContentSize() const { + if (_fontDirty) + { + const_cast(this)->updateFont(); + } if (_contentDirty) { const_cast(this)->updateContent(); @@ -1211,4 +1213,24 @@ const Size& Label::getContentSize() const return Node::getContentSize(); } +void Label::listenToBackground(EventCustom *event) +{ +#if CC_ENABLE_CACHE_TEXTURE_DATA + if (_fontAtlas && _currentLabelType == LabelType::TTF) + { + _batchNodes.clear(); + _batchNodes.push_back(this); + Node::removeAllChildrenWithCleanup(true); + } +#endif +} + +void Label::listenToFontAtlasPurge(EventCustom *event) +{ + if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas) + { + alignText(); + } +} + NS_CC_END diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index cbfcacf985..bef78167a6 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -59,7 +59,7 @@ typedef struct _ttfConfig bool distanceFieldEnabled; int outlineSize; - _ttfConfig(const char* filePath = "",int size = 36, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC, + _ttfConfig(const char* filePath = "",int size = 12, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC, const char *customGlyphCollection = nullptr,bool useDistanceField = false,int outline = 0) :fontFilePath(filePath) ,fontSize(size) @@ -78,7 +78,7 @@ typedef struct _ttfConfig class CC_DLL Label : public SpriteBatchNode, public LabelProtocol { public: - static const int DefultFontSize; + static const int DistanceFieldFontSize; static Label* create(); @@ -230,6 +230,15 @@ public: virtual const Size& getContentSize() const override; + /** Listen "come to background" message + It only has effect on Android. + */ + void listenToBackground(EventCustom *event); + + /** Listen "FontAtlas purge textures" message + */ + void listenToFontAtlasPurge(EventCustom *event); + protected: void onDraw(const kmMat4& transform, bool transformUpdated); @@ -259,14 +268,12 @@ protected: */ virtual ~Label(); - virtual bool initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false); + virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false); bool recordLetterInfo(const cocos2d::Point& point,const FontLetterDefinition& letterDef, int spriteIndex); bool recordPlaceholderInfo(int spriteIndex); void setFontScale(float fontScale); - - virtual bool init(); virtual void alignText(); @@ -279,14 +286,20 @@ protected: virtual void updateColor() override; - virtual void initProgram(); + virtual void updateShaderProgram(); void drawShadowWithoutBlur(); void createSpriteWithFontDefinition(); + void updateFont(); + void reset(); + bool _isOpacityModifyRGB; bool _contentDirty; + bool _fontDirty; + std::string _fontName; + int _fontSize; LabelType _currentLabelType; std::vector _batchNodes; diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 84c889d81f..1917ea4537 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -226,6 +226,24 @@ const std::string& LabelAtlas::getString(void) const return _string; } +void LabelAtlas::updateColor() +{ + if (_textureAtlas) + { + Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity ); + auto quads = _textureAtlas->getQuads(); + ssize_t length = _string.length(); + for (int index = 0; index < length; index++) + { + quads[index].bl.colors = color4; + quads[index].br.colors = color4; + quads[index].tl.colors = color4; + quads[index].tr.colors = color4; + _textureAtlas->updateQuad(&quads[index], index); + } + } +} + //CCLabelAtlas - draw #if CC_LABELATLAS_DEBUG_DRAW diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index 47064c14c7..157a897c88 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -94,7 +94,8 @@ protected: { _string.clear(); } - + virtual void updateColor() override; + // string to render std::string _string; // the first char in the charmap diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index 38645d960f..cfcee2e726 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "CCActionInterval.h" #include "CCSprite.h" #include "CCLabelAtlas.h" -#include "CCLabelTTF.h" +#include "CCLabel.h" #include "CCScriptSupport.h" #include #include @@ -301,12 +301,12 @@ void MenuItemLabel::setEnabled(bool enabled) { if(enabled == false) { - _colorBackup = _label->getColor(); - _label->setColor(_disabledColor); + _colorBackup = this->getColor(); + this->setColor(_disabledColor); } else { - _label->setColor(_colorBackup); + this->setColor(_colorBackup); } } MenuItem::setEnabled(enabled); @@ -439,7 +439,7 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback _fontName = _globalFontName; _fontSize = _globalFontSize; - LabelTTF *label = LabelTTF::create(value, _fontName, (float)_fontSize); + Label *label = Label::create(value, _fontName, _fontSize); if (MenuItemLabel::initWithLabel(label, callback)) { // do something ? @@ -447,17 +447,11 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback return true; } -void MenuItemFont::recreateLabel() -{ - LabelTTF *label = LabelTTF::create(dynamic_cast(_label)->getString(), - _fontName.c_str(), (float)_fontSize); - this->setLabel(label); -} - void MenuItemFont::setFontSizeObj(int s) { _fontSize = s; - recreateLabel(); + dynamic_cast(_label)->setFontSize(_fontSize); + this->setContentSize(dynamic_cast(_label)->getContentSize()); } int MenuItemFont::getFontSizeObj() const @@ -468,7 +462,8 @@ int MenuItemFont::getFontSizeObj() const void MenuItemFont::setFontNameObj(const std::string& name) { _fontName = name; - recreateLabel(); + dynamic_cast(_label)->setFontName(_fontName); + this->setContentSize(dynamic_cast(_label)->getContentSize()); } const std::string& MenuItemFont::getFontNameObj() const diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index 263c0bec7c..2e28f52037 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -40,7 +40,7 @@ NS_CC_BEGIN typedef std::function ccMenuCallback; -class LabelTTF; +class Label; class LabelAtlas; class Sprite; class SpriteFrame; @@ -142,6 +142,7 @@ private: - BitmapFontAtlas - LabelAtlas - LabelTTF + - Label */ class CC_DLL MenuItemLabel : public MenuItem { @@ -310,8 +311,6 @@ protected: CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Ref* target, SEL_MenuHandler selector); /** initializes a menu item from a string with a target/selector */ bool initWithString(const std::string& value, const ccMenuCallback& callback); - - void recreateLabel(); int _fontSize; std::string _fontName; diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 00d19415f2..1007dd9585 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -224,7 +224,7 @@ void TMXLayer::parseInternalProperties() void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, int gid) { sprite->setPosition(getPositionAt(pos)); - sprite->setVertexZ((float)getVertexZForPos(pos)); + sprite->setPositionZ((float)getVertexZForPos(pos)); sprite->setAnchorPoint(Point::ZERO); sprite->setOpacity(_opacity); @@ -326,7 +326,7 @@ Sprite * TMXLayer::getTileAt(const Point& pos) tile = Sprite::createWithTexture(this->getTexture(), rect); tile->setBatchNode(this); tile->setPosition(getPositionAt(pos)); - tile->setVertexZ((float)getVertexZForPos(pos)); + tile->setPositionZ((float)getVertexZForPos(pos)); tile->setAnchorPoint(Point::ZERO); tile->setOpacity(_opacity); diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 3a558106c3..0e7bd4f647 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -500,11 +500,9 @@ void TextureCache::waitForQuit() std::string TextureCache::getCachedTextureInfo() const { - char buffer[16386]; + std::string buffer; char buftmp[4096]; - memset(buffer,0,sizeof(buffer)); - unsigned int count = 0; unsigned int totalBytes = 0; @@ -527,13 +525,14 @@ std::string TextureCache::getCachedTextureInfo() const (long)tex->getPixelsHigh(), (long)bpp, (long)bytes / 1024); - strcat(buffer, buftmp); + + buffer += buftmp; } snprintf(buftmp, sizeof(buftmp)-1, "TextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)\n", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); - strcat(buffer, buftmp); + buffer += buftmp; - return std::string(buffer); + return buffer; } #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/cocos/2d/CCTweenFunction.cpp b/cocos/2d/CCTweenFunction.cpp index 79a413dc9a..bb9bf4ccd3 100644 --- a/cocos/2d/CCTweenFunction.cpp +++ b/cocos/2d/CCTweenFunction.cpp @@ -121,13 +121,31 @@ float tweenTo(float time, TweenType type, float *easingParam) break; case Elastic_EaseIn: - delta = elasticEaseIn(time, easingParam[0]); + { + float period = 0.3f; + if (nullptr != easingParam) { + period = easingParam[0]; + } + delta = elasticEaseIn(time, period); + } break; case Elastic_EaseOut: - delta = elasticEaseOut(time, easingParam[0]); + { + float period = 0.3f; + if (nullptr != easingParam) { + period = easingParam[0]; + } + delta = elasticEaseOut(time, period); + } break; case Elastic_EaseInOut: - delta = elasticEaseInOut(time, easingParam[0]); + { + float period = 0.3f; + if (nullptr != easingParam) { + period = easingParam[0]; + } + delta = elasticEaseInOut(time, period); + } break; diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index d67c7769e3..b491f0fd9d 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -84,6 +84,7 @@ OldStyle 4267;4251;4244;%(DisableSpecificWarnings) true + CompileAsCpp if not exist "$(OutDir)" mkdir "$(OutDir)" @@ -183,42 +184,20 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - - CompileAsCpp - + - - CompileAsCpp - - - CompileAsCpp - + + - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - - - CompileAsCpp - + + + + + + + + @@ -559,6 +538,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 93a4983b67..c363dfc54b 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -91,21 +91,6 @@ {aeadfa95-9c89-4212-98ae-89ad57db596a} - - {05e27e68-7574-4a8b-af68-553dd3bafdfa} - - - {b797075f-7437-46d5-b4ee-2aa2c108e98f} - - - {c755509d-1610-4e6c-b01b-e01d4d0de46e} - - - {e1b64497-c099-4f06-8d61-9d4c6b7a215a} - - - {7c71abeb-8b4b-4be8-a23c-e32fedc65fc9} - {aec8225f-81a7-4213-b97b-7004d5535398} @@ -115,6 +100,9 @@ {32373f63-2c2d-4eab-bc4a-21745ba0b3fb} + + {465965df-dc31-471a-887f-e430125b8ba0} + @@ -561,46 +549,46 @@ - kazmath\src\GL + kazmath\GL - kazmath\src\GL + kazmath\GL - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath - kazmath\src + kazmath @@ -1162,49 +1150,54 @@ - kazmath\include\kazmath\GL + kazmath\GL - kazmath\include\kazmath\GL + kazmath\GL - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath - kazmath\include\kazmath + kazmath + + + kazmath + + \ No newline at end of file diff --git a/cocos/2d/platform/desktop/CCGLView.cpp b/cocos/2d/platform/desktop/CCGLView.cpp index 0b4dcc7e11..9c2d4a390d 100644 --- a/cocos/2d/platform/desktop/CCGLView.cpp +++ b/cocos/2d/platform/desktop/CCGLView.cpp @@ -399,7 +399,7 @@ void GLView::swapBuffers() bool GLView::windowShouldClose() { if(_mainWindow) - return glfwWindowShouldClose(_mainWindow); + return glfwWindowShouldClose(_mainWindow) ? true : false; else return true; } diff --git a/cocos/2d/platform/linux/CCApplication.cpp b/cocos/2d/platform/linux/CCApplication.cpp index 9d8e81fb1d..9ea95ec06f 100644 --- a/cocos/2d/platform/linux/CCApplication.cpp +++ b/cocos/2d/platform/linux/CCApplication.cpp @@ -70,17 +70,26 @@ int Application::run() return 0; } + long lastTime = 0L; + long curTime = 0L; + auto director = Director::getInstance(); auto glview = director->getOpenGLView(); + // Retain glview to avoid glview being released in the while loop + glview->retain(); + while (!glview->windowShouldClose()) { - long iLastTime = getCurrentMillSecond(); + lastTime = getCurrentMillSecond(); + director->mainLoop(); glview->pollEvents(); - long iCurTime = getCurrentMillSecond(); - if (iCurTime-iLastTime<_animationInterval){ - usleep((_animationInterval - iCurTime+iLastTime)*1000); + + curTime = getCurrentMillSecond(); + if (curTime - lastTime < _animationInterval) + { + usleep((_animationInterval - curTime + lastTime)*1000); } } /* Only work on Desktop @@ -88,8 +97,13 @@ int Application::run() * when we want to close the window, we should call Director::end(); * then call Director::mainLoop to do release of internal resources */ - director->end(); - director->mainLoop(); + if (glview->isOpenGLReady()) + { + director->end(); + director->mainLoop(); + director = nullptr; + } + glview->release(); return -1; } diff --git a/cocos/2d/platform/mac/CCApplication.mm b/cocos/2d/platform/mac/CCApplication.mm index d739404b45..43dd21583a 100644 --- a/cocos/2d/platform/mac/CCApplication.mm +++ b/cocos/2d/platform/mac/CCApplication.mm @@ -68,16 +68,27 @@ int Application::run() { return 0; } - GLView* glview = Director::getInstance()->getOpenGLView(); + + long lastTime = 0L; + long curTime = 0L; + + auto director = Director::getInstance(); + auto glview = director->getOpenGLView(); + + // Retain glview to avoid glview being released in the while loop + glview->retain(); while (!glview->windowShouldClose()) { - long iLastTime = getCurrentMillSecond(); - Director::getInstance()->mainLoop(); + lastTime = getCurrentMillSecond(); + + director->mainLoop(); glview->pollEvents(); - long iCurTime = getCurrentMillSecond(); - if (iCurTime-iLastTime<_animationInterval){ - usleep(static_cast((_animationInterval - iCurTime+iLastTime)*1000)); + + curTime = getCurrentMillSecond(); + if (curTime - lastTime < _animationInterval) + { + usleep(static_cast((_animationInterval - curTime + lastTime)*1000)); } } @@ -86,8 +97,14 @@ int Application::run() * when we want to close the window, we should call Director::end(); * then call Director::mainLoop to do release of internal resources */ - Director::getInstance()->end(); - Director::getInstance()->mainLoop(); + if (glview->isOpenGLReady()) + { + director->end(); + director->mainLoop(); + } + + glview->release(); + return true; } diff --git a/cocos/2d/platform/win32/CCApplication.cpp b/cocos/2d/platform/win32/CCApplication.cpp index a0b0b4a25b..05dd5ee4ac 100644 --- a/cocos/2d/platform/win32/CCApplication.cpp +++ b/cocos/2d/platform/win32/CCApplication.cpp @@ -79,12 +79,16 @@ int Application::run() auto director = Director::getInstance(); auto glview = director->getOpenGLView(); + // Retain glview to avoid glview being released in the while loop + glview->retain(); + while(!glview->windowShouldClose()) { QueryPerformanceCounter(&nNow); if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart) { nLast.QuadPart = nNow.QuadPart; + director->mainLoop(); glview->pollEvents(); } @@ -101,6 +105,7 @@ int Application::run() director->mainLoop(); director = nullptr; } + glview->release(); return true; } diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index 87c44d5d8c..8b93969262 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -110,7 +110,7 @@ bool FileUtilsWin32::isFileExist(const std::string& strFilePath) const } WCHAR utf16Buf[CC_MAX_PATH] = {0}; - MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)); + MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)/sizeof(utf16Buf[0])); return GetFileAttributesW(utf16Buf) != -1 ? true : false; } @@ -137,7 +137,7 @@ static Data getData(const std::string& filename, bool forString) std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); WCHAR wszBuf[CC_MAX_PATH] = {0}; - MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)); + MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); @@ -211,7 +211,7 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch std::string fullPath = fullPathForFilename(filename); WCHAR wszBuf[CC_MAX_PATH] = {0}; - MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)); + MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL); CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE); diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 40fc8970f6..99b37ae047 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -214,7 +214,7 @@ static void _log(const char *format, va_list args) WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); OutputDebugStringW(wszBuf); - WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), buf, sizeof(buf), NULL, FALSE); + WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE); printf("%s", buf); #else diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index e1184f1464..88584c8029 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -488,11 +488,11 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node } else if(propName == "rotationX") { float rotate = value.asFloat(); - pNode->setRotationX(rotate); + pNode->setRotationSkewX(rotate); }else if(propName == "rotationY") { float rotate = value.asFloat(); - pNode->setRotationY(rotate); + pNode->setRotationSkewY(rotate); } else if (propName == "opacity") { @@ -1169,7 +1169,7 @@ void CCBRotateXTo::startWithTarget(Node *pNode) _target = pNode; _elapsed = 0.0f; _firstTick = true; - _startAngle = _target->getRotationX(); + _startAngle = _target->getRotationSkewX(); _diffAngle = _dstAngle - _startAngle; } @@ -1190,8 +1190,7 @@ CCBRotateXTo* CCBRotateXTo::reverse() const void CCBRotateXTo::update(float time) { - _target->setRotationX(_startAngle + (_diffAngle * time)) - ; + _target->setRotationSkewX(_startAngle + (_diffAngle * time)); } @@ -1257,14 +1256,13 @@ void CCBRotateYTo::startWithTarget(Node *pNode) _target = pNode; _elapsed = 0.0f; _firstTick = true; - _startAngle = _target->getRotationY(); + _startAngle = _target->getRotationSkewY(); _diffAngle = _dstAngle - _startAngle; } void CCBRotateYTo::update(float time) { - _target->setRotationY(_startAngle + (_diffAngle * time)) - ; + _target->setRotationSkewY(_startAngle + (_diffAngle * time)); } diff --git a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp index 2d0bffe22f..80d2676e39 100644 --- a/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCNodeLoader.cpp @@ -79,7 +79,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe pNode = ccbNode->getCCBFileNode(); // Skip properties that doesn't have a value to override - Array *extraPropsNames = (Array*)pNode->getUserObject(); + __Array *extraPropsNames = (__Array*)pNode->getUserObject(); Ref* pObj = NULL; bool bFound = false; CCARRAY_FOREACH(extraPropsNames, pObj) @@ -1055,9 +1055,9 @@ void NodeLoader::onHandlePropTypeDegrees(Node * pNode, Node * pParent, const cha if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) { pNode->setRotation(pDegrees); } else if(strcmp(pPropertyName, PROPERTY_ROTATIONX) == 0) { - pNode->setRotationX(pDegrees); + pNode->setRotationSkewX(pDegrees); } else if(strcmp(pPropertyName, PROPERTY_ROTATIONY) == 0) { - pNode->setRotationY(pDegrees); + pNode->setRotationSkewY(pDegrees); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index bf0b311b04..710297c001 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -157,7 +157,7 @@ const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const void GUIReader::registerTypeAndCallBack(const std::string& classType, ObjectFactory::Instance ins, - Object *object, + Ref *object, SEL_ParseEvent callBack) { ObjectFactory* factoryCreate = ObjectFactory::getInstance(); @@ -2030,8 +2030,8 @@ void WidgetPropertiesReader0300::setPropsForAllCustomWidgetFromJsonDictionary(co { GUIReader* guiReader = GUIReader::getInstance(); - std::map object_map = GUIReader::getInstance()->getParseObjectMap(); - Object* object = object_map[classType]; + std::map object_map = GUIReader::getInstance()->getParseObjectMap(); + Ref* object = object_map[classType]; std::map selector_map = guiReader->getParseCallBackMap(); SEL_ParseEvent selector = selector_map[classType]; diff --git a/cocos/editor-support/cocostudio/ObjectFactory.cpp b/cocos/editor-support/cocostudio/ObjectFactory.cpp index 87b724b984..26bb4d7c35 100644 --- a/cocos/editor-support/cocostudio/ObjectFactory.cpp +++ b/cocos/editor-support/cocostudio/ObjectFactory.cpp @@ -143,7 +143,7 @@ Component* ObjectFactory::createComponent(const std::string &name) ui::Widget* ObjectFactory::createGUI(std::string name) { - Object* object = NULL; + Ref* object = nullptr; if (name == "Panel") { @@ -182,7 +182,7 @@ ui::Widget* ObjectFactory::createGUI(std::string name) WidgetReaderProtocol* ObjectFactory::createWidgetReaderProtocol(std::string name) { - Object* object = NULL; + Ref* object = NULL; do { diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index ea09a7f2f1..c8cbb1bd86 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -235,7 +235,7 @@ public: */ void setMoment(float moment); /** get the body moment of inertia. */ - inline float getMoment(float moment) const { return _moment; } + inline float getMoment() const { return _moment; } /** * @brief add moment of inertia to body. * if _moment(moment of the body) == PHYSICS_INFINITY, it remains. diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index 84098e4751..660cf1337d 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -504,8 +504,8 @@ void PhysicsShapeBox::getPoints(Point* points) const Size PhysicsShapeBox::getSize() const { cpShape* shape = _info->getShapes().front(); - return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)), - cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)))); + return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)), + cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)))); } // PhysicsShapePolygon diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 50e773f525..4edf422f03 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -211,6 +211,11 @@ void PhysicsWorld::debugDraw() { PhysicsBody* body = dynamic_cast(obj); + if (!body->isEnabled()) + { + continue; + } + for (auto& shape : body->getShapes()) { _debugDraw->drawShape(*dynamic_cast(shape)); diff --git a/cocos/scripting/lua-bindings/auto/api/PhysicsBody.lua b/cocos/scripting/lua-bindings/auto/api/PhysicsBody.lua index f67992b694..a611fb7553 100644 --- a/cocos/scripting/lua-bindings/auto/api/PhysicsBody.lua +++ b/cocos/scripting/lua-bindings/auto/api/PhysicsBody.lua @@ -43,7 +43,6 @@ -------------------------------- -- @function [parent=#PhysicsBody] getMoment -- @param self --- @param #float float -- @return float#float ret (return value: float) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/api/RichElement.lua b/cocos/scripting/lua-bindings/auto/api/RichElement.lua new file mode 100644 index 0000000000..34d4aec0a9 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichElement.lua @@ -0,0 +1,16 @@ + +-------------------------------- +-- @module RichElement +-------------------------------- +-- @function [parent=#RichElement] init +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#RichElement] RichElement +-- @param self + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/RichElementCustomNode.lua b/cocos/scripting/lua-bindings/auto/api/RichElementCustomNode.lua new file mode 100644 index 0000000000..99943ed0d3 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichElementCustomNode.lua @@ -0,0 +1,26 @@ + +-------------------------------- +-- @module RichElementCustomNode +-------------------------------- +-- @function [parent=#RichElementCustomNode] init +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #cc.Node node +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#RichElementCustomNode] create +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #cc.Node node +-- @return RichElementCustomNode#RichElementCustomNode ret (return value: ccui.RichElementCustomNode) + +-------------------------------- +-- @function [parent=#RichElementCustomNode] RichElementCustomNode +-- @param self + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/RichElementImage.lua b/cocos/scripting/lua-bindings/auto/api/RichElementImage.lua new file mode 100644 index 0000000000..202e67672a --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichElementImage.lua @@ -0,0 +1,26 @@ + +-------------------------------- +-- @module RichElementImage +-------------------------------- +-- @function [parent=#RichElementImage] init +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #char char +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#RichElementImage] create +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #char char +-- @return RichElementImage#RichElementImage ret (return value: ccui.RichElementImage) + +-------------------------------- +-- @function [parent=#RichElementImage] RichElementImage +-- @param self + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/RichElementText.lua b/cocos/scripting/lua-bindings/auto/api/RichElementText.lua new file mode 100644 index 0000000000..5cf922dcf0 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichElementText.lua @@ -0,0 +1,30 @@ + +-------------------------------- +-- @module RichElementText +-------------------------------- +-- @function [parent=#RichElementText] init +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #char char +-- @param #char char +-- @param #float float +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#RichElementText] create +-- @param self +-- @param #int int +-- @param #color3B_table color3b +-- @param #unsigned char char +-- @param #char char +-- @param #char char +-- @param #float float +-- @return RichElementText#RichElementText ret (return value: ccui.RichElementText) + +-------------------------------- +-- @function [parent=#RichElementText] RichElementText +-- @param self + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/RichText.lua b/cocos/scripting/lua-bindings/auto/api/RichText.lua new file mode 100644 index 0000000000..6fadaad8ff --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/RichText.lua @@ -0,0 +1,57 @@ + +-------------------------------- +-- @module RichText +-------------------------------- +-- @function [parent=#RichText] insertElement +-- @param self +-- @param #ccui.RichElement richelement +-- @param #int int + +-------------------------------- +-- @function [parent=#RichText] setAnchorPoint +-- @param self +-- @param #point_table point + +-------------------------------- +-- @function [parent=#RichText] pushBackElement +-- @param self +-- @param #ccui.RichElement richelement + +-------------------------------- +-- @function [parent=#RichText] formatText +-- @param self + +-------------------------------- +-- @function [parent=#RichText] ignoreContentAdaptWithSize +-- @param self +-- @param #bool bool + +-------------------------------- +-- @function [parent=#RichText] setVerticalSpace +-- @param self +-- @param #float float + +-------------------------------- +-- @function [parent=#RichText] getContentSize +-- @param self +-- @return size_table#size_table ret (return value: size_table) + +-------------------------------- +-- overload function: removeElement(ccui.RichElement) +-- +-- overload function: removeElement(int) +-- +-- @function [parent=#RichText] removeElement +-- @param self +-- @param #int int + +-------------------------------- +-- @function [parent=#RichText] create +-- @param self +-- @return RichText#RichText ret (return value: ccui.RichText) + +-------------------------------- +-- @function [parent=#RichText] RichText +-- @param self + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua index 918cb1f330..022d2f7187 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua @@ -91,4 +91,29 @@ -- @field [parent=#ccui] Helper#Helper Helper preloaded module +-------------------------------------------------------- +-- the ccui RichElement +-- @field [parent=#ccui] RichElement#RichElement RichElement preloaded module + + +-------------------------------------------------------- +-- the ccui RichElementText +-- @field [parent=#ccui] RichElementText#RichElementText RichElementText preloaded module + + +-------------------------------------------------------- +-- the ccui RichElementImage +-- @field [parent=#ccui] RichElementImage#RichElementImage RichElementImage preloaded module + + +-------------------------------------------------------- +-- the ccui RichElementCustomNode +-- @field [parent=#ccui] RichElementCustomNode#RichElementCustomNode RichElementCustomNode preloaded module + + +-------------------------------------------------------- +-- the ccui RichText +-- @field [parent=#ccui] RichText#RichText RichText preloaded module + + return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id index a499b30375..033466eb38 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -b0dc5acd96b5d7e94c40c01097a6f969719a6110 \ No newline at end of file +44ccccc9572e8345c6b9903e8f10abcf0937d1cc \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id index 7d3b4412fd..99aa8077bc 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -337366fa551a6f02e7f44e832e351fad51895ca5 \ No newline at end of file +cb29285429f792ed191dc2135b5f80ca5e52e9d1 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp.REMOVED.git-id index e59710c30d..3a2dffca25 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -6deb0e9e9ec193559f4eaa0f48310265bc32a491 \ No newline at end of file +6830e4b8f10511215bf059042bfd7eca7cc03679 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp index 02abdfff42..e15f911b88 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp @@ -25,7 +25,7 @@ int lua_cocos2dx_spine_Skeleton_setToSetupPose(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'", nullptr); return 0; } #endif @@ -68,7 +68,7 @@ int lua_cocos2dx_spine_Skeleton_setBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'", nullptr); return 0; } #endif @@ -114,7 +114,7 @@ int lua_cocos2dx_spine_Skeleton_onDraw(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_onDraw'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_onDraw'", nullptr); return 0; } #endif @@ -163,7 +163,7 @@ int lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'", nullptr); return 0; } #endif @@ -206,7 +206,7 @@ int lua_cocos2dx_spine_Skeleton_getBlendFunc(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'", nullptr); return 0; } #endif @@ -250,7 +250,7 @@ int lua_cocos2dx_spine_Skeleton_setSkin(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSkin'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSkin'", nullptr); return 0; } #endif @@ -297,7 +297,7 @@ int lua_cocos2dx_spine_Skeleton_setBonesToSetupPose(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'", nullptr); return 0; } #endif @@ -329,7 +329,7 @@ static int lua_cocos2dx_spine_Skeleton_finalize(lua_State* tolua_S) int lua_register_cocos2dx_spine_Skeleton(lua_State* tolua_S) { tolua_usertype(tolua_S,"sp.Skeleton"); - tolua_cclass(tolua_S,"Skeleton","sp.Skeleton","cc.Node",NULL); + tolua_cclass(tolua_S,"Skeleton","sp.Skeleton","cc.Node",nullptr); tolua_beginmodule(tolua_S,"Skeleton"); tolua_function(tolua_S,"setToSetupPose",lua_cocos2dx_spine_Skeleton_setToSetupPose); @@ -366,7 +366,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_addAnimation(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'", nullptr); return 0; } #endif @@ -439,7 +439,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_getCurrent(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'", nullptr); return 0; } #endif @@ -494,7 +494,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_setMix(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'", nullptr); return 0; } #endif @@ -546,7 +546,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_setAnimation(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'", nullptr); return 0; } #endif @@ -599,7 +599,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTracks(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'", nullptr); return 0; } #endif @@ -642,7 +642,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'", nullptr); return 0; } #endif @@ -695,7 +695,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(lua_State* tolua_ #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", NULL); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", nullptr); return 0; } #endif @@ -739,7 +739,7 @@ static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S) int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S) { tolua_usertype(tolua_S,"sp.SkeletonAnimation"); - tolua_cclass(tolua_S,"SkeletonAnimation","sp.SkeletonAnimation","sp.Skeleton",NULL); + tolua_cclass(tolua_S,"SkeletonAnimation","sp.SkeletonAnimation","sp.Skeleton",nullptr); tolua_beginmodule(tolua_S,"SkeletonAnimation"); tolua_function(tolua_S,"addAnimation",lua_cocos2dx_spine_SkeletonAnimation_addAnimation); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp.REMOVED.git-id index 548c0c9831..bcd5a80a5a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -b1abe1fd74f3d67444e32b3a3a0cad5c86b4269a \ No newline at end of file +0a46232432ba108d165f69ca9435f3ae0e911a27 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id index 46b602ad1b..104c65729e 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -d0b810bd90f5639ba15e03fc5e083b762225a16d \ No newline at end of file +11bba6be0cebc89eb4c7195a61d021e51719468f \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 220c5d3f00..1e576402ce 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -328,6 +328,32 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/lua-bindings/manual/lua_debugger.c.REMOVED.git-id b/cocos/scripting/lua-bindings/manual/lua_debugger.c.REMOVED.git-id index b474b19a28..5f4b4125c3 100644 --- a/cocos/scripting/lua-bindings/manual/lua_debugger.c.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/manual/lua_debugger.c.REMOVED.git-id @@ -1 +1 @@ -fe27a3bee5f56dc93ee7ae540adb0d88245d8072 \ No newline at end of file +9ad446c3528688b8df8fe36f8d72cec5eb49789d \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 64c6b685f2..63eca00029 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -932,7 +932,12 @@ ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios"; + LIBRARY_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios", + "$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios", + ); + "OTHER_LDFLAGS[arch=arm64]" = "-llua"; + "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../2d/platform/ios"; @@ -952,7 +957,12 @@ ); HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1; - LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios"; + LIBRARY_SEARCH_PATHS = ( + "$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios", + "$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios", + ); + "OTHER_LDFLAGS[arch=arm64]" = "-llua"; + "OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../2d/platform/ios"; diff --git a/cocos/ui/GUIDefine.h b/cocos/ui/GUIDefine.h index 8cd44b664a..788439e7aa 100644 --- a/cocos/ui/GUIDefine.h +++ b/cocos/ui/GUIDefine.h @@ -30,9 +30,9 @@ #include #include "cocostudio/ObjectFactory.h" -#pragma mark - -#pragma mark Widget macro -#pragma mark - +//#pragma mark - +//#pragma mark Widget macro +//#pragma mark - #define DECLARE_CLASS_GUI_INFO \ public: \ @@ -50,9 +50,9 @@ cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) \ -#pragma mark - -#pragma mark Reader macro -#pragma mark - +//#pragma mark - +//#pragma mark Reader macro +//#pragma mark - #define DECLARE_CLASS_WIDGET_READER_INFO \ public: \ diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 941bdf0b46..63c21a2fc1 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -436,7 +436,7 @@ void Button::updateFlippedX() _titleRenderer->setFlippedX(_flippedX); if (_scale9Enabled) { - int flip = _flippedX ? -1 : 1; + float flip = _flippedX ? -1.0f : 1.0f; _buttonNormalRenderer->setScaleX(flip); _buttonClickedRenderer->setScaleX(flip); _buttonDisableRenderer->setScaleX(flip); @@ -454,7 +454,7 @@ void Button::updateFlippedY() _titleRenderer->setFlippedY(_flippedY); if (_scale9Enabled) { - int flip = _flippedY ? -1 : 1; + float flip = _flippedY ? -1.0f : 1.0f; _buttonNormalRenderer->setScaleY(flip); _buttonClickedRenderer->setScaleY(flip); _buttonDisableRenderer->setScaleY(flip); diff --git a/cocos/ui/UILayout.h b/cocos/ui/UILayout.h index f525ab870a..bf82af234a 100644 --- a/cocos/ui/UILayout.h +++ b/cocos/ui/UILayout.h @@ -154,11 +154,11 @@ public: const Point& getBackGroundColorVector(); - void setBackGroundImageColor(const ccColor3B& color); + void setBackGroundImageColor(const Color3B& color); void setBackGroundImageOpacity(GLubyte opacity); - const ccColor3B& getBackGroundImageColor(); + const Color3B& getBackGroundImageColor(); GLubyte getBackGroundImageOpacity(); diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 8e153ec123..a9099ad291 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -340,7 +340,7 @@ void RichText::formarRenderers() float newContentSizeHeight = 0.0f; float *maxHeights = new float[_elementRenders.size()]; - for (int i=0; i<_elementRenders.size(); i++) + for (size_t i=0; i<_elementRenders.size(); i++) { Vector* row = (_elementRenders[i]); float maxHeight = 0.0f; @@ -355,7 +355,7 @@ void RichText::formarRenderers() float nextPosY = _customSize.height; - for (int i=0; i<_elementRenders.size(); i++) + for (size_t i=0; i<_elementRenders.size(); i++) { Vector* row = (_elementRenders[i]); float nextPosX = 0.0f; @@ -374,7 +374,7 @@ void RichText::formarRenderers() delete [] maxHeights; } - int length = _elementRenders.size(); + size_t length = _elementRenders.size(); for (size_t i = 0; i* l = _elementRenders[i]; diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 3459f9e2ec..9b0068f26f 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -1020,8 +1020,8 @@ void Widget::copyProperties(Widget *widget) setScaleX(widget->getScaleX()); setScaleY(widget->getScaleY()); setRotation(widget->getRotation()); - setRotationX(widget->getRotationX()); - setRotationY(widget->getRotationY()); + setRotationSkewX(widget->getRotationSkewX()); + setRotationSkewY(widget->getRotationSkewY()); setFlippedX(widget->isFlippedX()); setFlippedY(widget->isFlippedY()); setColor(widget->getColor()); diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index d693a3809e..b354e0b892 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -91,8 +91,8 @@ You can run the samples... $ cd cocos2d-x $ ./setup.py $ cd build - $ ./android-build.py -p 10 - $ adb install cocos2d-x/tests/proj.android/bin/TestDemo-debug.apk + $ ./android-build.py cpp-empty-test -p 10 + $ adb install cocos2d-x/tests/cpp-empty-test/proj.android/bin/CppEmptyTest-debug.apk Then click item on Android device to run tests. Available value of `-p` is the API level, cocos2d-x supports from level 10. @@ -101,18 +101,18 @@ Then click item on Android device to run tests. Available value of `-p` is the A $ cd cocos2d-x $ ./setup.py $ cd build - $ ./android-build.py + $ ./android-build.py cpp-empty-test -p 10 Then * Import cocos2d-x Android project into Eclipse, the path used to import is `cocos/2d/platform/android` -* Import `tests` Android project into Eclipse, the path used to import is `tests/proj.android` -* Build `tests` Android project and run +* Import `cpp-empty-test` Android project into Eclipse, the path used to import is `tests/cpp-empty-test/proj.android` +* Build `cpp-empty-test` Android project and run ### Windows * Enter `cocos2d-x/build`, and open `cocos2d-win32.vs2012.sln` -* Select `TestCpp` as running target +* Select `cpp-empty-test` as running target * Click run button @@ -126,23 +126,17 @@ Then $ mkdir build $ cd build - $ cmake .. + $ cmake ../cocos2d-x $ make -j4 Run - $ cd bin/testcpp - $ ./testcpp + $ cd bin/cpp-empty-test + $ ./cpp-empty-test ## How to start a new game - $ cd cocos2d-x - $ ./setup.py - $ source FILE_TO_RECORD_SYSTEM_VARIABLE -`FILE_TO_RECORD_SYSTEM_VARIABLE` may be `~/.bash_profile`, `~/.bash_login` or `~./.profile` - - $ cocos new MyGame -p com.MyCompany.MyGame -l cpp -d directory_to_save -Because `cocos run` command is not ready, so you should do it manually as running `TestCpp`. After `cocos run` command is finished, can just run `cocos run` to run the new game on demand target. +Please refer to [ReadMe](../README.md) # Highlights of v3.0 diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp index d3c2ac4743..f46499e44c 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.cpp @@ -68,14 +68,16 @@ static const int CC_EDIT_BOX_PADDING = 5; bool EditBoxImplAndroid::initWithSize(const Size& size) { int fontSize = getFontSizeAccordingHeightJni(size.height-12); - _label = LabelTTF::create("", "", size.height-12); + _label = Label::create(); + _label->setFontSize(size.height-12); // align the text vertically center _label->setAnchorPoint(Point(0, 0.5f)); _label->setPosition(Point(CC_EDIT_BOX_PADDING, size.height / 2.0f)); _label->setColor(_colText); _editBox->addChild(_label); - _labelPlaceHolder = LabelTTF::create("", "", size.height-12); + _labelPlaceHolder = Label::create(); + _labelPlaceHolder->setFontSize(size.height-12); // align the text vertically center _labelPlaceHolder->setAnchorPoint(Point(0, 0.5f)); _labelPlaceHolder->setPosition(Point(CC_EDIT_BOX_PADDING, size.height / 2.0f)); @@ -167,7 +169,7 @@ void EditBoxImplAndroid::setText(const char* pText) long length = cc_utf8_strlen(_text.c_str(), -1); for (long i = 0; i < length; i++) { - strToShow.append("\u25CF"); + strToShow.append("*"); } } else @@ -178,15 +180,12 @@ void EditBoxImplAndroid::setText(const char* pText) _label->setString(strToShow.c_str()); // Clip the text width to fit to the text box - // FIXME: After re-implement LabelTTF by Label, '(g|s)etTextureRect' will not work, it's because LabelTTF is inherited from Node rather than Sprite now. - - // float fMaxWidth = _editSize.width - CC_EDIT_BOX_PADDING * 2; - // Rect clippingRect = _label->getTextureRect(); - // if(clippingRect.size.width > fMaxWidth) { - // clippingRect.size.width = fMaxWidth; - // _label->setTextureRect(clippingRect); - // } + float fMaxWidth = _editSize.width - CC_EDIT_BOX_PADDING * 2; + auto labelSize = _label->getContentSize(); + if(labelSize.width > fMaxWidth) { + _label->setDimensions(fMaxWidth,labelSize.height); + } } else { diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h index 5e4c7ebf51..69a1f3e1a6 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplAndroid.h @@ -84,8 +84,8 @@ public: virtual void closeKeyboard(); private: - LabelTTF* _label; - LabelTTF* _labelPlaceHolder; + Label* _label; + Label* _labelPlaceHolder; EditBox::InputMode _editBoxInputMode; EditBox::InputFlag _editBoxInputFlag; EditBox::KeyboardReturnType _keyboardReturnType; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h index b64208f4d2..329d30c55a 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h @@ -123,8 +123,8 @@ private: void adjustTextFieldPosition(); void placeInactiveLabels(); - LabelTTF* _label; - LabelTTF* _labelPlaceHolder; + Label* _label; + Label* _labelPlaceHolder; Size _contentSize; Point _position; Point _anchorPoint; diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm index 13002597df..d2ba95be02 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -327,13 +327,13 @@ void EditBoxImplIOS::initInactiveLabels(const Size& size) { const char* pDefaultFontName = [[_systemControl.textField.font fontName] UTF8String]; - _label = LabelTTF::create("", "", 0.0f); + _label = Label::create(); _label->setAnchorPoint(Point(0, 0.5f)); _label->setColor(Color3B::WHITE); _label->setVisible(false); _editBox->addChild(_label, kLabelZOrder); - _labelPlaceHolder = LabelTTF::create("", "", 0.0f); + _labelPlaceHolder = Label::create(); // align the text vertically center _labelPlaceHolder->setAnchorPoint(Point(0, 0.5f)); _labelPlaceHolder->setColor(Color3B::GRAY); @@ -362,14 +362,11 @@ void EditBoxImplIOS::setInactiveText(const char* pText) _label->setString(getText()); // Clip the text width to fit to the text box - // FIXME: After re-implement LabelTTF by Label, '(g|s)etTextureRect' will not work, it's because LabelTTF is inherited from Node rather than Sprite now. - // float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2; - // Rect clippingRect = _label->getTextureRect(); - // if(clippingRect.size.width > fMaxWidth) - // { - // clippingRect.size.width = fMaxWidth; - // _label->setTextureRect(clippingRect); - // } + float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2; + Size labelSize = _label->getContentSize(); + if(labelSize.width > fMaxWidth) { + _label->setDimensions(fMaxWidth,labelSize.height); + } } void EditBoxImplIOS::setFont(const char* pFontName, int fontSize) diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp index 4dcc885f49..b532285370 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.cpp @@ -70,14 +70,16 @@ void EditBoxImplWin::doAnimationWhenKeyboardMove(float duration, float distance) bool EditBoxImplWin::initWithSize(const Size& size) { //! int fontSize = getFontSizeAccordingHeightJni(size.height-12); - _label = LabelTTF::create("", "", size.height-12); + _label = Label::create(); + _label->setFontSize(size.height-12); // align the text vertically center _label->setAnchorPoint(Point(0, 0.5f)); _label->setPosition(Point(5, size.height / 2.0f)); _label->setColor(_colText); _editBox->addChild(_label); - _labelPlaceHolder = LabelTTF::create("", "", size.height-12); + _labelPlaceHolder = Label::create(); + _labelPlaceHolder->setFontSize(size.height-12); // align the text vertically center _labelPlaceHolder->setAnchorPoint(Point(0, 0.5f)); _labelPlaceHolder->setPosition(Point(5, size.height / 2.0f)); diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h index 2b379efe83..7c2a699dc8 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWin.h +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWin.h @@ -84,8 +84,8 @@ public: virtual void onEnter(void); private: - LabelTTF* _label; - LabelTTF* _labelPlaceHolder; + Label* _label; + Label* _labelPlaceHolder; EditBox::InputMode _editBoxInputMode; EditBox::InputFlag _editBoxInputFlag; EditBox::KeyboardReturnType _keyboardReturnType; diff --git a/external/curl/include/ios/curl/curlbuild.h b/external/curl/include/ios/curl/curlbuild.h index c24099a90a..3397c39b61 100644 --- a/external/curl/include/ios/curl/curlbuild.h +++ b/external/curl/include/ios/curl/curlbuild.h @@ -171,13 +171,13 @@ typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; /* curl_off_t formatting string directive without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_T "lld" +#define CURL_FORMAT_CURL_OFF_T PRId64 /* unsigned curl_off_t formatting string without "%" conversion specifier. */ -#define CURL_FORMAT_CURL_OFF_TU "llu" +#define CURL_FORMAT_CURL_OFF_TU PRIu64 /* curl_off_t formatting string directive with "%" conversion specifier. */ -#define CURL_FORMAT_OFF_T "%lld" +#define CURL_FORMAT_OFF_T "%" PRId64 /* The size of `curl_off_t', as computed by sizeof. */ #define CURL_SIZEOF_CURL_OFF_T 8 diff --git a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id index a3971cdd23..b832ed4fb2 100644 --- a/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id +++ b/external/curl/prebuilt/ios/libcurl.a.REMOVED.git-id @@ -1 +1 @@ -c135286e812602cc184684b59b4d074f723ef4a5 \ No newline at end of file +dc1d98e73cda98024add3420a06fa29651c863d0 \ No newline at end of file diff --git a/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..709ec42a2a --- /dev/null +++ b/external/curl/prebuilt/ios/libcurl_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +9b09288998b6198388456c41ccbdd5596622abe5 \ No newline at end of file diff --git a/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id b/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id index f7532b4633..6f0e868417 100644 --- a/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id +++ b/external/freetype2/prebuilt/ios/libfreetype.a.REMOVED.git-id @@ -1 +1 @@ -3303f759eb8c682843322ffa9f8c69563d241ca5 \ No newline at end of file +81b071fde15c160fb96e2b28a22142e903fdf5a4 \ No newline at end of file diff --git a/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id b/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..5bae8cd871 --- /dev/null +++ b/external/freetype2/prebuilt/ios/libfreetype_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +690402fd689da9d29621e7665db2f40ac4e947eb \ No newline at end of file diff --git a/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id b/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id index 5434a2f27c..a366f9fbac 100644 --- a/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id +++ b/external/jpeg/prebuilt/ios/libjpeg.a.REMOVED.git-id @@ -1 +1 @@ -39c4d5970691b3a3ca47be0f7d2a0b5c72e9e2ee \ No newline at end of file +e8281e5ccfc438a1d097b9704010312801ea192e \ No newline at end of file diff --git a/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id b/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..11f4aa8c76 --- /dev/null +++ b/external/jpeg/prebuilt/ios/libjpeg_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +dd93f7d77c23392642750b58fb0f41eda9218b69 \ No newline at end of file diff --git a/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id b/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id index 78b5e3634d..fdea42a702 100644 --- a/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id +++ b/external/jpeg/prebuilt/mac/libjpeg.a.REMOVED.git-id @@ -1 +1 @@ -fc2d13f253f62b28ad1d37a4a24da1e977acba20 \ No newline at end of file +d8eeb3fe1c71ca56139f7e31f0b502da876c692b \ No newline at end of file diff --git a/external/lua/lua/lbaselib.c b/external/lua/lua/lbaselib.c index 2ab550bd48..2a4c079d3b 100644 --- a/external/lua/lua/lbaselib.c +++ b/external/lua/lua/lbaselib.c @@ -631,7 +631,7 @@ static void base_open (lua_State *L) { luaL_register(L, "_G", base_funcs); lua_pushliteral(L, LUA_VERSION); lua_setglobal(L, "_VERSION"); /* set global _VERSION */ - /* `ipairs' and `pairs' need auxiliary functions as upvalues */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ auxopen(L, "ipairs", luaB_ipairs, ipairsaux); auxopen(L, "pairs", luaB_pairs, luaB_next); /* `newproxy' needs a weaktable as upvalue */ diff --git a/external/lua/lua/lcode.c b/external/lua/lua/lcode.c index 679cb9cfd9..cff626b7fa 100644 --- a/external/lua/lua/lcode.c +++ b/external/lua/lua/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $ +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -544,6 +544,10 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always true; do nothing */ break; } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } case VJMP: { invertjump(fs, e); pc = e->u.s.info; @@ -568,6 +572,10 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { pc = NO_JUMP; /* always false; do nothing */ break; } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } case VJMP: { pc = e->u.s.info; break; diff --git a/external/lua/lua/ldblib.c b/external/lua/lua/ldblib.c index 2027eda598..67de1222a9 100644 --- a/external/lua/lua/ldblib.c +++ b/external/lua/lua/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $ +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -45,7 +45,6 @@ static int db_setmetatable (lua_State *L) { static int db_getfenv (lua_State *L) { - luaL_checkany(L, 1); lua_getfenv(L, 1); return 1; } diff --git a/external/lua/lua/ldo.c b/external/lua/lua/ldo.c index d1bf786cb7..8de05f728e 100644 --- a/external/lua/lua/ldo.c +++ b/external/lua/lua/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $ +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -217,7 +217,6 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { int nvar = actual - nfixargs; /* number of extra arguments */ lua_assert(p->is_vararg & VARARG_HASARG); luaC_checkGC(L); - luaD_checkstack(L, p->maxstacksize); htab = luaH_new(L, nvar, 1); /* create `arg' table */ for (i=0; itop - nvar + i); diff --git a/external/lua/lua/lgc.c b/external/lua/lua/lgc.c index e909c79a96..d9e0b78294 100644 --- a/external/lua/lua/lgc.c +++ b/external/lua/lua/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $ +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -627,6 +627,7 @@ void luaC_step (lua_State *L) { } } else { + lua_assert(g->totalbytes >= g->estimate); setthreshold(g); } } diff --git a/external/lua/lua/liolib.c b/external/lua/lua/liolib.c index e072056ca1..e79ed1cb2e 100644 --- a/external/lua/lua/liolib.c +++ b/external/lua/lua/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $ +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -180,13 +180,11 @@ static int io_popen (lua_State *L) { } -#ifndef __native_client__ static int io_tmpfile (lua_State *L) { FILE **pf = newfile(L); *pf = tmpfile(); return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; } -#endif static FILE *getiofile (lua_State *L, int findex) { @@ -278,10 +276,7 @@ static int read_number (lua_State *L, FILE *f) { lua_pushnumber(L, d); return 1; } - else { - lua_pushnil(L); /* "result" to be removed */ - return 0; /* read fails */ - } + else return 0; /* read fails */ } @@ -488,9 +483,7 @@ static const luaL_Reg iolib[] = { {"output", io_output}, {"popen", io_popen}, {"read", io_read}, -#ifndef __native_client__ {"tmpfile", io_tmpfile}, -#endif {"type", io_type}, {"write", io_write}, {NULL, NULL} diff --git a/external/lua/lua/llex.c b/external/lua/lua/llex.c index 77afcdedc7..6dc319358c 100644 --- a/external/lua/lua/llex.c +++ b/external/lua/lua/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $ +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -118,10 +118,8 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) { lua_State *L = ls->L; TString *ts = luaS_newlstr(L, str, l); TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ - if (ttisnil(o)) { + if (ttisnil(o)) setbvalue(o, 1); /* make sure `str' will not be collected */ - luaC_checkGC(L); - } return ts; } @@ -178,9 +176,9 @@ static void buffreplace (LexState *ls, char from, char to) { static void trydecpoint (LexState *ls, SemInfo *seminfo) { /* format error: try to update decimal point separator */ - /* struct lconv *cv = localeconv(); removed for android ndk */ + struct lconv *cv = localeconv(); char old = ls->decpoint; - ls->decpoint = '.'; /* (cv ? cv->decimal_point[0] : '.'); removed for android ndk */ + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { /* format error with correct decimal point: no more options */ diff --git a/external/lua/lua/loadlib.c b/external/lua/lua/loadlib.c index 6158c5353d..0d401eba1c 100644 --- a/external/lua/lua/loadlib.c +++ b/external/lua/lua/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $ +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -639,7 +639,7 @@ LUALIB_API int luaopen_package (lua_State *L) { lua_pushvalue(L, -1); lua_replace(L, LUA_ENVIRONINDEX); /* create `loaders' table */ - lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0); + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); /* fill it with pre-defined loaders */ for (i=0; loaders[i] != NULL; i++) { lua_pushcfunction(L, loaders[i]); diff --git a/external/lua/lua/loslib.c b/external/lua/lua/loslib.c index 3443907973..da06a572ac 100644 --- a/external/lua/lua/loslib.c +++ b/external/lua/lua/loslib.c @@ -35,12 +35,10 @@ static int os_pushresult (lua_State *L, int i, const char *filename) { } -#ifndef __native_client__ static int os_execute (lua_State *L) { lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); return 1; } -#endif static int os_remove (lua_State *L) { @@ -223,9 +221,7 @@ static const luaL_Reg syslib[] = { {"clock", os_clock}, {"date", os_date}, {"difftime", os_difftime}, -#ifndef __native_client__ {"execute", os_execute}, -#endif {"exit", os_exit}, {"getenv", os_getenv}, {"remove", os_remove}, diff --git a/external/lua/lua/lparser.c b/external/lua/lua/lparser.c index dda7488dca..1e2a9a88b7 100644 --- a/external/lua/lua/lparser.c +++ b/external/lua/lua/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $ +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -374,9 +374,9 @@ static void close_func (LexState *ls) { lua_assert(luaG_checkcode(f)); lua_assert(fs->bl == NULL); ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ /* last token read was anchored in defunct function; must reanchor it */ if (fs) anchor_token(ls); - L->top -= 2; /* remove table and prototype from the stack */ } diff --git a/external/lua/lua/lstrlib.c b/external/lua/lua/lstrlib.c index 7a03489beb..1b4763d4ee 100644 --- a/external/lua/lua/lstrlib.c +++ b/external/lua/lua/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $ +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -754,7 +754,6 @@ static void addintlen (char *form) { static int str_format (lua_State *L) { - int top = lua_gettop(L); int arg = 1; size_t sfl; const char *strfrmt = luaL_checklstring(L, arg, &sfl); @@ -769,8 +768,7 @@ static int str_format (lua_State *L) { else { /* format item */ char form[MAX_FORMAT]; /* to store the format (`%...') */ char buff[MAX_ITEM]; /* to store the formatted item */ - if (++arg > top) - luaL_argerror(L, arg, "no value"); + arg++; strfrmt = scanformat(L, strfrmt, form); switch (*strfrmt++) { case 'c': { diff --git a/external/lua/lua/lua.c b/external/lua/lua/lua.c index 3add3ee1c5..3a46609328 100644 --- a/external/lua/lua/lua.c +++ b/external/lua/lua/lua.c @@ -336,3 +336,57 @@ struct Smain { int status; }; + +static int pmain (lua_State *L) { + struct Smain *s = (struct Smain *)lua_touserdata(L, 1); + char **argv = s->argv; + int script; + int has_i = 0, has_v = 0, has_e = 0; + globalL = L; + if (argv[0] && argv[0][0]) progname = argv[0]; + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ + luaL_openlibs(L); /* open libraries */ + lua_gc(L, LUA_GCRESTART, 0); + s->status = handle_luainit(L); + if (s->status != 0) return 0; + script = collectargs(argv, &has_i, &has_v, &has_e); + if (script < 0) { /* invalid args? */ + print_usage(); + s->status = 1; + return 0; + } + if (has_v) print_version(); + s->status = runargs(L, argv, (script > 0) ? script : s->argc); + if (s->status != 0) return 0; + if (script) + s->status = handle_script(L, argv, script); + if (s->status != 0) return 0; + if (has_i) + dotty(L); + else if (script == 0 && !has_e && !has_v) { + if (lua_stdin_is_tty()) { + print_version(); + dotty(L); + } + else dofile(L, NULL); /* executes stdin as a file */ + } + return 0; +} + + +int main (int argc, char **argv) { + int status; + struct Smain s; + lua_State *L = lua_open(); /* create state */ + if (L == NULL) { + l_message(argv[0], "cannot create state: not enough memory"); + return EXIT_FAILURE; + } + s.argc = argc; + s.argv = argv; + status = lua_cpcall(L, &pmain, &s); + report(L, status); + lua_close(L); + return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/external/lua/lua/lua.h b/external/lua/lua/lua.h index a4b73e743e..e4bdfd3b94 100644 --- a/external/lua/lua/lua.h +++ b/external/lua/lua/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $ +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -17,9 +17,9 @@ #define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.5" +#define LUA_RELEASE "Lua 5.1.4" #define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" @@ -362,7 +362,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/external/lua/lua/lvm.c b/external/lua/lua/lvm.c index e0a0cd8521..ee3256ab94 100644 --- a/external/lua/lua/lvm.c +++ b/external/lua/lua/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $ +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -133,7 +133,6 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { int loop; - TValue temp; for (loop = 0; loop < MAXTAGLOOP; loop++) { const TValue *tm; if (ttistable(t)) { /* `t' is a table? */ @@ -142,7 +141,6 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { if (!ttisnil(oldval) || /* result is no nil? */ (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ setobj2t(L, oldval, val); - h->flags = 0; luaC_barriert(L, h, val); return; } @@ -154,9 +152,7 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { callTM(L, tm, t, key, val); return; } - /* else repeat with `tm' */ - setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */ - t = &temp; + t = tm; /* else repeat with `tm' */ } luaG_runerror(L, "loop in settable"); } diff --git a/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id b/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id new file mode 100644 index 0000000000..1133a98d05 --- /dev/null +++ b/external/lua/lua/prebuilt/ios/liblua.a.REMOVED.git-id @@ -0,0 +1 @@ +a064ce4dee79c042cebd3ab706673cd2a7bc4a4e \ No newline at end of file diff --git a/external/png/prebuilt/ios/libpng.a.REMOVED.git-id b/external/png/prebuilt/ios/libpng.a.REMOVED.git-id index adbc13a75d..2d0321bd96 100644 --- a/external/png/prebuilt/ios/libpng.a.REMOVED.git-id +++ b/external/png/prebuilt/ios/libpng.a.REMOVED.git-id @@ -1 +1 @@ -2a8128e7d552dc8b2d79c1cbd8c84c21ad578672 \ No newline at end of file +c4decf3cb39b46189df24c54868f46e985b15de2 \ No newline at end of file diff --git a/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id b/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..9907c43b6c --- /dev/null +++ b/external/png/prebuilt/ios/libpng_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +13d38a8f7cf04ee464b3eaf5fd7464853499390e \ No newline at end of file diff --git a/external/png/prebuilt/mac/libpng.a.REMOVED.git-id b/external/png/prebuilt/mac/libpng.a.REMOVED.git-id index 9d858ddb88..a3f9f5fe04 100644 --- a/external/png/prebuilt/mac/libpng.a.REMOVED.git-id +++ b/external/png/prebuilt/mac/libpng.a.REMOVED.git-id @@ -1 +1 @@ -fb78024e2f81c33d196af83e7740de7c7f4ea021 \ No newline at end of file +373f86ef034bf18f5d52588747c02d7896884730 \ No newline at end of file diff --git a/external/tiff/include/ios/tiffconf.h b/external/tiff/include/ios/tiffconf.h index 4322c323af..9a53f1497b 100644 --- a/external/tiff/include/ios/tiffconf.h +++ b/external/tiff/include/ios/tiffconf.h @@ -15,7 +15,7 @@ #define TIFF_INT32_T signed int /* Signed 64-bit type */ -#define TIFF_INT64_T signed long long +#define TIFF_INT64_T int64_t /* Signed 8-bit type */ #define TIFF_INT8_T signed char @@ -27,7 +27,7 @@ #define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ -#define TIFF_UINT64_T unsigned long long +#define TIFF_UINT64_T uint64_t /* Unsigned 8-bit type */ #define TIFF_UINT8_T unsigned char diff --git a/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id b/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id index 1305bb3f84..75a747bf14 100644 --- a/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id +++ b/external/tiff/prebuilt/ios/libtiff.a.REMOVED.git-id @@ -1 +1 @@ -60433133a48054eb884d9e6a0cee95fe4ba22b1c \ No newline at end of file +286c39ddabb05b91c81ee5d7ec0a1301d0be3108 \ No newline at end of file diff --git a/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id b/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..2a9acad1ea --- /dev/null +++ b/external/tiff/prebuilt/ios/libtiff_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +39aa0b352df6cb1adf2390cf199910b21a3b3c12 \ No newline at end of file diff --git a/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id b/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id index 4cc30a45bb..89f7a5119a 100644 --- a/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id +++ b/external/tiff/prebuilt/mac/libtiff.a.REMOVED.git-id @@ -1 +1 @@ -5fe8aca7e0bfa91c79b4b6b0a562f88a6653c452 \ No newline at end of file +e5cd88ead5723950d6f69e8bd72b4b18b2f9d893 \ No newline at end of file diff --git a/external/version.txt b/external/version.txt new file mode 100644 index 0000000000..bdd7244465 --- /dev/null +++ b/external/version.txt @@ -0,0 +1,9 @@ +libs version +——————————————————— +freetype 2.5.0 +curl 7.26.0 +jpeg 9.0 +png 1.6.2 +tiff 4.0.3 +webp 0.2.1 +websockets v1.23-chrome32-firefox24 \ No newline at end of file diff --git a/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id b/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id index f782a7af53..46ccff2586 100644 --- a/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id +++ b/external/webp/prebuilt/ios/libwebp.a.REMOVED.git-id @@ -1 +1 @@ -c26c3c22887023d322926dcbbd0f69377deedaf8 \ No newline at end of file +7f9f32e81cbd068ab7a9c408a26eedfdcc8d6e30 \ No newline at end of file diff --git a/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id b/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id new file mode 100644 index 0000000000..c5dff9b151 --- /dev/null +++ b/external/webp/prebuilt/ios/libwebp_arm64.a.REMOVED.git-id @@ -0,0 +1 @@ +904e2e16f2f4846b4550b9ba25e8b709f6c4337e \ No newline at end of file diff --git a/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id b/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id index 7a441fa135..fb37e15f1a 100644 --- a/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id +++ b/external/webp/prebuilt/mac/libwebp.a.REMOVED.git-id @@ -1 +1 @@ -4c5c7d34a90f5fcac954f6d44803173224d8ead2 \ No newline at end of file +6b5decfe3f5b19bacfbd9778cb58843a7161a6a9 \ No newline at end of file diff --git a/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id b/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id index 08dc34e960..51c418cdb9 100644 --- a/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id +++ b/external/websockets/prebuilt/ios/libwebsockets.a.REMOVED.git-id @@ -1 +1 @@ -ee4ee6cc26274f6d3138d08d429d6ba49b629f53 \ No newline at end of file +5c60f0b27edd2650caee8a96948272604a8098d5 \ No newline at end of file diff --git a/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id b/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id index bdf504bf24..0badadb7b2 100644 --- a/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id +++ b/external/websockets/prebuilt/mac/libwebsockets.a.REMOVED.git-id @@ -1 +1 @@ -5d0743ce07a9c865d4367d8e3db161148676f2c8 \ No newline at end of file +36c2d4cb652d9a93fa2a285cb8c73f237612bb46 \ No newline at end of file diff --git a/setup.py b/setup.py index f3feb4b830..da1948c713 100755 --- a/setup.py +++ b/setup.py @@ -87,19 +87,6 @@ class SetEnvVar(object): return file_to_write - def _update_system_variable(self, origin_content, target_content): - - is_updated = False - file = open(self.file_used_for_setup, 'a') - for line in fileinput.input(file_to_write, inplace=1): - if line.startswith(origin_content): - line = target_content - if_undated = True - sys.stdout.write(line) - - file.close() - return is_updated - def _find_string_in_file(self, string, file_path): with open(file_path) as f: for line in f: @@ -118,7 +105,9 @@ class SetEnvVar(object): 0, _winreg.KEY_SET_VALUE | _winreg.KEY_READ) _winreg.SetValueEx(env, key, 0, _winreg.REG_SZ, value) + _winreg.FlushKey(env) _winreg.CloseKey(env) + except Exception: if env: _winreg.CloseKey(env) @@ -271,7 +260,10 @@ class SetEnvVar(object): if not android_sdk_root: return False - android_path = os.path.join(android_sdk_root, 'tools/android') + if self._isWindows(): + android_path = os.path.join(android_sdk_root, 'tools/android.bat') + else: + android_path = os.path.join(android_sdk_root, 'tools/android') if os.path.isfile(android_path): return True else: @@ -281,7 +273,7 @@ class SetEnvVar(object): ant_path = '' if self._isWindows(): - ant_path = os.path.join(ant_root, 'ant.exe') + ant_path = os.path.join(ant_root, 'ant.bat') else: ant_path = os.path.join(ant_root, 'ant') @@ -290,6 +282,35 @@ class SetEnvVar(object): else: return False + def set_windows_path(self, cocos_consle_root): + import _winreg + try: + env = None + path = None + env = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, + 'Environment', + 0, + _winreg.KEY_SET_VALUE | _winreg.KEY_READ) + path = _winreg.QueryValueEx(env, 'Path')[0] + path = path + ';' + cocos_consle_root + path.replace('/', '\\') + _winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path) + _winreg.FlushKey(env) + _winreg.CloseKey(env) + + except Exception: + if not path: + path = cocos_consle_root.replace('/', '\\') + _winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path) + _winreg.FlushKey(env) + else: + _winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path) + _winreg.FlushKey(env) + if env: + _winreg.CloseKey(env) + return False + return True + def set_console_root(self): @@ -297,6 +318,8 @@ class SetEnvVar(object): print '-> Adding COCOS2D_CONSOLE_ROOT environment variable...', if not self._find_environment_variable(COCOS_CONSOLE_ROOT): cocos_consle_root = os.path.join(self.current_absolute_path, 'tools/cocos2d-console/bin') + if self._isWindows(): + self.set_windows_path(cocos_consle_root) if self._set_environment_variable(COCOS_CONSOLE_ROOT, cocos_consle_root): print 'OK' print ' -> Added: %s = %s' % (COCOS_CONSOLE_ROOT, cocos_consle_root) @@ -328,7 +351,7 @@ class SetEnvVar(object): ndk_root = self._get_input_value() if ndk_root and not self._is_ndk_root_valid(ndk_root) and not ndk_root_found: - print 'Error: %s is not a valid path of NDK_ROOT. Ignoring it.' % ndk_root + print 'Error: "%s" is not a valid path of NDK_ROOT. Ignoring it.' % ndk_root if ndk_root_found: print 'FOUND' @@ -354,7 +377,7 @@ class SetEnvVar(object): android_sdk_root = self._get_input_value() if android_sdk_root and not self._is_android_sdk_root_valid(android_sdk_root) and not android_sdk_root_found: - print 'Error: %s is not a valid path of ANDROID_SDK_ROOT. Ignoring it.' % android_sdk_root + print 'Error: "%s" is not a valid path of ANDROID_SDK_ROOT. Ignoring it.' % android_sdk_root if android_sdk_root_found: print 'FOUND' @@ -378,7 +401,7 @@ class SetEnvVar(object): ant_root = self._get_input_value() if ant_root and not self._is_ant_root_valid(ant_root) and not ant_found: - print 'Error: %s is not a valid path of ANT_ROOT. Ignoring it.' % ant_root + print 'Error: "%s" is not a valid path of ANT_ROOT. Ignoring it.' % ant_root if ant_found: @@ -410,7 +433,7 @@ class SetEnvVar(object): print '\nCOCOS_CONSOLE_ROOT was already added. Edit "%s" for manual changes' % target if self._isWindows(): - print '\nPlease restart the terminal to make added system variables take effect' + print '\nPlease restart the terminal or restart computer to make added system variables take effect' else: print '\nPlease execute command: "source %s" to make added system variables take effect' % target @@ -418,7 +441,7 @@ if __name__ == '__main__': parser = OptionParser() parser.add_option('-n', '--ndkroot', dest='ndk_root', help='directory of ndk root') parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root') - parser.add_option('-t', '--antroot', dest='ant_root', help='directory of ant root') + parser.add_option('-t', '--antroot', dest='ant_root', help='directory that contains ant/ant.bat') opts, args = parser.parse_args() # set environment variables diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index dc63ffbac6..5bd936f744 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -879acef60464ae6a0af99e8e5d809245f8cdbe56 \ No newline at end of file +4dfa7f46c2e06a4b3b95120bea3b8689f31ddad0 \ No newline at end of file diff --git a/templates/lua-template-default/frameworks/CMakeLists.txt b/templates/lua-template-default/frameworks/CMakeLists.txt new file mode 100644 index 0000000000..33c9f28fc9 --- /dev/null +++ b/templates/lua-template-default/frameworks/CMakeLists.txt @@ -0,0 +1,182 @@ +cmake_minimum_required(VERSION 2.6) + +set(APP_NAME HelloLua) +project (${APP_NAME}) + +include(cocos2d-x/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 + runtime-src/proj.linux/main.cpp + runtime-src/Classes/AppDelegate.cpp +) + +set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d-x) + +include_directories( + /usr/include + /usr/include/GLFW + /usr/local/include/GLFW + runtime-src/Classes + ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/manual + ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/auto + ${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/renderer + ${COCOS2D_ROOT}/cocos/2d/platform + ${COCOS2D_ROOT}/cocos/2d/platform/desktop + ${COCOS2D_ROOT}/cocos/2d/platform/linux + ${COCOS2D_ROOT}/cocos/base + ${COCOS2D_ROOT}/cocos/physics + ${COCOS2D_ROOT}/cocos/editor-support + ${COCOS2D_ROOT}/cocos/math/kazmath + ${COCOS2D_ROOT}/extensions + ${COCOS2D_ROOT}/external + ${COCOS2D_ROOT}/external/edtaa3func + ${COCOS2D_ROOT}/external/jpeg/include/linux + ${COCOS2D_ROOT}/external/tiff/include/linux + ${COCOS2D_ROOT}/external/webp/include/linux + ${COCOS2D_ROOT}/external/websockets/include/linux + ${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}/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/websockets/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR} + ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} +) + +# kazmath +add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath) + +# chipmunk library +add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src) + +# box2d library +add_subdirectory(${COCOS2D_ROOT}/external/Box2D) + +# unzip library +add_subdirectory(${COCOS2D_ROOT}/external/unzip) + +# tinyxml2 library +add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2) + +# audio +add_subdirectory(${COCOS2D_ROOT}/cocos/audio) + +# cocos base library +add_subdirectory(${COCOS2D_ROOT}/cocos/base) + +# cocos 2d library +add_subdirectory(${COCOS2D_ROOT}/cocos/2d) + +# gui +add_subdirectory(${COCOS2D_ROOT}/cocos/ui) + +# network +add_subdirectory(${COCOS2D_ROOT}/cocos/network) + +# extensions +add_subdirectory(${COCOS2D_ROOT}/extensions) + +## Editor Support + +# spine +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine) + +# cocosbuilder +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder) + +# cocostudio +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio) + +## Scripting +# lua +add_subdirectory(${COCOS2D_ROOT}/external/lua/lua) + +# tolua +add_subdirectory(${COCOS2D_ROOT}/external/lua/tolua) + +# luabinding +add_subdirectory(${COCOS2D_ROOT}/cocos/scripting/lua-bindings) + +# 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 + ui + network + spine + cocostudio + cocosbuilder + extensions + audio + cocos2d + ) + +set(APP_BIN_DIR "${CMAKE_BINARY_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}/../res ${APP_BIN_DIR}/Resources/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/Resources/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script ${APP_BIN_DIR}/Resources + ) + diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp new file mode 100644 index 0000000000..e420889600 --- /dev/null +++ b/templates/lua-template-default/frameworks/runtime-src/proj.linux/main.cpp @@ -0,0 +1,16 @@ +#include "../Classes/AppDelegate.h" +#include "cocos2d.h" + +#include +#include +#include +#include + +USING_NS_CC; + +int main(int argc, char **argv) +{ + // create the application instance + AppDelegate app; + return Application::getInstance()->run(); +} diff --git a/templates/lua-template-default/res/background.caf.REMOVED.git-id b/templates/lua-template-default/res/background.caf.REMOVED.git-id new file mode 100644 index 0000000000..d8be9c833d --- /dev/null +++ b/templates/lua-template-default/res/background.caf.REMOVED.git-id @@ -0,0 +1 @@ +5d7d0b8ce9780883a780ee5fd9e9317129b41643 \ No newline at end of file diff --git a/templates/lua-template-default/src/main.lua b/templates/lua-template-default/src/main.lua index 32bad3df7e..ec894a7787 100644 --- a/templates/lua-template-default/src/main.lua +++ b/templates/lua-template-default/src/main.lua @@ -204,8 +204,12 @@ local function main() -- play background music, preload effect -- uncomment below for the BlackBerry version - -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg") - local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") + local bgMusicPath = nil + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then + bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.caf") + else + bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3") + end cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true) local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath) diff --git a/templates/lua-template-runtime/.buildpath b/templates/lua-template-runtime/.buildpath new file mode 100644 index 0000000000..53ba323fe6 --- /dev/null +++ b/templates/lua-template-runtime/.buildpath @@ -0,0 +1,4 @@ + + + + diff --git a/templates/lua-template-runtime/.project b/templates/lua-template-runtime/.project new file mode 100644 index 0000000000..12fd28f45b --- /dev/null +++ b/templates/lua-template-runtime/.project @@ -0,0 +1,13 @@ + + + CocosGame + + + + + + + org.ccdt.cocosproject + org.eclipse.koneki.ldt.nature + + diff --git a/templates/lua-template-runtime/res/background.caf.REMOVED.git-id b/templates/lua-template-runtime/res/background.caf.REMOVED.git-id new file mode 100644 index 0000000000..d8be9c833d --- /dev/null +++ b/templates/lua-template-runtime/res/background.caf.REMOVED.git-id @@ -0,0 +1 @@ +5d7d0b8ce9780883a780ee5fd9e9317129b41643 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/android/PrebuiltRuntimeLua.apk.REMOVED.git-id b/templates/lua-template-runtime/runtime/android/PrebuiltRuntimeLua.apk.REMOVED.git-id new file mode 100644 index 0000000000..19e22f2887 --- /dev/null +++ b/templates/lua-template-runtime/runtime/android/PrebuiltRuntimeLua.apk.REMOVED.git-id @@ -0,0 +1 @@ +b6ad138951e439ad072da264df619cc7321f46c6 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default-568h@2x.png.REMOVED.git-id b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default-568h@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8f5838f3a8 --- /dev/null +++ b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default-568h@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +66c6d1cead373b45218424f6a82f370897e443e4 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default@2x.png.REMOVED.git-id b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default@2x.png.REMOVED.git-id new file mode 100644 index 0000000000..8843505b20 --- /dev/null +++ b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/Default@2x.png.REMOVED.git-id @@ -0,0 +1 @@ +84689888a14a2123d2b39f7f2f61be8c15207479 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PkgInfo b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PkgInfo new file mode 100644 index 0000000000..bd04210fb4 --- /dev/null +++ b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PkgInfo @@ -0,0 +1 @@ +APPL???? \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PrebuiltRuntimeLua iOS.REMOVED.git-id b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PrebuiltRuntimeLua iOS.REMOVED.git-id new file mode 100644 index 0000000000..bb065b2804 --- /dev/null +++ b/templates/lua-template-runtime/runtime/ios/PrebuiltRuntimeLua.app/PrebuiltRuntimeLua iOS.REMOVED.git-id @@ -0,0 +1 @@ +1ffd33761a672e4eb19b2ea7b540523e6b326a14 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/MacOS/PrebuiltRuntimeLua Mac.REMOVED.git-id b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/MacOS/PrebuiltRuntimeLua Mac.REMOVED.git-id new file mode 100644 index 0000000000..c1d69d4c62 --- /dev/null +++ b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/MacOS/PrebuiltRuntimeLua Mac.REMOVED.git-id @@ -0,0 +1 @@ +31b1a0d01d2ab46a60ad179417cdeb24a4e143c8 \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/PkgInfo b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/PkgInfo new file mode 100644 index 0000000000..bd04210fb4 --- /dev/null +++ b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/PkgInfo @@ -0,0 +1 @@ +APPL???? \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/Icon.icns.REMOVED.git-id b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/Icon.icns.REMOVED.git-id new file mode 100644 index 0000000000..0c90afdb6d --- /dev/null +++ b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/Icon.icns.REMOVED.git-id @@ -0,0 +1 @@ +2040fc6fe624353ae1d3db50cd3d450f4fda5afc \ No newline at end of file diff --git a/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/MainMenu.nib b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/MainMenu.nib new file mode 100644 index 0000000000..af8ea56631 Binary files /dev/null and b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/MainMenu.nib differ diff --git a/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/WorkSpaceDialog.nib b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/WorkSpaceDialog.nib new file mode 100644 index 0000000000..66abf393b8 Binary files /dev/null and b/templates/lua-template-runtime/runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/WorkSpaceDialog.nib differ diff --git a/templates/lua-template-runtime/runtime/win32/PrebuiltRuntimeLua.exe.REMOVED.git-id b/templates/lua-template-runtime/runtime/win32/PrebuiltRuntimeLua.exe.REMOVED.git-id new file mode 100644 index 0000000000..c94ed670ae --- /dev/null +++ b/templates/lua-template-runtime/runtime/win32/PrebuiltRuntimeLua.exe.REMOVED.git-id @@ -0,0 +1 @@ +129179ac926a4f511943ffc9ea7f36161dcaed0c \ No newline at end of file diff --git a/templates/lua-template-runtime/src/main.lua b/templates/lua-template-runtime/src/main.lua index 32bad3df7e..808b6061e6 100644 --- a/templates/lua-template-runtime/src/main.lua +++ b/templates/lua-template-runtime/src/main.lua @@ -17,8 +17,6 @@ local function main() -- avoid memory leak collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) - cc.FileUtils:getInstance():addSearchResolutionsOrder("src"); - cc.FileUtils:getInstance():addSearchResolutionsOrder("res"); local schedulerID = 0 --support debug local targetPlatform = cc.Application:getInstance():getTargetPlatform() @@ -29,7 +27,7 @@ local function main() --require('debugger')() end - require "hello2" + require "src/hello2" cclog("result is " .. myadd(1, 1)) --------------- @@ -43,7 +41,7 @@ local function main() local frameHeight = 95 -- create dog animate - local textureDog = cc.TextureCache:getInstance():addImage("dog.png") + local textureDog = cc.TextureCache:getInstance():addImage("res/dog.png") local rect = cc.rect(0, 0, frameWidth, frameHeight) local frame0 = cc.SpriteFrame:createWithTexture(textureDog, rect) rect = cc.rect(frameWidth, 0, frameWidth, frameHeight) @@ -86,21 +84,21 @@ local function main() local layerFarm = cc.Layer:create() -- add in farm background - local bg = cc.Sprite:create("farm.jpg") + local bg = cc.Sprite:create("res/farm.jpg") bg:setPosition(origin.x + visibleSize.width / 2 + 80, origin.y + visibleSize.height / 2) layerFarm:addChild(bg) -- add land sprite for i = 0, 3 do for j = 0, 1 do - local spriteLand = cc.Sprite:create("land.png") + local spriteLand = cc.Sprite:create("res/land.png") spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) layerFarm:addChild(spriteLand) end end -- add crop - local frameCrop = cc.SpriteFrame:create("crop.png", cc.rect(0, 0, 105, 95)) + local frameCrop = cc.SpriteFrame:create("res/crop.png", cc.rect(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do local spriteCrop = cc.Sprite:createWithSpriteFrame(frameCrop); @@ -117,7 +115,7 @@ local function main() local touchBeginPoint = nil local function onTouchBegan(touch, event) local location = touch:getLocation() - cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y) + --cclog("onTouchBegan: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = {x = location.x, y = location.y} spriteDog.isPaused = true -- CCTOUCHBEGAN event must return true @@ -126,7 +124,7 @@ local function main() local function onTouchMoved(touch, event) local location = touch:getLocation() - cclog("onTouchMoved: %0.2f, %0.2f", location.x, location.y) + --cclog("onTouchMoved: %0.2f, %0.2f", location.x, location.y) if touchBeginPoint then local cx, cy = layerFarm:getPosition() layerFarm:setPosition(cx + location.x - touchBeginPoint.x, @@ -137,7 +135,7 @@ local function main() local function onTouchEnded(touch, event) local location = touch:getLocation() - cclog("onTouchEnded: %0.2f, %0.2f", location.x, location.y) + --cclog("onTouchEnded: %0.2f, %0.2f", location.x, location.y) touchBeginPoint = nil spriteDog.isPaused = false end @@ -174,13 +172,13 @@ local function main() local function menuCallbackOpenPopup() -- loop test sound effect - local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") + local effectPath = cc.FileUtils:getInstance():fullPathForFilename("res/effect1.wav") effectID = cc.SimpleAudioEngine:getInstance():playEffect(effectPath) menuPopup:setVisible(true) end -- add a popup menu - local menuPopupItem = cc.MenuItemImage:create("menu2.png", "menu2.png") + local menuPopupItem = cc.MenuItemImage:create("res/menu2.png", "res/menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptTapHandler(menuCallbackClosePopup) menuPopup = cc.Menu:create(menuPopupItem) @@ -189,7 +187,7 @@ local function main() layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = cc.MenuItemImage:create("menu1.png", "menu1.png") + local menuToolsItem = cc.MenuItemImage:create("res/menu1.png", "res/menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptTapHandler(menuCallbackOpenPopup) menuTools = cc.Menu:create(menuToolsItem) @@ -205,9 +203,9 @@ local function main() -- uncomment below for the BlackBerry version -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg") - local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("background.mp3") + local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3") cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true) - local effectPath = cc.FileUtils:getInstance():fullPathForFilename("effect1.wav") + local effectPath = cc.FileUtils:getInstance():fullPathForFilename("res/effect1.wav") cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath) -- run diff --git a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 6ebcc144cc..d7115d58fb 100644 --- a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -16,6 +16,8 @@ #define MUSIC_FILE "music.mid" #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX ) #define MUSIC_FILE "background.ogg" +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + #define MUSIC_FILE "background.caf" #else #define MUSIC_FILE "background.mp3" #endif // CC_PLATFOR_WIN32 diff --git a/tests/cpp-tests/Resources/background.caf.REMOVED.git-id b/tests/cpp-tests/Resources/background.caf.REMOVED.git-id new file mode 100644 index 0000000000..d8be9c833d --- /dev/null +++ b/tests/cpp-tests/Resources/background.caf.REMOVED.git-id @@ -0,0 +1 @@ +5d7d0b8ce9780883a780ee5fd9e9317129b41643 \ No newline at end of file diff --git a/tests/lua-empty-test/res/background.caf.REMOVED.git-id b/tests/lua-empty-test/res/background.caf.REMOVED.git-id new file mode 100644 index 0000000000..d8be9c833d --- /dev/null +++ b/tests/lua-empty-test/res/background.caf.REMOVED.git-id @@ -0,0 +1 @@ +5d7d0b8ce9780883a780ee5fd9e9317129b41643 \ No newline at end of file diff --git a/tests/lua-empty-test/src/hello.lua b/tests/lua-empty-test/src/hello.lua index 5bb47e5805..2916f16686 100644 --- a/tests/lua-empty-test/src/hello.lua +++ b/tests/lua-empty-test/src/hello.lua @@ -17,7 +17,7 @@ local function main() collectgarbage("setpause", 100) collectgarbage("setstepmul", 5000) - --support debug + --support debug,when used on ios7.1 64bit,these codes should be commented local targetPlatform = cc.Application:getInstance():getTargetPlatform() if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform) or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or @@ -193,8 +193,13 @@ local function main() -- play background music, preload effect -- uncomment below for the BlackBerry version - -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.ogg") - local bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3") + local bgMusicPath = nil + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then + bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("res/background.caf") + else + bgMusicPath = cc.FileUtils:getInstance():fullPathForFilename("res/background.mp3") + end + cc.SimpleAudioEngine:getInstance():playMusic(bgMusicPath, true) local effectPath = cc.FileUtils:getInstance():fullPathForFilename("res/effect1.wav") cc.SimpleAudioEngine:getInstance():preloadEffect(effectPath) diff --git a/tests/lua-tests/project/proj.android/src/org/cocos2dx/testlua/Cocos2dxActivity.java b/tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/Cocos2dxActivity.java similarity index 100% rename from tests/lua-tests/project/proj.android/src/org/cocos2dx/testlua/Cocos2dxActivity.java rename to tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/Cocos2dxActivity.java diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua index 0fbe58efca..85d57230b9 100644 --- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua +++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua @@ -31,7 +31,7 @@ function AssetManagerModule.newScene(backfunc) helloLabel:setPosition(cc.p(winSize.width / 2, winSize.height - 40)) layer:addChild(helloLabel, 5) - local sprite = cc.Sprite:create("background.png") + local sprite = cc.Sprite:create("Images/background.png") sprite:setAnchorPoint(cc.p(0.5, 0.5)) sprite:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) layer:addChild(sprite, 0) diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua index eecbf1b83e..e0c1108ea7 100644 --- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua +++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua @@ -100,7 +100,8 @@ local function updateLayer() local function enter(sender) if not isUpdateItemClicked then - addSearchPath(pathToSave,true) + local realPath = pathToSave .. "/package" + addSearchPath(realPath,true) end assetsManagerModule = reloadModule("src/AssetsManagerTest/AssetsManagerModule") diff --git a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua index 89ec9223d8..36d054a636 100644 --- a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua +++ b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua @@ -1,6 +1,13 @@ require "AudioEngine" local EFFECT_FILE = "effect1.wav" -local MUSIC_FILE = "background.mp3" + +local MUSIC_FILE = nil +local targetPlatform = cc.Application:getInstance():getTargetPlatform() +if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then + MUSIC_FILE = "background.caf" +else + MUSIC_FILE = "background.mp3" +end local LINE_SPACE = 40 diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 8afcc3bcda..77336f3475 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -149,6 +149,10 @@ function CreateTestMenu() CloseMenu:setPosition(0, 0) CloseMenu:addChild(CloseItem) menuLayer:addChild(CloseMenu) + local targetPlatform = cc.Application:getInstance():getTargetPlatform() + if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then + CloseMenu:setVisible(false) + end -- add menu items for tests local MainMenu = cc.Menu:create() diff --git a/tools/bindings-generator b/tools/bindings-generator index cd30a5b87d..34dfbf6497 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit cd30a5b87d5c9b6fdbd57cdc5a9213bcb975f65b +Subproject commit 34dfbf64971a955995fe9762ab33ddbf907a1be3 diff --git a/tools/cocos2d-console b/tools/cocos2d-console index f52d834ee7..67d0fd2ed7 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f52d834ee7b4f412f7b972ef484a0e406ce6c1fd +Subproject commit 67d0fd2ed79e5f7d52b797af897bf5cc23ef7994 diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py new file mode 100755 index 0000000000..2c67ab746d --- /dev/null +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -0,0 +1,87 @@ +#!/usr/bin/python +#create new project by cocos-console +#build new project and run + +import os +import sys + +project_types = ['cpp', 'lua'] +PROJ_SUFFIX = 'Proj' +phonePlats = ['mac','ios','android'] + +cocos_console_dir = 'tools/cocos2d-console/bin/' + +#now cocos2d-console suport different run on Platforms, e.g: only run android on win +runSupport = { + 'darwin' : [1, 1, 1], + 'win' : [0, 0, 1], + 'linux' : [0, 0, 1] +} + +_argvs = sys.argv +print 'input argvs:', _argvs[1], _argvs[2] +_will_create = False +_will_run = False +if _argvs[1]=='create' || _argvs[2]=='create': + _will_create = True +if _argvs[1]=='run' || _argvs[2]=='run': + _will_create = True + _will_run = True +if _will_create == False and _will_run == False: + _will_create = True + _will_run = True + +curPlat = sys.platform +if curPlat.find('linux') >= 0: + curPlat = 'linux' +elif curPlat.find('darwin') >= 0: + curPlat = 'darwin' +else: + curPlat = 'win' +print 'current platform is:', curPlat + +def clean_project(): + for proj in project_types: + cmd = 'rm -rf '+proj+PROJ_SUFFIX + os.system(cmd) + +def create_project(): + print 'will create_project: ' + idx = 0 + for proj in project_types: + print 'proj: ', proj + cmd = 'cocos new -l '+proj+' '+proj+PROJ_SUFFIX + print proj,'cmd:',cmd + idx += 1 + info_create = os.system(cmd) #call cmd on win is diff + print 'create project',proj,' is:', not info_create +def build_run(): + print 'will build and run' + for proj in project_types: + idx = 0 + for phone in phonePlats: + cmd = 'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX + print proj,'cmd:',cmd + if runSupport[curPlat][idx]: + info_run = os.system(cmd) + print 'run project', proj, 'is:', not info_run + idx += 1 + +def main(): + if _will_create: + clean_project() + create_project() + if _will_run: + build_run() + +# -------------- main -------------- +if __name__ == '__main__': + sys_ret = 0 + try: + sys_ret = main() + except: + traceback.print_exc() + sys_ret = 1 + finally: + sys.exit(sys_ret) + diff --git a/tools/jenkins-scripts/watchdog.py b/tools/jenkins-scripts/watchdog.py new file mode 100644 index 0000000000..feff7a3731 --- /dev/null +++ b/tools/jenkins-scripts/watchdog.py @@ -0,0 +1,58 @@ +import jenkinsapi +from jenkinsapi.jenkins import Jenkins +import sys +import time +import os + +#check & kill dead buid +def build_time(_job): + #get jenkins-job-watchdog-threshold + threshold = os.environ['jenkins-job-watchdog-threshold'] + #Get last build running + build = _job.get_last_build() + running = build.is_running() + print 'build_job:',_job,'running:',running + if not running: + return False + + #Get numerical ID of the last build. + buildnu = _job.get_last_buildnumber() + print "buildnumber:#",buildnu + #get nowtime + nowtime = time.strftime('%M',time.localtime(time.time())) + #print 'nowtime:',nowtime + #get build start time + timeb = build.get_timestamp() + #print 'buildtime:',str(timeb)[14:16] + buildtime = int(str(timeb)[14:16]) + subtime = 0 + if int(nowtime) >= buildtime: + subtime = int(nowtime)-buildtime + else: + subtime = 60-buildtime+int(nowtime) + if subtime > threshold: + #print 'subtime',subtime + #kill dead buid + build.stop() + +def main(): + username = os.environ['username'] + password = os.environ['password'] + J = Jenkins('http://115.28.134.83:8000',username,password) + #get all jenkins jobs + for key,job in J.iteritems(): + build_time(job) + return(0) + + +# -------------- main -------------- +if __name__ == '__main__': + sys_ret = 0 + try: + sys_ret = main() + except: + traceback.print_exc() + sys_ret = 1 + finally: + sys.exit(sys_ret) + diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 57a9d5b369..9bdfe727ba 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -48,7 +48,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased], Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], MenuItem.*::[create setCallback initWithCallback], - Label::[getLettersInfo createWithTTF setTTFConfig], + Label::[getLettersInfo createWithTTF setTTFConfig listenToBackground listenToFontAtlasPurge], Copying::[*], LabelProtocol::[*], LabelTextFormatProtocol::[*], diff --git a/tools/tolua/cocos2dx_ui.ini b/tools/tolua/cocos2dx_ui.ini index 538a46cfb0..68e1978ca5 100644 --- a/tools/tolua/cocos2dx_ui.ini +++ b/tools/tolua/cocos2dx_ui.ini @@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter +classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.* # 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