Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_7_test

This commit is contained in:
samuele3hu 2015-06-23 20:03:14 +08:00
commit 5c5f3dcc79
49 changed files with 458 additions and 358 deletions

View File

@ -152,12 +152,8 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
Quaternion quaternion; Quaternion quaternion;
Quaternion::createFromRotationMatrix(rotation,&quaternion); Quaternion::createFromRotationMatrix(rotation,&quaternion);
quaternion.normalize();
float rotx = atan2f(2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z), 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y)); setRotationQuat(quaternion);
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)));
} }
const Mat4& Camera::getViewProjectionMatrix() const const Mat4& Camera::getViewProjectionMatrix() const

View File

@ -690,7 +690,7 @@ void Label::updateQuads()
} }
if (_lettersInfo[ctr].position.y - letterDef.height < 0.f) 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); _reusedLetter->setTextureRect(_reusedRect,false,_reusedRect.size);

View File

@ -61,11 +61,13 @@ void Audio::Initialize()
void Audio::CreateResources() void Audio::CreateResources()
{ {
try do
{ {
ThrowIfFailed( if (FAILED(XAudio2Create(&m_musicEngine)))
XAudio2Create(&m_musicEngine) {
); m_engineExperiencedCriticalError = true;
break;
}
#if defined(_DEBUG) #if defined(_DEBUG)
XAUDIO2_DEBUG_CONFIGURATION debugConfig = {0}; 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 // 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. // as Game Media.
// We default the mastering voice to 2 channels to simplify the reverb logic. // We default the mastering voice to 2 channels to simplify the reverb logic.
ThrowIfFailed( if(FAILED(m_musicEngine->CreateMasteringVoice(&m_musicMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia)))
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 // 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 // Games will use many voices in a complex graph for audio, mixing all effects down to a
// single mastering voice. // single mastering voice.
// We are creating an entirely new engine instance and mastering voice in order to tag // We are creating an entirely new engine instance and mastering voice in order to tag
// our sound effects with the audio category AudioCategory_GameEffects. // our sound effects with the audio category AudioCategory_GameEffects.
ThrowIfFailed( if(FAILED(XAudio2Create(&m_soundEffectEngine)))
XAudio2Create(&m_soundEffectEngine) {
); m_engineExperiencedCriticalError = true;
break;
}
m_soundEffectEngineCallback.Initialize(this); m_soundEffectEngineCallback.Initialize(this);
m_soundEffectEngine->RegisterForCallbacks(&m_soundEffectEngineCallback); m_soundEffectEngine->RegisterForCallbacks(&m_soundEffectEngineCallback);
// We default the mastering voice to 2 channels to simplify the reverb logic. // We default the mastering voice to 2 channels to simplify the reverb logic.
ThrowIfFailed( if(FAILED(m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects)))
m_soundEffectEngine->CreateMasteringVoice(&m_soundEffectMasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameEffects)
);
}
catch (...)
{ {
m_engineExperiencedCriticalError = true; m_engineExperiencedCriticalError = true;
break;
} }
} while (false);
} }
unsigned int Audio::Hash(const char *key) unsigned int Audio::Hash(const char *key)
@ -309,9 +313,10 @@ void Audio::PlaySoundEffect(unsigned int sound)
StopSoundEffect(sound); StopSoundEffect(sound);
ThrowIfFailed( if (FAILED(m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer)))
m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer) {
); m_engineExperiencedCriticalError = true;
}
if (m_engineExperiencedCriticalError) { if (m_engineExperiencedCriticalError) {
// If there's an error, then we'll recreate the engine on the next render pass // 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.SendCount = 1;
sends.pSends = descriptors; sends.pSends = descriptors;
ThrowIfFailed( if (FAILED(m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, &wfx, 0, 1.0f, &m_voiceContext, &sends)))
&wfx, 0, 1.0f, &m_voiceContext, &sends) {
); m_engineExperiencedCriticalError = true;
}
//fix bug: set a initial volume //fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_backgroundMusicVolume); m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_backgroundMusicVolume);
} else } else
@ -575,10 +581,11 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
sends.SendCount = 1; sends.SendCount = 1;
sends.pSends = descriptors; sends.pSends = descriptors;
ThrowIfFailed( if(FAILED(m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice, &wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr)))
&wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr) {
); m_engineExperiencedCriticalError = true;
}
//fix bug: set a initial volume //fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_soundEffctVolume); m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_soundEffctVolume);
} }

View File

@ -311,6 +311,7 @@ void AudioPlayer::setVolume(float volume)
bool AudioPlayer::play2d(AudioCache* cache) bool AudioPlayer::play2d(AudioCache* cache)
{ {
bool ret = false; bool ret = false;
HRESULT hr = S_OK;
if (cache != nullptr) if (cache != nullptr)
{ {
@ -323,21 +324,26 @@ bool AudioPlayer::play2d(AudioCache* cache)
XAUDIO2_VOICE_SENDS sends = { 0 }; XAUDIO2_VOICE_SENDS sends = { 0 };
sends.SendCount = 1; sends.SendCount = 1;
sends.pSends = descriptors; 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);
} }
if (SUCCEEDED(hr)) {
_isStreaming = _cache->isStreamingSource(); _isStreaming = _cache->isStreamingSource();
_duration = getDuration(); _duration = getDuration();
ret = _play(); ret = _play();
} }
}
return ret; return ret;
} }
void AudioPlayer::init() void AudioPlayer::init()
{ {
do {
memset(&_xaBuffer, 0, sizeof(_xaBuffer)); memset(&_xaBuffer, 0, sizeof(_xaBuffer));
ThrowIfFailed(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf())); if (FAILED(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf()))) {
break;
}
#if defined(_DEBUG) #if defined(_DEBUG)
XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 }; XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 };
@ -347,9 +353,12 @@ void AudioPlayer::init()
#endif #endif
_xaEngine->RegisterForCallbacks(this); _xaEngine->RegisterForCallbacks(this);
ThrowIfFailed(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia)); if (FAILED(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia))) {
break;
}
_ready = true; _ready = true;
_state = AudioPlayerState::READY; _state = AudioPlayerState::READY;
} while (false);
} }
void AudioPlayer::free() void AudioPlayer::free()

View File

@ -1007,6 +1007,9 @@ void Director::restartDirector()
{ {
reset(); reset();
// RenderState need to be reinitialized
RenderState::initialize();
// Texture cache need to be reinitialized // Texture cache need to be reinitialized
initTextureCache(); initTextureCache();

View File

@ -54,7 +54,7 @@ ComRender::~ComRender(void)
void ComRender::onEnter() void ComRender::onEnter()
{ {
if (_owner != nullptr) if (_owner != nullptr && _render->getParent() == nullptr)
{ {
_owner->addChild(_render); _owner->addChild(_render);
} }
@ -62,7 +62,7 @@ void ComRender::onEnter()
void ComRender::onExit() void ComRender::onExit()
{ {
if (_owner != nullptr) if (_owner != nullptr && _render->getParent() == nullptr)
{ {
_owner->removeChild(_render, true); _owner->removeChild(_render, true);
} }
@ -70,7 +70,7 @@ void ComRender::onExit()
void ComRender::onAdd() void ComRender::onAdd()
{ {
if (_owner != nullptr) if (_owner != nullptr && _render->getParent() == nullptr)
{ {
_owner->addChild(_render); _owner->addChild(_render);
} }
@ -78,7 +78,7 @@ void ComRender::onAdd()
void ComRender::onRemove() void ComRender::onRemove()
{ {
if (_owner != nullptr) if (_owner != nullptr && _render->getParent() == nullptr)
{ {
_owner->removeChild(_render, true); _owner->removeChild(_render, true);
} }
@ -104,6 +104,7 @@ void ComRender::setNode(cocos2d::Node *node)
} }
// TODO: This method is soooo big!! We should refactor it!
bool ComRender::serialize(void* r) bool ComRender::serialize(void* r)
{ {
bool ret = false; bool ret = false;
@ -166,21 +167,21 @@ bool ComRender::serialize(void* r)
{ {
if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos)) if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos))
{ {
_render = CCSprite::create(filePath.c_str()); _render = Sprite::create(filePath.c_str());
_render->retain(); _render->retain();
ret = true; ret = true;
} }
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos) else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos)
{ {
_render = CCTMXTiledMap::create(filePath.c_str()); _render = TMXTiledMap::create(filePath.c_str());
_render->retain(); _render->retain();
ret = true; ret = true;
} }
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos) else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos)
{ {
_render = CCParticleSystemQuad::create(filePath.c_str()); _render = ParticleSystemQuad::create(filePath.c_str());
_render->setPosition(0.0f, 0.0f); _render->setPosition(0.0f, 0.0f);
_render->retain(); _render->retain();
@ -262,7 +263,7 @@ bool ComRender::serialize(void* r)
if (str1 != nullptr) if (str1 != nullptr)
{ {
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
Armature *pAr = CCArmature::create(str1); Armature *pAr = Armature::create(str1);
_render = pAr; _render = pAr;
_render->retain(); _render->retain();
const char *actionName = nullptr; const char *actionName = nullptr;
@ -339,7 +340,7 @@ bool ComRender::serialize(void* r)
} }
strPngFile.replace(pos, strPngFile.length(), ".png"); strPngFile.replace(pos, strPngFile.length(), ".png");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str());
_render = CCSprite::createWithSpriteFrameName(filePath.c_str()); _render = Sprite::createWithSpriteFrameName(filePath.c_str());
_render->retain(); _render->retain();
ret = true; ret = true;

View File

@ -1422,6 +1422,8 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(const rapidjson::Value& json, D
{ {
((SpriteDisplayData *)displayData)->displayName = name; ((SpriteDisplayData *)displayData)->displayName = name;
} }
if(json.HasMember(SKIN_DATA))
{
const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA); const rapidjson::Value &dicArray = DICTOOL->getSubDictionary_json(json, SKIN_DATA);
if(!dicArray.IsNull()) if(!dicArray.IsNull())
{ {
@ -1441,6 +1443,8 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(const rapidjson::Value& json, D
sdd->skinData.y *= dataInfo->contentScale; sdd->skinData.y *= dataInfo->contentScale;
} }
} }
}
} }
break; break;

View File

@ -340,6 +340,8 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
createObject(subDict, gb, attachComponent); createObject(subDict, gb, attachComponent);
} }
if(dict.HasMember("CanvasSize"))
{
const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize"); const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize");
if (DICTOOL->checkObjectExist_json(canvasSizeDict)) if (DICTOOL->checkObjectExist_json(canvasSizeDict))
{ {
@ -348,6 +350,8 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
gb->setContentSize(Size(width, height)); gb->setContentSize(Size(width, height));
} }
}
return gb; return gb;
} }

View File

@ -1791,7 +1791,7 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
struct ProjectNodeOptions : private flatbuffers::Table { struct ProjectNodeOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); } const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); } const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
float innerActionSpeed() const { return GetField<float>(8, 1.0); } float innerActionSpeed() const { return GetField<float>(8, 0); }
bool Verify(flatbuffers::Verifier &verifier) const { bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) && return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) && VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
@ -1808,7 +1808,7 @@ struct ProjectNodeOptionsBuilder {
flatbuffers::uoffset_t start_; flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); } void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); } void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 1.0); } void add_innerActionSpeed(float innerActionSpeed) { fbb_.AddElement<float>(8, innerActionSpeed, 0); }
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &); ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
flatbuffers::Offset<ProjectNodeOptions> Finish() { flatbuffers::Offset<ProjectNodeOptions> Finish() {
@ -1820,7 +1820,7 @@ struct ProjectNodeOptionsBuilder {
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb, inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0, flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<flatbuffers::String> fileName = 0, flatbuffers::Offset<flatbuffers::String> fileName = 0,
float innerActionSpeed = 1.0) { float innerActionSpeed = 0) {
ProjectNodeOptionsBuilder builder_(_fbb); ProjectNodeOptionsBuilder builder_(_fbb);
builder_.add_innerActionSpeed(innerActionSpeed); builder_.add_innerActionSpeed(innerActionSpeed);
builder_.add_fileName(fileName); builder_.add_fileName(fileName);

View File

@ -24,6 +24,8 @@
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif
#endif #endif
#elif defined(_SHARED_)
#define CC_STUDIO_DLL __attribute__((visibility("default")))
#else #else
#define CC_STUDIO_DLL #define CC_STUDIO_DLL
#endif #endif

View File

@ -85,15 +85,15 @@ namespace cocostudio
attriname = attribute->Name(); attriname = attribute->Name();
std::string value = attribute->Value(); std::string value = attribute->Value();
if (attriname == "ValueX") if (attriname == "X")
{ {
ret.x = atof(value.c_str()); ret.x = atof(value.c_str());
} }
else if (attriname == "ValueY") else if (attriname == "Y")
{ {
ret.y = atof(value.c_str()); ret.y = atof(value.c_str());
} }
else if(attriname == "ValueZ") else if(attriname == "Z")
{ {
ret.z = atof(value.c_str()); ret.z = atof(value.c_str());
} }
@ -196,11 +196,11 @@ namespace cocostudio
attriname = attribute->Name(); attriname = attribute->Name();
std::string value = attribute->Value(); std::string value = attribute->Value();
if (attriname == "ValueX") if (attriname == "X")
{ {
position.x = atof(value.c_str()); position.x = atof(value.c_str());
} }
else if (attriname == "ValueY") else if (attriname == "Y")
{ {
position.y = atof(value.c_str()); position.y = atof(value.c_str());
} }
@ -217,11 +217,11 @@ namespace cocostudio
attriname = attribute->Name(); attriname = attribute->Name();
std::string value = attribute->Value(); std::string value = attribute->Value();
if (attriname == "ValueX") if (attriname == "X")
{ {
scale.x = atof(value.c_str()); scale.x = atof(value.c_str());
} }
else if (attriname == "ValueY") else if (attriname == "Y")
{ {
scale.y = atof(value.c_str()); scale.y = atof(value.c_str());
} }

View File

@ -85,11 +85,11 @@ namespace cocostudio
attriname = attribute->Name(); attriname = attribute->Name();
std::string value = attribute->Value(); std::string value = attribute->Value();
if (attriname == "ValueX") if (attriname == "X")
{ {
ret.x = atof(value.c_str()); ret.x = atof(value.c_str());
} }
else if (attriname == "ValueY") else if (attriname == "Y")
{ {
ret.y = atof(value.c_str()); ret.y = atof(value.c_str());
} }

View File

@ -84,11 +84,11 @@ namespace cocostudio
attriname = attribute->Name(); attriname = attribute->Name();
std::string value = attribute->Value(); std::string value = attribute->Value();
if (attriname == "ValueX") if (attriname == "X")
{ {
ret.x = atof(value.c_str()); ret.x = atof(value.c_str());
} }
else if (attriname == "ValueY") else if (attriname == "Y")
{ {
ret.y = atof(value.c_str()); ret.y = atof(value.c_str());
} }

View File

@ -95,16 +95,15 @@ public final class Cocos2dxBitmap {
hAlignment = Layout.Alignment.ALIGN_CENTER; hAlignment = Layout.Alignment.ALIGN_CENTER;
break; break;
case HORIZONTAL_ALIGN_RIGHT: case HORIZONTAL_ALIGN_RIGHT:
hAlignment = Layout.Alignment.valueOf("ALIGN_RIGHT"); hAlignment = Layout.Alignment.ALIGN_OPPOSITE;
break; break;
case HORIZONTAL_ALIGN_LEFT: case HORIZONTAL_ALIGN_LEFT:
hAlignment = Layout.Alignment.valueOf("ALIGN_LEFT");
break; break;
default: default:
break; break;
} }
TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment); TextPaint paint = Cocos2dxBitmap.newPaint(fontName, fontSize);
if (stroke) { if (stroke) {
paint.setStyle(TextPaint.Style.STROKE); paint.setStyle(TextPaint.Style.STROKE);
paint.setStrokeWidth(strokeSize); paint.setStrokeWidth(strokeSize);
@ -164,8 +163,7 @@ public final class Cocos2dxBitmap {
return true; return true;
} }
private static TextPaint newPaint(final String fontName, final int fontSize, private static TextPaint newPaint(final String fontName, final int fontSize) {
final int horizontalAlignment) {
final TextPaint paint = new TextPaint(); final TextPaint paint = new TextPaint();
paint.setTextSize(fontSize); paint.setTextSize(fontSize);
paint.setAntiAlias(true); paint.setAntiAlias(true);

View File

@ -42,7 +42,7 @@ THE SOFTWARE.
#define LOG_TAG "main" #define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #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; using namespace cocos2d;
@ -53,6 +53,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{ {
JniHelper::setJavaVM(vm); JniHelper::setJavaVM(vm);
cocos_android_app_init(JniHelper::getEnv());
return JNI_VERSION_1_4; return JNI_VERSION_1_4;
} }
@ -66,8 +68,6 @@ JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, j
glview->setFrameSize(w, h); glview->setFrameSize(w, h);
director->setOpenGLView(glview); director->setOpenGLView(glview);
//cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->run(); cocos2d::Application::getInstance()->run();
} }
else 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) JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz)
{ {
cocos_android_app_init(env, thiz);
cocos2d::Application::getInstance()->initGLContextAttrs(); cocos2d::Application::getInstance()->initGLContextAttrs();
GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs(); GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();

View File

@ -1427,7 +1427,7 @@ const Rect& Texture2D::getSpriteFrameCapInset( cocos2d::SpriteFrame *spriteFrame
} }
else else
{ {
auto capInsetMap = this->_ninePatchInfo->capInsetMap; auto &capInsetMap = this->_ninePatchInfo->capInsetMap;
if(capInsetMap.find(spriteFrame) != capInsetMap.end()) if(capInsetMap.find(spriteFrame) != capInsetMap.end())
{ {
return capInsetMap.at(spriteFrame); return capInsetMap.at(spriteFrame);

View File

@ -108,7 +108,13 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
if (texture != nullptr) if (texture != nullptr)
{ {
callback(texture); if (callback) callback(texture);
return;
}
// check if file exists
if ( fullpath.empty() || ! FileUtils::getInstance()->isFileExist( fullpath ) ) {
if (callback) callback(nullptr);
return; return;
} }

View File

@ -1292,9 +1292,29 @@
var get3DVector = function(json, name, defValue){ var get3DVector = function(json, name, defValue){
var x = defValue, y = defValue, z = defValue; var x = defValue, y = defValue, z = defValue;
if(json && name && json[name]){ if(json && name && json[name]){
x = null != json[name]["ValueX"] ? json[name]["ValueX"] : defValue; if(undefined !== json[name]["ValueX"]) {
y = null != json[name]["ValueY"] ? json[name]["ValueY"] : defValue; x = json[name]["ValueX"];
z = null != json[name]["ValueZ"] ? json[name]["ValueZ"] : defValue; } 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); var vec3 = cc.math.vec3(x, y, z);
return vec3; return vec3;
@ -1343,8 +1363,18 @@
var nearClip = 1; var nearClip = 1;
var farClip = 500; var farClip = 500;
if(json["ClipPlane"]){ if(json["ClipPlane"]){
if(undefined !== json["ClipPlane"]["ValueX"]) {
nearClip = 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"]; farClip = json["ClipPlane"]["ValueY"];
} else if(undefined !== json["ClipPlane"]["Y"]) {
farClip = json["ClipPlane"]["Y"];
}
if(null === nearClip || isNaN(nearClip)) if(null === nearClip || isNaN(nearClip))
nearClip = 1; nearClip = 1;
if(null === farClip || isNaN(farClip)) if(null === farClip || isNaN(farClip))

View File

@ -151,7 +151,7 @@ namespace ui {
auto spriteFrame = sprite->getSpriteFrame(); auto spriteFrame = sprite->getSpriteFrame();
if (texture->isContain9PatchInfo()) if (texture->isContain9PatchInfo())
{ {
auto parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame); auto& parsedCapInset = texture->getSpriteFrameCapInset(spriteFrame);
if(!parsedCapInset.equals(Rect::ZERO)) if(!parsedCapInset.equals(Rect::ZERO))
{ {
this->_isPatch9 = true; this->_isPatch9 = true;

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -10,7 +10,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -11,7 +11,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -11,7 +11,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -10,7 +10,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -10,7 +10,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -2000,6 +2000,7 @@ void ParticleIssue12310::onEnter()
addChild(particle); addChild(particle);
_emitter = particle; _emitter = particle;
_emitter->retain();
auto particle2 = ParticleSystemQuad::create("Particles/BoilingFoamStar.plist"); auto particle2 = ParticleSystemQuad::create("Particles/BoilingFoamStar.plist");
particle2->setPosition(Vec2(winSize.width * 0.65f, winSize.height * 0.5f)); particle2->setPosition(Vec2(winSize.width * 0.65f, winSize.height * 0.5f));

View File

@ -13,9 +13,9 @@ protected:
cocos2d::LayerColor* _color; cocos2d::LayerColor* _color;
public: public:
~ParticleDemo(void); ~ParticleDemo();
virtual void onEnter(void); virtual void onEnter();
virtual std::string title() const override; virtual std::string title() const override;
virtual std::string subtitle() const override; virtual std::string subtitle() const override;

View File

@ -90,8 +90,6 @@ bool Scene3DTestScene::init()
{ {
CC_BREAK_IF(false == TerrainWalkThru::init()); CC_BREAK_IF(false == TerrainWalkThru::init());
Director::getInstance()->setDisplayStats(false);
// prepare for camera creation, we need create three custom cameras // prepare for camera creation, we need create three custom cameras
_gameCameras.resize(LAYER_COUNT); _gameCameras.resize(LAYER_COUNT);

View File

@ -232,8 +232,7 @@ bool UITextTest_IgnoreConentSize::init()
widgetSize.height / 2.0f)); widgetSize.height / 2.0f));
leftText->ignoreContentAdaptWithSize(false); leftText->ignoreContentAdaptWithSize(false);
leftText->setTextAreaSize(Size(60,60)); leftText->setTextAreaSize(Size(60,60));
leftText->setString("Text line with break\nText line \ leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
with break\nText line with break\nText line with break\n");
leftText->setTouchScaleChangeEnabled(true); leftText->setTouchScaleChangeEnabled(true);
leftText->setTouchEnabled(true); leftText->setTouchEnabled(true);
_uiLayer->addChild(leftText); _uiLayer->addChild(leftText);
@ -243,8 +242,7 @@ bool UITextTest_IgnoreConentSize::init()
"fonts/Marker Felt.ttf",10); "fonts/Marker Felt.ttf",10);
rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50, rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50,
widgetSize.height / 2.0f)); widgetSize.height / 2.0f));
rightText->setString("Text line with break\nText line \ rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
with break\nText line with break\nText line with break\n");
//note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false) //note:setTextAreaSize must be used with ignoreContentAdaptWithSize(false)
rightText->setTextAreaSize(Size(100,30)); rightText->setTextAreaSize(Size(100,30));
rightText->ignoreContentAdaptWithSize(false); rightText->ignoreContentAdaptWithSize(false);

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -10,7 +10,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -10,7 +10,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm; JavaVM* vm;

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm; JavaVM* vm;

View File

@ -5338,10 +5338,10 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({
//----start59----ctor //----start59----ctor
this._super(); this._super();
var destFactors = [gl.ZERO, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR, gl.SRC_ALPHA, gl.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 = [gl.ZERO, gl.ONE, gl.DST_COLOR, gl.ONE_MINUS_DST_COLOR, gl.DST_ALPHA, gl.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", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"], var destTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "DST_ALPHA", "ONE_MINUS_DST_ALPHA"],
srcTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_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 sourceImg = "Images/dot.png", destImg = "Images/wood.jpg";
var sourceTexture = cc.textureCache.addImage(sourceImg); var sourceTexture = cc.textureCache.addImage(sourceImg);
@ -5355,6 +5355,14 @@ var SpriteBlendFuncTest = SpriteTestDemo.extend({
this.addChild(sourceSprite); this.addChild(sourceSprite);
this.addChild(destSprite); 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; var i, j, title, fontSize, titleLabel;
for(i = 0; i < destTitles.length; i++){ for(i = 0; i < destTitles.length; i++){
title = destTitles[i]; title = destTitles[i];

View File

@ -179,6 +179,10 @@ var transitionsIdx = 0;
// every .Scene each test used must inherit from TestScene, // every .Scene each test used must inherit from TestScene,
// make sure the test have the menu item for back to main menu // make sure the test have the menu item for back to main menu
var TransitionsTestScene = TestScene.extend({ var TransitionsTestScene = TestScene.extend({
onEnter: function () {
this._super();
director.setDepthTest(false);
},
runThisTest:function () { runThisTest:function () {
var layer = new TestLayer1(); var layer = new TestLayer1();
this.addChild(layer); this.addChild(layer);

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate(); AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate(); AppDelegate *pAppDelegate = new (std::nothrow) AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -9,7 +9,7 @@
using namespace cocos2d; using namespace cocos2d;
void cocos_android_app_init (JNIEnv* env, jobject thiz) { void cocos_android_app_init (JNIEnv* env) {
LOGD("cocos_android_app_init"); LOGD("cocos_android_app_init");
AppDelegate *pAppDelegate = new AppDelegate(); AppDelegate *pAppDelegate = new AppDelegate();
} }

View File

@ -1235,17 +1235,20 @@ function LabelCharMapTest.create()
local label1 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist") local label1 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")
layer:addChild(label1, 0, kTagSprite1) layer:addChild(label1, 0, kTagSprite1)
label1:setAnchorPoint(cc.p(0, 0))
label1:setPosition( cc.p(10,100) ) label1:setPosition( cc.p(10,100) )
label1:setOpacity( 200 ) label1:setOpacity( 200 )
local label2 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist") local label2 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")
layer:addChild(label2, 0, kTagSprite2) layer:addChild(label2, 0, kTagSprite2)
label2:setAnchorPoint(cc.p(0, 0))
label2:setPosition( cc.p(10,160) ) label2:setPosition( cc.p(10,160) )
label2:setOpacity( 32 ) label2:setOpacity( 32 )
local label3 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")--32 means Space key local label3 = cc.Label:createWithCharMap("fonts/tuffy_bold_italic-charmap.plist")--32 means Space key
label3:setString("123 Test") label3:setString("123 Test")
layer:addChild(label3, 0, kTagSprite3) layer:addChild(label3, 0, kTagSprite3)
label3:setAnchorPoint(cc.p(0, 0))
label3:setPosition(cc.p(10,220)) label3:setPosition(cc.p(10,220))
local function step(dt) local function step(dt)

View File

@ -14,6 +14,9 @@ import traceback
from os import path, extsep from os import path, extsep
from subprocess import Popen, PIPE, CalledProcessError from subprocess import Popen, PIPE, CalledProcessError
def os_is_win32():
return sys.platform == 'win32'
class UnrecognizedFormat: class UnrecognizedFormat:
def __init__(self, prompt): def __init__(self, prompt):
self._prompt = prompt self._prompt = prompt
@ -66,7 +69,7 @@ class GitArchiver(object):
# Raises an exception if there is no repo under main_repo_abspath. # Raises an exception if there is no repo under main_repo_abspath.
try: 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: except Exception as e:
raise ValueError("Not a git repository (or any of the parent directories).".format(path=main_repo_abspath)) 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: if self.verbose:
print("Compressing {f} => {a}...".format(f=file_path, print("Compressing {f} => {a}...".format(f=file_path,
a=path.join(self.prefix, file_path))) a=path.join(self.prefix, file_path)))
try:
add(file_path, file_path) add(file_path, file_path)
except:
print('add %s failed.' % file_path)
pass
else: else:
print("{f} => {a}".format(f=file_path, print("{f} => {a}".format(f=file_path,
a=path.join(self.prefix, 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), print("Compressing {f} => {a}...".format(f=path.join(self.main_repo_abspath, file_path),
a=path.join(self.prefix, file_path))) a=path.join(self.prefix, file_path)))
try:
add(path.join(self.main_repo_abspath, file_path), file_path) add(path.join(self.main_repo_abspath, file_path), file_path)
except:
print('add %s failed.' % file_path)
pass
else: else:
print("{f} => {a}".format(f=path.join(self.main_repo_abspath, file_path), print("{f} => {a}".format(f=path.join(self.main_repo_abspath, file_path),
a=path.join(self.prefix, 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)) 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)):] path_in_zip = extra_to_zip_file + file_path[(len(extra_folder_path)):]
try:
add(file_path, path_in_zip) add(file_path, path_in_zip)
except:
print('add %s failed.' % file_path)
pass
outfile_name, outfile_ext = path.splitext(output_path) outfile_name, outfile_ext = path.splitext(output_path)
for extra_dir in config_data["extra_dirs"]: for extra_dir in config_data["extra_dirs"]:
@ -242,7 +258,11 @@ class GitArchiver(object):
for f in files: for f in files:
file_path = path.join(root,f) file_path = path.join(root,f)
path_in_zip = file_path[(len(self.main_repo_abspath)+1):] path_in_zip = file_path[(len(self.main_repo_abspath)+1):]
try:
add(file_path, path_in_zip) add(file_path, path_in_zip)
except:
print('add %s failed.' % file_path)
pass
if not dry_run: if not dry_run:
archive.close() archive.close()
@ -273,6 +293,15 @@ class GitArchiver(object):
""" """
components = [] components = []
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)
else:
while not path.samefile(abspath, repo_abspath): while not path.samefile(abspath, repo_abspath):
abspath, tail = path.split(abspath) abspath, tail = path.split(abspath)