diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index ab2ded7344..4de5987c79 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -152,12 +152,8 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up) Quaternion quaternion; Quaternion::createFromRotationMatrix(rotation,&quaternion); - - float rotx = atan2f(2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z), 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y)); - float roty = asin(clampf(2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x) , -1.0f , 1.0f)); - float rotz = -atan2(2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y) , 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z)); - - setRotation3D(Vec3(CC_RADIANS_TO_DEGREES(rotx),CC_RADIANS_TO_DEGREES(roty),CC_RADIANS_TO_DEGREES(rotz))); + quaternion.normalize(); + setRotationQuat(quaternion); } const Mat4& Camera::getViewProjectionMatrix() const diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index f1e674876e..331bed2b27 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -690,7 +690,7 @@ void Label::updateQuads() } if (_lettersInfo[ctr].position.y - letterDef.height < 0.f) { - _reusedRect.size.height = _lettersInfo[ctr].position.y; + _reusedRect.size.height = _lettersInfo[ctr].position.y < 0.f ? 0.f : _lettersInfo[ctr].position.y; } _reusedLetter->setTextureRect(_reusedRect,false,_reusedRect.size); diff --git a/cocos/audio/winrt/Audio.cpp b/cocos/audio/winrt/Audio.cpp index 13ed507632..1dd1332b70 100644 --- a/cocos/audio/winrt/Audio.cpp +++ b/cocos/audio/winrt/Audio.cpp @@ -61,11 +61,13 @@ void Audio::Initialize() void Audio::CreateResources() { - try + do { - ThrowIfFailed( - XAudio2Create(&m_musicEngine) - ); + if (FAILED(XAudio2Create(&m_musicEngine))) + { + m_engineExperiencedCriticalError = true; + break; + } #if defined(_DEBUG) XAUDIO2_DEBUG_CONFIGURATION debugConfig = {0}; @@ -83,31 +85,33 @@ void Audio::CreateResources() // decode the data then we feed it through the XAudio2 pipeline as a separate Mastering Voice, so that we can tag it // as Game Media. // We default the mastering voice to 2 channels to simplify the reverb logic. - ThrowIfFailed( - m_musicEngine->CreateMasteringVoice(&m_musicMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia) - ); + if(FAILED(m_musicEngine->CreateMasteringVoice(&m_musicMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia))) + { + m_engineExperiencedCriticalError = true; + break; + } // Create a separate engine and mastering voice for sound effects in the sample // Games will use many voices in a complex graph for audio, mixing all effects down to a // single mastering voice. // We are creating an entirely new engine instance and mastering voice in order to tag // our sound effects with the audio category AudioCategory_GameEffects. - ThrowIfFailed( - XAudio2Create(&m_soundEffectEngine) - ); + if(FAILED(XAudio2Create(&m_soundEffectEngine))) + { + m_engineExperiencedCriticalError = true; + break; + } m_soundEffectEngineCallback.Initialize(this); m_soundEffectEngine->RegisterForCallbacks(&m_soundEffectEngineCallback); // We default the mastering voice to 2 channels to simplify the reverb logic. - ThrowIfFailed( - m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects) - ); - } - catch (...) - { - m_engineExperiencedCriticalError = true; - } + if(FAILED(m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects))) + { + m_engineExperiencedCriticalError = true; + break; + } + } while (false); } unsigned int Audio::Hash(const char *key) @@ -309,9 +313,10 @@ void Audio::PlaySoundEffect(unsigned int sound) StopSoundEffect(sound); - ThrowIfFailed( - m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer) - ); + if (FAILED(m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer))) + { + m_engineExperiencedCriticalError = true; + } if (m_engineExperiencedCriticalError) { // If there's an error, then we'll recreate the engine on the next render pass @@ -560,10 +565,11 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic) sends.SendCount = 1; sends.pSends = descriptors; - ThrowIfFailed( - m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, - &wfx, 0, 1.0f, &m_voiceContext, &sends) - ); + if (FAILED(m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, + &wfx, 0, 1.0f, &m_voiceContext, &sends))) + { + m_engineExperiencedCriticalError = true; + } //fix bug: set a initial volume m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_backgroundMusicVolume); } else @@ -575,10 +581,11 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic) sends.SendCount = 1; sends.pSends = descriptors; - ThrowIfFailed( - m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, - &wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr) - ); + if(FAILED(m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, + &wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr))) + { + m_engineExperiencedCriticalError = true; + } //fix bug: set a initial volume m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_soundEffctVolume); } diff --git a/cocos/audio/winrt/AudioCachePlayer.cpp b/cocos/audio/winrt/AudioCachePlayer.cpp index 0be13433dd..d6dbbd3af5 100644 --- a/cocos/audio/winrt/AudioCachePlayer.cpp +++ b/cocos/audio/winrt/AudioCachePlayer.cpp @@ -311,6 +311,7 @@ void AudioPlayer::setVolume(float volume) bool AudioPlayer::play2d(AudioCache* cache) { bool ret = false; + HRESULT hr = S_OK; if (cache != nullptr) { @@ -323,12 +324,14 @@ bool AudioPlayer::play2d(AudioCache* cache) XAUDIO2_VOICE_SENDS sends = { 0 }; sends.SendCount = 1; sends.pSends = descriptors; - ThrowIfFailed(_xaEngine->CreateSourceVoice(&_xaSourceVoice, &cache->_audInfo._wfx, 0, 1.0, this, &sends)); + hr = _xaEngine->CreateSourceVoice(&_xaSourceVoice, &cache->_audInfo._wfx, 0, 1.0, this, &sends); } - _isStreaming = _cache->isStreamingSource(); - _duration = getDuration(); - ret = _play(); + if (SUCCEEDED(hr)) { + _isStreaming = _cache->isStreamingSource(); + _duration = getDuration(); + ret = _play(); + } } return ret; @@ -336,20 +339,26 @@ bool AudioPlayer::play2d(AudioCache* cache) void AudioPlayer::init() { - memset(&_xaBuffer, 0, sizeof(_xaBuffer)); - ThrowIfFailed(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf())); + do { + memset(&_xaBuffer, 0, sizeof(_xaBuffer)); + if (FAILED(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf()))) { + break; + } #if defined(_DEBUG) - XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 }; - debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; - debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; - _xaEngine->SetDebugConfiguration(&debugConfig); + XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 }; + debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; + debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; + _xaEngine->SetDebugConfiguration(&debugConfig); #endif - _xaEngine->RegisterForCallbacks(this); - ThrowIfFailed(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia)); - _ready = true; - _state = AudioPlayerState::READY; + _xaEngine->RegisterForCallbacks(this); + if (FAILED(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia))) { + break; + } + _ready = true; + _state = AudioPlayerState::READY; + } while (false); } void AudioPlayer::free() diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 0be71ab673..7ef479424c 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -1007,6 +1007,9 @@ void Director::restartDirector() { reset(); + // RenderState need to be reinitialized + RenderState::initialize(); + // Texture cache need to be reinitialized initTextureCache(); diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index b69e0570d2..9bab679e74 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -54,23 +54,23 @@ ComRender::~ComRender(void) void ComRender::onEnter() { - if (_owner != nullptr) + if (_owner != nullptr && _render->getParent() == nullptr) { - _owner->addChild(_render); + _owner->addChild(_render); } } void ComRender::onExit() { - if (_owner != nullptr) + if (_owner != nullptr && _render->getParent() == nullptr) { - _owner->removeChild(_render, true); + _owner->removeChild(_render, true); } } void ComRender::onAdd() { - if (_owner != nullptr) + if (_owner != nullptr && _render->getParent() == nullptr) { _owner->addChild(_render); } @@ -78,7 +78,7 @@ void ComRender::onAdd() void ComRender::onRemove() { - if (_owner != nullptr) + if (_owner != nullptr && _render->getParent() == nullptr) { _owner->removeChild(_render, true); } @@ -104,128 +104,129 @@ void ComRender::setNode(cocos2d::Node *node) } +// TODO: This method is soooo big!! We should refactor it! bool ComRender::serialize(void* r) { - bool ret = false; + bool ret = false; do { CC_BREAK_IF(r == nullptr); - SerData *serData = (SerData *)(r); + SerData *serData = (SerData *)(r); const rapidjson::Value *v = serData->_rData; - stExpCocoNode *cocoNode = serData->_cocoNode; + stExpCocoNode *cocoNode = serData->_cocoNode; CocoLoader *cocoLoader = serData->_cocoLoader; - const char *className = nullptr; - const char *comName = nullptr; - const char *file = nullptr; - const char *plist = nullptr; - std::string filePath; - std::string plistPath; - int resType = 0; - if (v != nullptr) - { - className = DICTOOL->getStringValue_json(*v, "classname"); - CC_BREAK_IF(className == nullptr); - comName = DICTOOL->getStringValue_json(*v, "name"); - const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); - CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); - file = DICTOOL->getStringValue_json(fileData, "path"); - plist = DICTOOL->getStringValue_json(fileData, "plistFile"); - CC_BREAK_IF(file == nullptr && plist == nullptr); - resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); - } - else if(cocoNode != nullptr) - { - className = cocoNode[1].GetValue(cocoLoader); - CC_BREAK_IF(className == nullptr); - comName = cocoNode[2].GetValue(cocoLoader); - stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader); - CC_BREAK_IF(!pfileData); - file = pfileData[0].GetValue(cocoLoader); - plist = pfileData[1].GetValue(cocoLoader); - CC_BREAK_IF(file == nullptr && plist == nullptr); - resType = atoi(pfileData[2].GetValue(cocoLoader)); - } - if (comName != nullptr) - { - setName(comName); - } - else - { - setName(className); - } + const char *className = nullptr; + const char *comName = nullptr; + const char *file = nullptr; + const char *plist = nullptr; + std::string filePath; + std::string plistPath; + int resType = 0; + if (v != nullptr) + { + className = DICTOOL->getStringValue_json(*v, "classname"); + CC_BREAK_IF(className == nullptr); + comName = DICTOOL->getStringValue_json(*v, "name"); + const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); + CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); + file = DICTOOL->getStringValue_json(fileData, "path"); + plist = DICTOOL->getStringValue_json(fileData, "plistFile"); + CC_BREAK_IF(file == nullptr && plist == nullptr); + resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); + } + else if(cocoNode != nullptr) + { + className = cocoNode[1].GetValue(cocoLoader); + CC_BREAK_IF(className == nullptr); + comName = cocoNode[2].GetValue(cocoLoader); + stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader); + CC_BREAK_IF(!pfileData); + file = pfileData[0].GetValue(cocoLoader); + plist = pfileData[1].GetValue(cocoLoader); + CC_BREAK_IF(file == nullptr && plist == nullptr); + resType = atoi(pfileData[2].GetValue(cocoLoader)); + } + if (comName != nullptr) + { + setName(comName); + } + else + { + setName(className); + } - if (file != nullptr) - { - filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); - } - if (plist != nullptr) - { - plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist)); - } - if (resType == 0) - { - if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos)) - { - _render = CCSprite::create(filePath.c_str()); - _render->retain(); + if (file != nullptr) + { + filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); + } + if (plist != nullptr) + { + plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist)); + } + if (resType == 0) + { + if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos)) + { + _render = Sprite::create(filePath.c_str()); + _render->retain(); ret = true; - } - else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos) - { - _render = CCTMXTiledMap::create(filePath.c_str()); - _render->retain(); + } + else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos) + { + _render = TMXTiledMap::create(filePath.c_str()); + _render->retain(); ret = true; - } - else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos) - { - _render = CCParticleSystemQuad::create(filePath.c_str()); - _render->setPosition(0.0f, 0.0f); - _render->retain(); + } + else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos) + { + _render = ParticleSystemQuad::create(filePath.c_str()); + _render->setPosition(0.0f, 0.0f); + _render->retain(); ret = true; - } - else if(strcmp(className, "CCArmature") == 0) - { - std::string file_extension = filePath; - size_t pos = filePath.find_last_of('.'); - if (pos != std::string::npos) - { - file_extension = filePath.substr(pos, filePath.length()); - std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); - } - if (file_extension == ".JSON" || file_extension == ".EXPORTJSON") - { - rapidjson::Document doc; - if(!readJson(filePath.c_str(), doc)) - { - log("read json file[%s] error!\n", filePath.c_str()); - continue; - } - const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0); - const char *name = DICTOOL->getStringValue_json(subData, "name"); - ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); - Armature *pAr = Armature::create(name); - _render = pAr; - _render->retain(); - const char *actionName = nullptr; - if (cocoNode != nullptr) - { - actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname"); - } - else - { - actionName = DICTOOL->getStringValue_json(*v, "selectedactionname"); - } - if (actionName != nullptr && pAr->getAnimation() != nullptr) - { - pAr->getAnimation()->play(actionName); - } + } + else if(strcmp(className, "CCArmature") == 0) + { + std::string file_extension = filePath; + size_t pos = filePath.find_last_of('.'); + if (pos != std::string::npos) + { + file_extension = filePath.substr(pos, filePath.length()); + std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); + } + if (file_extension == ".JSON" || file_extension == ".EXPORTJSON") + { + rapidjson::Document doc; + if(!readJson(filePath.c_str(), doc)) + { + log("read json file[%s] error!\n", filePath.c_str()); + continue; + } + const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0); + const char *name = DICTOOL->getStringValue_json(subData, "name"); + ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); + Armature *pAr = Armature::create(name); + _render = pAr; + _render->retain(); + const char *actionName = nullptr; + if (cocoNode != nullptr) + { + actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname"); + } + else + { + actionName = DICTOOL->getStringValue_json(*v, "selectedactionname"); + } + if (actionName != nullptr && pAr->getAnimation() != nullptr) + { + pAr->getAnimation()->play(actionName); + } ret = true; - } - else if (file_extension == ".CSB") - { + } + else if (file_extension == ".CSB") + { std::string binaryFilePath = FileUtils::getInstance()->fullPathForFilename(filePath.c_str()); auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath); auto fileDataBytes = fileData.getBytes(); @@ -233,10 +234,10 @@ bool ComRender::serialize(void* r) CocoLoader tCocoLoader; if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes)) { - stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode(); - rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); - if (rapidjson::kObjectType == tType) - { + stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode(); + rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); + if (rapidjson::kObjectType == tType) + { int count = tpRootCocoNode->GetChildNum(); stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); for (int i = 0; i < count; ++i) @@ -262,7 +263,7 @@ bool ComRender::serialize(void* r) if (str1 != nullptr) { ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); - Armature *pAr = CCArmature::create(str1); + Armature *pAr = Armature::create(str1); _render = pAr; _render->retain(); const char *actionName = nullptr; @@ -284,75 +285,75 @@ bool ComRender::serialize(void* r) } } } - } - } + } + } else { continue; } - } + } else { continue; } - } - else if(strcmp(className, "GUIComponent") == 0) - { - std::string file_extension = filePath; - size_t pos = filePath.find_last_of('.'); - if (pos != std::string::npos) - { - file_extension = filePath.substr(pos, filePath.length()); - std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); - } - if (file_extension == ".JSON" || file_extension == ".EXPORTJSON") - { + } + else if(strcmp(className, "GUIComponent") == 0) + { + std::string file_extension = filePath; + size_t pos = filePath.find_last_of('.'); + if (pos != std::string::npos) + { + file_extension = filePath.substr(pos, filePath.length()); + std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); + } + if (file_extension == ".JSON" || file_extension == ".EXPORTJSON") + { cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str()); _render = widget; _render->retain(); ret = true; - } - else if (file_extension == ".CSB") - { + } + else if (file_extension == ".CSB") + { cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromBinaryFile(filePath.c_str()); _render = widget; _render->retain(); ret = true; - } - } - else - { - CC_BREAK_IF(true); - } - } - else if (resType == 1) - { - if (strcmp(className, "CCSprite") == 0) - { - std::string strPngFile = plistPath; - std::string::size_type pos = strPngFile.find(".plist"); - if (pos == strPngFile.npos) - { - continue; - } - strPngFile.replace(pos, strPngFile.length(), ".png"); - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); - _render = CCSprite::createWithSpriteFrameName(filePath.c_str()); - _render->retain(); + } + } + else + { + CC_BREAK_IF(true); + } + } + else if (resType == 1) + { + if (strcmp(className, "CCSprite") == 0) + { + std::string strPngFile = plistPath; + std::string::size_type pos = strPngFile.find(".plist"); + if (pos == strPngFile.npos) + { + continue; + } + strPngFile.replace(pos, strPngFile.length(), ".png"); + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); + _render = Sprite::createWithSpriteFrameName(filePath.c_str()); + _render->retain(); ret = true; - } - else - { - CC_BREAK_IF(true); - } - } - else - { - CC_BREAK_IF(true); - } + } + else + { + CC_BREAK_IF(true); + } + } + else + { + CC_BREAK_IF(true); + } } while (0); return ret; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index dbeae98145..60c5aa6792 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -1417,29 +1417,33 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(const rapidjson::Value& json, D { displayData = new (std::nothrow) SpriteDisplayData(); - const char *name = DICTOOL->getStringValue_json(json, A_NAME); + const char *name = DICTOOL->getStringValue_json(json, A_NAME); if(name != nullptr) { ((SpriteDisplayData *)displayData)->displayName = name; } - const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA); - if(!dicArray.IsNull()) - { - rapidjson::SizeType index = 0; - const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(dicArray, index); - if (!dic.IsNull()) - { - SpriteDisplayData *sdd = (SpriteDisplayData *)displayData; - sdd->skinData.x = DICTOOL->getFloatValue_json(dic, A_X) * s_PositionReadScale; - sdd->skinData.y = DICTOOL->getFloatValue_json(dic, A_Y) * s_PositionReadScale; - sdd->skinData.scaleX = DICTOOL->getFloatValue_json(dic, A_SCALE_X, 1.0f); - sdd->skinData.scaleY = DICTOOL->getFloatValue_json(dic, A_SCALE_Y, 1.0f); - sdd->skinData.skewX = DICTOOL->getFloatValue_json(dic, A_SKEW_X, 1.0f); - sdd->skinData.skewY = DICTOOL->getFloatValue_json(dic, A_SKEW_Y, 1.0f); + if(json.HasMember(SKIN_DATA)) + { + const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA); + if(!dicArray.IsNull()) + { + rapidjson::SizeType index = 0; + const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(dicArray, index); + if (!dic.IsNull()) + { + SpriteDisplayData *sdd = (SpriteDisplayData *)displayData; + sdd->skinData.x = DICTOOL->getFloatValue_json(dic, A_X) * s_PositionReadScale; + sdd->skinData.y = DICTOOL->getFloatValue_json(dic, A_Y) * s_PositionReadScale; + sdd->skinData.scaleX = DICTOOL->getFloatValue_json(dic, A_SCALE_X, 1.0f); + sdd->skinData.scaleY = DICTOOL->getFloatValue_json(dic, A_SCALE_Y, 1.0f); + sdd->skinData.skewX = DICTOOL->getFloatValue_json(dic, A_SKEW_X, 1.0f); + sdd->skinData.skewY = DICTOOL->getFloatValue_json(dic, A_SKEW_Y, 1.0f); + + sdd->skinData.x *= dataInfo->contentScale; + sdd->skinData.y *= dataInfo->contentScale; + } + } - sdd->skinData.x *= dataInfo->contentScale; - sdd->skinData.y *= dataInfo->contentScale; - } } } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 0e29de8d2f..593eaeba32 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -340,12 +340,16 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par createObject(subDict, gb, attachComponent); } - const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize"); - if (DICTOOL->checkObjectExist_json(canvasSizeDict)) + if(dict.HasMember("CanvasSize")) { - int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width"); - int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height"); - gb->setContentSize(Size(width, height)); + const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize"); + if (DICTOOL->checkObjectExist_json(canvasSizeDict)) + { + int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width"); + int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height"); + gb->setContentSize(Size(width, height)); + } + } return gb; diff --git a/cocos/editor-support/cocostudio/CSParseBinary_generated.h b/cocos/editor-support/cocostudio/CSParseBinary_generated.h index 7a553be9bb..ba6b4197c6 100644 --- a/cocos/editor-support/cocostudio/CSParseBinary_generated.h +++ b/cocos/editor-support/cocostudio/CSParseBinary_generated.h @@ -1791,7 +1791,7 @@ inline flatbuffers::Offset CreateListViewOptions(flatbuffers::F struct ProjectNodeOptions : private flatbuffers::Table { const WidgetOptions *nodeOptions() const { return GetPointer(4); } const flatbuffers::String *fileName() const { return GetPointer(6); } - float innerActionSpeed() const { return GetField(8, 1.0); } + float innerActionSpeed() const { return GetField(8, 0); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, 4 /* nodeOptions */) && @@ -1808,7 +1808,7 @@ struct ProjectNodeOptionsBuilder { flatbuffers::uoffset_t start_; void add_nodeOptions(flatbuffers::Offset nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_fileName(flatbuffers::Offset fileName) { fbb_.AddOffset(6, fileName); } - void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 1.0); } + void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement(8, innerActionSpeed, 0); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); flatbuffers::Offset Finish() { @@ -1820,7 +1820,7 @@ struct ProjectNodeOptionsBuilder { inline flatbuffers::Offset CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset nodeOptions = 0, flatbuffers::Offset fileName = 0, - float innerActionSpeed = 1.0) { + float innerActionSpeed = 0) { ProjectNodeOptionsBuilder builder_(_fbb); builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_fileName(fileName); diff --git a/cocos/editor-support/cocostudio/CocosStudioExport.h b/cocos/editor-support/cocostudio/CocosStudioExport.h index c22591f6b5..20bc6f5038 100644 --- a/cocos/editor-support/cocostudio/CocosStudioExport.h +++ b/cocos/editor-support/cocostudio/CocosStudioExport.h @@ -24,6 +24,8 @@ #define NULL ((void *)0) #endif #endif +#elif defined(_SHARED_) + #define CC_STUDIO_DLL __attribute__((visibility("default"))) #else #define CC_STUDIO_DLL #endif diff --git a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp index 9047de4d88..5435505e48 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.cpp @@ -85,15 +85,15 @@ namespace cocostudio attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "ValueX") + if (attriname == "X") { ret.x = atof(value.c_str()); } - else if (attriname == "ValueY") + else if (attriname == "Y") { ret.y = atof(value.c_str()); } - else if(attriname == "ValueZ") + else if(attriname == "Z") { ret.z = atof(value.c_str()); } @@ -196,11 +196,11 @@ namespace cocostudio attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "ValueX") + if (attriname == "X") { position.x = atof(value.c_str()); } - else if (attriname == "ValueY") + else if (attriname == "Y") { position.y = atof(value.c_str()); } @@ -217,11 +217,11 @@ namespace cocostudio attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "ValueX") + if (attriname == "X") { scale.x = atof(value.c_str()); } - else if (attriname == "ValueY") + else if (attriname == "Y") { scale.y = atof(value.c_str()); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp index b1f511ccf8..618811f1c0 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.cpp @@ -85,11 +85,11 @@ namespace cocostudio attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "ValueX") + if (attriname == "X") { ret.x = atof(value.c_str()); } - else if (attriname == "ValueY") + else if (attriname == "Y") { ret.y = atof(value.c_str()); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp index b571260938..6f3fa906e4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.cpp @@ -84,11 +84,11 @@ namespace cocostudio attriname = attribute->Name(); std::string value = attribute->Value(); - if (attriname == "ValueX") + if (attriname == "X") { ret.x = atof(value.c_str()); } - else if (attriname == "ValueY") + else if (attriname == "Y") { ret.y = atof(value.c_str()); } diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 538881eecf..ea3cc94561 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -95,16 +95,15 @@ public final class Cocos2dxBitmap { hAlignment = Layout.Alignment.ALIGN_CENTER; break; case HORIZONTAL_ALIGN_RIGHT: - hAlignment = Layout.Alignment.valueOf("ALIGN_RIGHT"); + hAlignment = Layout.Alignment.ALIGN_OPPOSITE; break; case HORIZONTAL_ALIGN_LEFT: - hAlignment = Layout.Alignment.valueOf("ALIGN_LEFT"); break; default: break; } - TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment); + TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize); if (stroke) { paint.setStyle(TextPaint.Style.STROKE); paint.setStrokeWidth(strokeSize); @@ -164,8 +163,7 @@ public final class Cocos2dxBitmap { return true; } - private static TextPaint newPaint(final String fontName, final int fontSize, - final int horizontalAlignment) { + private static TextPaint newPaint(final String fontName, final int fontSize) { final TextPaint paint = new TextPaint(); paint.setTextSize(fontSize); paint.setAntiAlias(true); diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index 5f710fd765..afcf93eca0 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -42,7 +42,7 @@ THE SOFTWARE. #define LOG_TAG "main" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) -void cocos_android_app_init(JNIEnv* env, jobject thiz) __attribute__((weak)); +void cocos_android_app_init(JNIEnv* env) __attribute__((weak)); using namespace cocos2d; @@ -53,6 +53,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { JniHelper::setJavaVM(vm); + cocos_android_app_init(JniHelper::getEnv()); + return JNI_VERSION_1_4; } @@ -66,8 +68,6 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j glview->setFrameSize(w, h); director->setOpenGLView(glview); - //cocos_android_app_init(env, thiz); - cocos2d::Application::getInstance()->run(); } else @@ -85,7 +85,6 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz) { - cocos_android_app_init(env, thiz); cocos2d::Application::getInstance()->initGLContextAttrs(); GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs(); diff --git a/cocos/renderer/CCTexture2D.cpp b/cocos/renderer/CCTexture2D.cpp index f51b5ae199..634c7c0f1c 100644 --- a/cocos/renderer/CCTexture2D.cpp +++ b/cocos/renderer/CCTexture2D.cpp @@ -1427,7 +1427,7 @@ const Rect& Texture2D::getSpriteFrameCapInset( cocos2d::SpriteFrame *spriteFrame } else { - auto capInsetMap = this->_ninePatchInfo->capInsetMap; + auto &capInsetMap = this->_ninePatchInfo->capInsetMap; if(capInsetMap.find(spriteFrame) != capInsetMap.end()) { return capInsetMap.at(spriteFrame); diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index 7afca3874e..446061784e 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -108,7 +108,13 @@ void TextureCache::addImageAsync(const std::string &path, const std::functionisFileExist( fullpath ) ) { + if (callback) callback(nullptr); return; } diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 4e1262aff9..3823be9903 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1292,9 +1292,29 @@ var get3DVector = function(json, name, defValue){ var x = defValue, y = defValue, z = defValue; if(json && name && json[name]){ - x = null != json[name]["ValueX"] ? json[name]["ValueX"] : defValue; - y = null != json[name]["ValueY"] ? json[name]["ValueY"] : defValue; - z = null != json[name]["ValueZ"] ? json[name]["ValueZ"] : defValue; + if(undefined !== json[name]["ValueX"]) { + x = json[name]["ValueX"]; + } else if(undefined !== json[name]["X"]) { + x = json[name]["X"] + } + if(null === x || isNaN(x)) + x = defValue; + + if(undefined !== json[name]["ValueY"]) { + y = json[name]["ValueY"]; + } else if(undefined !== json[name]["Y"]) { + y = json[name]["Y"] + } + if(null === y || isNaN(y)) + y = defValue; + + if(undefined !== json[name]["ValueZ"]) { + z = json[name]["ValueZ"]; + } else if(undefined !== json[name]["Z"]) { + z = json[name]["Z"] + } + if(null === z || isNaN(z)) + z = defValue; } var vec3 = cc.math.vec3(x, y, z); return vec3; @@ -1343,8 +1363,18 @@ var nearClip = 1; var farClip = 500; if(json["ClipPlane"]){ - nearClip = json["ClipPlane"]["ValueX"]; - farClip = json["ClipPlane"]["ValueY"]; + if(undefined !== json["ClipPlane"]["ValueX"]) { + nearClip = json["ClipPlane"]["ValueX"]; + } else if(undefined !== json["ClipPlane"]["X"]) { + nearClip = json["ClipPlane"]["X"]; + } + + if(undefined !== json["ClipPlane"]["ValueY"]) { + farClip = json["ClipPlane"]["ValueY"]; + } else if(undefined !== json["ClipPlane"]["Y"]) { + farClip = json["ClipPlane"]["Y"]; + } + if(null === nearClip || isNaN(nearClip)) nearClip = 1; if(null === farClip || isNaN(farClip)) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 6d0b91aeb1..bc5ad0843e 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -151,7 +151,7 @@ namespace ui { auto spriteFrame = sprite->getSpriteFrame(); if (texture->isContain9PatchInfo()) { - auto parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame); + auto& parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame); if(!parsedCapInset.equals(Rect::ZERO)) { this->_isPatch9 = true; diff --git a/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp b/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp +++ b/templates/cpp-template-default/proj.android-studio/app/jni/hellocpp/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp b/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp +++ b/templates/cpp-template-default/proj.android/jni/hellocpp/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp +++ b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp index bb3ea221bc..c721da8a60 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp @@ -10,7 +10,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp index fff9f825a6..729b8b7f9a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android-studio/app/jni/hellolua/main.cpp @@ -11,7 +11,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp index fff9f825a6..729b8b7f9a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp @@ -11,7 +11,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp b/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp +++ b/tests/cpp-empty-test/proj.android-studio/app/jni/main.cpp @@ -10,7 +10,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/cpp-empty-test/proj.android/jni/main.cpp b/tests/cpp-empty-test/proj.android/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/cpp-empty-test/proj.android/jni/main.cpp +++ b/tests/cpp-empty-test/proj.android/jni/main.cpp @@ -10,7 +10,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index e74c790740..5dfdccba32 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -531,17 +531,17 @@ std::string BackgroundComponentTest::title() const void BackgroundComponentTest::onEnter() { SceneEditorTestBase::onEnter(); - do - { + do + { Node *root = createGameScene(); CC_BREAK_IF(!root); this->addChild(root, 0, 1); - } while (0); + } while (0); } void BackgroundComponentTest::onExit() { - ArmatureDataManager::destroyInstance(); + ArmatureDataManager::destroyInstance(); SceneReader::destroyInstance(); ActionManagerEx::destroyInstance(); GUIReader::destroyInstance(); @@ -550,20 +550,20 @@ void BackgroundComponentTest::onExit() cocos2d::Node* BackgroundComponentTest::createGameScene() { - _filePath = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json"; + _filePath = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json"; _rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str()); - if (_rootNode == nullptr) - { - return nullptr; - } - defaultPlay(); + if (_rootNode == nullptr) + { + return nullptr; + } + defaultPlay(); return _rootNode; } void BackgroundComponentTest::defaultPlay() { - ComAudio *Audio = static_cast(_rootNode->getComponent("CCBackgroundAudio")); - Audio->playBackgroundMusic(); + ComAudio *Audio = static_cast(_rootNode->getComponent("CCBackgroundAudio")); + Audio->playBackgroundMusic(); } @@ -584,13 +584,13 @@ std::string AttributeComponentTest::title() const void AttributeComponentTest::onEnter() { SceneEditorTestBase::onEnter(); - do - { + do + { Node *root = createGameScene(); CC_BREAK_IF(!root); - defaultPlay(); + defaultPlay(); this->addChild(root, 0, 1); - } while (0); + } while (0); } void AttributeComponentTest::onExit() @@ -604,33 +604,33 @@ void AttributeComponentTest::onExit() bool AttributeComponentTest::initData() { - bool bRet = false; - rapidjson::Document doc; - do { - CC_BREAK_IF(_rootNode == nullptr); - ComAttribute *attribute = static_cast(_rootNode->getChildByTag(10015)->getComponent("CCComAttribute")); - CC_BREAK_IF(attribute == nullptr); - log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP")); + bool bRet = false; + rapidjson::Document doc; + do { + CC_BREAK_IF(_rootNode == nullptr); + ComAttribute *attribute = static_cast(_rootNode->getChildByTag(10015)->getComponent("CCComAttribute")); + CC_BREAK_IF(attribute == nullptr); + log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP")); - bRet = true; - } while (0); - return bRet; + bRet = true; + } while (0); + return bRet; } cocos2d::Node* AttributeComponentTest::createGameScene() { - _filePath = "scenetest/AttributeComponentTest/AttributeComponentTest.json"; + _filePath = "scenetest/AttributeComponentTest/AttributeComponentTest.json"; _rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str()); - if (_rootNode == nullptr) - { - return nullptr; - } + if (_rootNode == nullptr) + { + return nullptr; + } return _rootNode; } void AttributeComponentTest::defaultPlay() { - initData(); + initData(); } TriggerTest::TriggerTest() @@ -652,7 +652,7 @@ std::string TriggerTest::title() const // on "init" you need to initialize your instance void TriggerTest::onEnter() { - SceneEditorTestBase::onEnter(); + SceneEditorTestBase::onEnter(); Node *root = createGameScene(); this->addChild(root, 0, 1); this->schedule(CC_SCHEDULE_SELECTOR(TriggerTest::gameLogic)); @@ -670,12 +670,12 @@ void TriggerTest::onEnter() void TriggerTest::onExit() { - sendEvent(TRIGGEREVENT_LEAVESCENE); + sendEvent(TRIGGEREVENT_LEAVESCENE); this->unschedule(CC_SCHEDULE_SELECTOR(TriggerTest::gameLogic)); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->removeEventListener(_touchListener); Device::setAccelerometerEnabled(false); - ArmatureDataManager::destroyInstance(); + ArmatureDataManager::destroyInstance(); SceneReader::destroyInstance(); ActionManagerEx::destroyInstance(); GUIReader::destroyInstance(); @@ -711,14 +711,14 @@ void TriggerTest::gameLogic(float dt) cocos2d::Node* TriggerTest::createGameScene() { - _filePath = "scenetest/TriggerTest/TriggerTest.json"; + _filePath = "scenetest/TriggerTest/TriggerTest.json"; _rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str()); - if (_rootNode == nullptr) - { - return nullptr; - } + if (_rootNode == nullptr) + { + return nullptr; + } - defaultPlay(); + defaultPlay(); return _rootNode; } void TriggerTest::defaultPlay() diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp index a085325fb1..ecaa86d5e4 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.cpp @@ -2000,6 +2000,7 @@ void ParticleIssue12310::onEnter() addChild(particle); _emitter = particle; + _emitter->retain(); auto particle2 = ParticleSystemQuad::create("Particles/BoilingFoamStar.plist"); particle2->setPosition(Vec2(winSize.width * 0.65f, winSize.height * 0.5f)); diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h index 8cab2e5ef3..56d4220c8f 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h @@ -8,14 +8,14 @@ DEFINE_TEST_SUITE(ParticleTests); class ParticleDemo : public TestCase { protected: - cocos2d::ParticleSystemQuad* _emitter; - cocos2d::Sprite* _background; - cocos2d::LayerColor* _color; + cocos2d::ParticleSystemQuad* _emitter; + cocos2d::Sprite* _background; + cocos2d::LayerColor* _color; public: - ~ParticleDemo(void); + ~ParticleDemo(); - virtual void onEnter(void); + virtual void onEnter(); virtual std::string title() const override; virtual std::string subtitle() const override; diff --git a/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp b/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp index 6d5e647aac..314da6b1dc 100644 --- a/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp +++ b/tests/cpp-tests/Classes/Scene3DTest/Scene3DTest.cpp @@ -89,8 +89,6 @@ bool Scene3DTestScene::init() do { CC_BREAK_IF(false == TerrainWalkThru::init()); - - Director::getInstance()->setDisplayStats(false); // prepare for camera creation, we need create three custom cameras _gameCameras.resize(LAYER_COUNT); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index 40fb111518..603121c565 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -232,8 +232,7 @@ bool UITextTest_IgnoreConentSize::init() widgetSize.height / 2.0f)); leftText->ignoreContentAdaptWithSize(false); leftText->setTextAreaSize(Size(60,60)); - leftText->setString("Text line with break\nText line \ - with break\nText line with break\nText line with break\n"); + leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); leftText->setTouchScaleChangeEnabled(true); leftText->setTouchEnabled(true); _uiLayer->addChild(leftText); @@ -243,8 +242,7 @@ bool UITextTest_IgnoreConentSize::init() "fonts/Marker Felt.ttf",10); rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50, widgetSize.height / 2.0f)); - rightText->setString("Text line with break\nText line \ - with break\nText line with break\nText line with break\n"); + rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); //note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false) rightText->setTextAreaSize(Size(100,30)); rightText->ignoreContentAdaptWithSize(false); diff --git a/tests/cpp-tests/proj.android-studio/app/jni/main.cpp b/tests/cpp-tests/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/cpp-tests/proj.android-studio/app/jni/main.cpp +++ b/tests/cpp-tests/proj.android-studio/app/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/cpp-tests/proj.android/jni/main.cpp b/tests/cpp-tests/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/cpp-tests/proj.android/jni/main.cpp +++ b/tests/cpp-tests/proj.android/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/game-controller-test/proj.android-studio/app/jni/main.cpp b/tests/game-controller-test/proj.android-studio/app/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/game-controller-test/proj.android-studio/app/jni/main.cpp +++ b/tests/game-controller-test/proj.android-studio/app/jni/main.cpp @@ -10,7 +10,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/game-controller-test/proj.android/jni/main.cpp b/tests/game-controller-test/proj.android/jni/main.cpp index feab560c09..4b0db09aa7 100644 --- a/tests/game-controller-test/proj.android/jni/main.cpp +++ b/tests/game-controller-test/proj.android/jni/main.cpp @@ -10,7 +10,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/js-tests/project/proj.android-studio/app/jni/main.cpp b/tests/js-tests/project/proj.android-studio/app/jni/main.cpp index baf5ca9810..2d9745860d 100644 --- a/tests/js-tests/project/proj.android-studio/app/jni/main.cpp +++ b/tests/js-tests/project/proj.android-studio/app/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); JavaVM* vm; diff --git a/tests/js-tests/project/proj.android/jni/main.cpp b/tests/js-tests/project/proj.android/jni/main.cpp index baf5ca9810..2d9745860d 100644 --- a/tests/js-tests/project/proj.android/jni/main.cpp +++ b/tests/js-tests/project/proj.android/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); JavaVM* vm; diff --git a/tests/js-tests/src/SpriteTest/SpriteTest.js b/tests/js-tests/src/SpriteTest/SpriteTest.js index fc5ca5e63b..9ce1da7414 100644 --- a/tests/js-tests/src/SpriteTest/SpriteTest.js +++ b/tests/js-tests/src/SpriteTest/SpriteTest.js @@ -5338,10 +5338,10 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({ //----start59----ctor this._super(); - var destFactors = [gl.ZERO, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA], - srcFactors = [gl.ZERO, gl.ONE, gl.DST_COLOR, gl.ONE_MINUS_DST_COLOR, gl.DST_ALPHA, gl.ONE_MINUS_DST_ALPHA]; - var destTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"], - srcTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"]; + var destFactors = [cc.ZERO, cc.ONE, cc.DST_COLOR, cc.ONE_MINUS_DST_COLOR, cc.DST_ALPHA, cc.ONE_MINUS_DST_ALPHA], + srcFactors = [cc.ZERO, cc.ONE, cc.SRC_COLOR, cc.ONE_MINUS_SRC_COLOR, cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA]; + var destTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "DST_ALPHA", "ONE_MINUS_DST_ALPHA"], + srcTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"]; var sourceImg = "Images/dot.png", destImg = "Images/wood.jpg"; var sourceTexture = cc.textureCache.addImage(sourceImg); @@ -5355,6 +5355,14 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({ this.addChild(sourceSprite); this.addChild(destSprite); + if(cc._renderType === cc._RENDER_TYPE_CANVAS){ + var info = new cc.LabelTTF("support is not complete on canvas", "Arial", 18); + info.x = 680; + info.y = 250; + info.setDimensions(cc.size(200, 200)); + this.addChild(info); + } + var i, j, title, fontSize, titleLabel; for(i = 0; i < destTitles.length; i++){ title = destTitles[i]; @@ -5387,7 +5395,7 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({ //destSprite.setScale(0.8); destSprite.setPosition( 220 + i * 60, 355 - j * 60); // destSprite.setBlendFunc(srcFactors[j], destFactors[i]); - + this.addChild(destSprite,1); this.addChild(sourceSprite,2); } diff --git a/tests/js-tests/src/TransitionsTest/TransitionsTest.js b/tests/js-tests/src/TransitionsTest/TransitionsTest.js index f6f0173e6b..772534f42f 100644 --- a/tests/js-tests/src/TransitionsTest/TransitionsTest.js +++ b/tests/js-tests/src/TransitionsTest/TransitionsTest.js @@ -179,6 +179,10 @@ var transitionsIdx = 0; // every .Scene each test used must inherit from TestScene, // make sure the test have the menu item for back to main menu var TransitionsTestScene = TestScene.extend({ + onEnter: function () { + this._super(); + director.setDepthTest(false); + }, runThisTest:function () { var layer = new TestLayer1(); this.addChild(layer); diff --git a/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp b/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-empty-test/project/proj.android-studio/app/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/lua-empty-test/project/proj.android/jni/main.cpp b/tests/lua-empty-test/project/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-empty-test/project/proj.android/jni/main.cpp +++ b/tests/lua-empty-test/project/proj.android/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp b/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp index 882c5632e7..8e8e384301 100644 --- a/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-game-controller-test/project/proj.android-studio/app/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate(); } diff --git a/tests/lua-game-controller-test/project/proj.android/jni/main.cpp b/tests/lua-game-controller-test/project/proj.android/jni/main.cpp index 882c5632e7..8e8e384301 100644 --- a/tests/lua-game-controller-test/project/proj.android/jni/main.cpp +++ b/tests/lua-game-controller-test/project/proj.android/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate(); } diff --git a/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp b/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp +++ b/tests/lua-tests/project/proj.android-studio/app/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/lua-tests/project/proj.android/jni/main.cpp b/tests/lua-tests/project/proj.android/jni/main.cpp index 5199d12ab4..2c27096ca3 100644 --- a/tests/lua-tests/project/proj.android/jni/main.cpp +++ b/tests/lua-tests/project/proj.android/jni/main.cpp @@ -9,7 +9,7 @@ using namespace cocos2d; -void cocos_android_app_init (JNIEnv* env, jobject thiz) { +void cocos_android_app_init (JNIEnv* env) { LOGD("cocos_android_app_init"); AppDelegate *pAppDelegate = new AppDelegate(); } diff --git a/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua b/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua index 40a2c9fed9..e61b88c6cd 100644 --- a/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua +++ b/tests/lua-tests/src/LabelTestNew/LabelTestNew.lua @@ -1235,17 +1235,20 @@ function LabelCharMapTest.create() local label1 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label1, 0, kTagSprite1) + label1:setAnchorPoint(cc.p(0, 0)) label1:setPosition( cc.p(10,100) ) label1:setOpacity( 200 ) local label2 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label2, 0, kTagSprite2) + label2:setAnchorPoint(cc.p(0, 0)) label2:setPosition( cc.p(10,160) ) label2:setOpacity( 32 ) local label3 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")--32 means Space key label3:setString("123 Test") layer:addChild(label3, 0, kTagSprite3) + label3:setAnchorPoint(cc.p(0, 0)) label3:setPosition(cc.p(10,220)) local function step(dt) diff --git a/tools/make-package/git-archive-all b/tools/make-package/git-archive-all index 00968e3851..32b1c98260 100755 --- a/tools/make-package/git-archive-all +++ b/tools/make-package/git-archive-all @@ -14,6 +14,9 @@ import traceback from os import path, extsep from subprocess import Popen, PIPE, CalledProcessError +def os_is_win32(): + return sys.platform == 'win32' + class UnrecognizedFormat: def __init__(self, prompt): self._prompt = prompt @@ -66,7 +69,7 @@ class GitArchiver(object): # Raises an exception if there is no repo under main_repo_abspath. try: - self.run_shell("[ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1", main_repo_abspath) + self.run_shell("git rev-parse", main_repo_abspath) except Exception as e: raise ValueError("Not a git repository (or any of the parent directories).".format(path=main_repo_abspath)) @@ -188,7 +191,11 @@ class GitArchiver(object): if self.verbose: print("Compressing {f} => {a}...".format(f=file_path, a=path.join(self.prefix, file_path))) - add(file_path, file_path) + try: + add(file_path, file_path) + except: + print('add %s failed.' % file_path) + pass else: print("{f} => {a}".format(f=file_path, a=path.join(self.prefix, file_path))) @@ -199,7 +206,11 @@ class GitArchiver(object): print("Compressing {f} => {a}...".format(f=path.join(self.main_repo_abspath, file_path), a=path.join(self.prefix, file_path))) - add(path.join(self.main_repo_abspath, file_path), file_path) + try: + add(path.join(self.main_repo_abspath, file_path), file_path) + except: + print('add %s failed.' % file_path) + pass else: print("{f} => {a}".format(f=path.join(self.main_repo_abspath, file_path), a=path.join(self.prefix, file_path))) @@ -232,7 +243,12 @@ class GitArchiver(object): raise Exception("Couldn't find extra folder path (%s) in (%s)!" % (extra_folder_path, file_path)) path_in_zip = extra_to_zip_file + file_path[(len(extra_folder_path)):] - add(file_path, path_in_zip) + + try: + add(file_path, path_in_zip) + except: + print('add %s failed.' % file_path) + pass outfile_name, outfile_ext = path.splitext(output_path) for extra_dir in config_data["extra_dirs"]: @@ -242,7 +258,11 @@ class GitArchiver(object): for f in files: file_path = path.join(root,f) path_in_zip = file_path[(len(self.main_repo_abspath)+1):] - add(file_path, path_in_zip) + try: + add(file_path, path_in_zip) + except: + print('add %s failed.' % file_path) + pass if not dry_run: archive.close() @@ -273,11 +293,20 @@ class GitArchiver(object): """ components = [] - while not path.samefile(abspath, repo_abspath): - abspath, tail = path.split(abspath) + if os_is_win32(): + abspath = os.path.normpath(abspath) + repo_abspath = os.path.normpath(repo_abspath) + while abspath != repo_abspath: + abspath, tail = path.split(abspath) - if len(tail): - components.insert(0, tail) + if len(tail): + components.insert(0, tail) + else: + while not path.samefile(abspath, repo_abspath): + abspath, tail = path.split(abspath) + + if len(tail): + components.insert(0, tail) components.insert(0, path.relpath(repo_abspath, repo_abspath)) return components