mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into issue_9586
This commit is contained in:
commit
8ff0ac6951
10
AUTHORS
10
AUTHORS
|
@ -10,8 +10,8 @@ Core Developers:
|
|||
Hao Wu (Wu-Hao)
|
||||
Qingkui Hu (samuele3hu)
|
||||
Huabing Xu (dabingnn)
|
||||
Wenhai Lin (Dhilan007)
|
||||
Guanghui Qu (andyque)
|
||||
Wenhai Lin (WenhaiLin)
|
||||
Guanghui Qu (zilongshanren)
|
||||
Wensheng Yang (yangws)
|
||||
Yulei Liao (dualface)
|
||||
Huabin Ling (pandamicro)
|
||||
|
@ -402,6 +402,9 @@ Developers:
|
|||
Adds 'setFont' and 'setAnchorPoint' to CCEditBox.
|
||||
Workaround for some problems due to UITextField of CCEditBoxImplIOS is attached as a view above OpenGL view.
|
||||
Enhance ScrollView with easing out scrolling.
|
||||
Add scroll bar feature into ui::ScrollView.
|
||||
Add RadioButton and RaidoButtonGroup widgets.
|
||||
Add a setter for line width in DrawNode.
|
||||
|
||||
Sam Clegg (sbc100)
|
||||
Author of Native Client port.
|
||||
|
@ -584,6 +587,7 @@ Developers:
|
|||
Fixing a bug that the submenu of ExtensionTest in TestCpp can't scroll.
|
||||
Implements a socket.io client extension and adds a test case.
|
||||
Implements 'SIODelegate::fireEventToScript' method to integrate JSB event handling with the original native code.
|
||||
Update socket.io network extension to correctly detect and manage connection to socket.io server versions 0.9.x-1.x
|
||||
|
||||
pktangyue
|
||||
Fixing a bug that CCScale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame.
|
||||
|
@ -759,7 +763,7 @@ Developers:
|
|||
Fix lua project template crash on iOS5.1 device
|
||||
Fix layout constant syntax error in lua-binding
|
||||
|
||||
andyque
|
||||
zilongshanren
|
||||
Fixed a bug that missing to check self assignment of Vector<T>, Map<K,V>, Value and String.
|
||||
Fixed a bug that move assignment operator doesn't clear previous content bug.
|
||||
Fixed the compile error of Map's getRandomObject.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "2d/CCLabel.h"
|
||||
#include "2d/CCFontAtlasCache.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCSpriteBatchNode.h"
|
||||
#include "2d/CCLabelTextFormatter.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
@ -42,6 +43,99 @@ NS_CC_BEGIN
|
|||
|
||||
const int Label::DistanceFieldFontSize = 50;
|
||||
|
||||
/**
|
||||
* LabelLetter used to update the quad in texture atlas without SpriteBatchNode.
|
||||
*/
|
||||
class LabelLetter : public Sprite
|
||||
{
|
||||
public:
|
||||
LabelLetter()
|
||||
{
|
||||
_textureAtlas = nullptr;
|
||||
}
|
||||
|
||||
static LabelLetter* createWithTexture(Texture2D *texture, const Rect& rect, bool rotated = false)
|
||||
{
|
||||
auto letter = new (std::nothrow) LabelLetter();
|
||||
if (letter && letter->initWithTexture(texture, rect, rotated))
|
||||
{
|
||||
letter->setVisible(false);
|
||||
letter->autorelease();
|
||||
return letter;
|
||||
}
|
||||
CC_SAFE_DELETE(letter);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void updateTransform() override
|
||||
{
|
||||
if (isDirty())
|
||||
{
|
||||
_transformToBatch = getNodeToParentTransform();
|
||||
Size &size = _rect.size;
|
||||
|
||||
float x1 = _offsetPosition.x;
|
||||
float y1 = _offsetPosition.y;
|
||||
float x2 = x1 + size.width;
|
||||
float y2 = y1 + size.height;
|
||||
float x = _transformToBatch.m[12];
|
||||
float y = _transformToBatch.m[13];
|
||||
|
||||
float cr = _transformToBatch.m[0];
|
||||
float sr = _transformToBatch.m[1];
|
||||
float cr2 = _transformToBatch.m[5];
|
||||
float sr2 = -_transformToBatch.m[4];
|
||||
float ax = x1 * cr - y1 * sr2 + x;
|
||||
float ay = x1 * sr + y1 * cr2 + y;
|
||||
|
||||
float bx = x2 * cr - y1 * sr2 + x;
|
||||
float by = x2 * sr + y1 * cr2 + y;
|
||||
float cx = x2 * cr - y2 * sr2 + x;
|
||||
float cy = x2 * sr + y2 * cr2 + y;
|
||||
float dx = x1 * cr - y2 * sr2 + x;
|
||||
float dy = x1 * sr + y2 * cr2 + y;
|
||||
|
||||
_quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ);
|
||||
_quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ);
|
||||
_quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ);
|
||||
_quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ);
|
||||
|
||||
if (_textureAtlas)
|
||||
{
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
}
|
||||
|
||||
_recursiveDirty = false;
|
||||
setDirty(false);
|
||||
}
|
||||
|
||||
Node::updateTransform();
|
||||
}
|
||||
|
||||
virtual void updateColor()
|
||||
{
|
||||
if (_textureAtlas == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Color4B color4(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity);
|
||||
// special opacity for premultiplied textures
|
||||
if (_opacityModifyRGB)
|
||||
{
|
||||
color4.r *= _displayedOpacity / 255.0f;
|
||||
color4.g *= _displayedOpacity / 255.0f;
|
||||
color4.b *= _displayedOpacity / 255.0f;
|
||||
}
|
||||
_quad.bl.colors = color4;
|
||||
_quad.br.colors = color4;
|
||||
_quad.tl.colors = color4;
|
||||
_quad.tr.colors = color4;
|
||||
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
}
|
||||
};
|
||||
|
||||
Label* Label::create()
|
||||
{
|
||||
auto ret = new (std::nothrow) Label();
|
||||
|
@ -257,6 +351,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
, _effectColorF(Color4F::BLACK)
|
||||
, _uniformEffectColor(0)
|
||||
, _shadowDirty(false)
|
||||
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
||||
, _insideBounds(true)
|
||||
{
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
@ -265,9 +360,11 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
_purgeTextureListener = EventListenerCustom::create(FontAtlas::CMD_PURGE_FONTATLAS, [this](EventCustom* event){
|
||||
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
|
||||
{
|
||||
Node::removeAllChildrenWithCleanup(true);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
it.second->setTexture(nullptr);
|
||||
}
|
||||
_batchNodes.clear();
|
||||
_batchNodes.push_back(this);
|
||||
|
||||
if (_fontAtlas)
|
||||
{
|
||||
|
@ -282,6 +379,10 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
{
|
||||
_fontAtlas = nullptr;
|
||||
this->setTTFConfig(_fontConfig);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
getLetter(it.first);
|
||||
}
|
||||
}
|
||||
});
|
||||
_eventDispatcher->addEventListenerWithFixedPriority(_resetTextureListener, 2);
|
||||
|
@ -299,6 +400,8 @@ Label::~Label()
|
|||
_eventDispatcher->removeEventListener(_resetTextureListener);
|
||||
|
||||
CC_SAFE_RELEASE_NULL(_reusedLetter);
|
||||
CC_SAFE_RELEASE_NULL(_textSprite);
|
||||
CC_SAFE_RELEASE_NULL(_shadowNode);
|
||||
}
|
||||
|
||||
void Label::reset()
|
||||
|
@ -311,7 +414,6 @@ void Label::reset()
|
|||
_systemFontSize = 12;
|
||||
|
||||
_batchNodes.clear();
|
||||
_batchNodes.push_back(this);
|
||||
|
||||
if (_fontAtlas)
|
||||
{
|
||||
|
@ -384,16 +486,6 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
|||
}
|
||||
|
||||
_fontAtlas = atlas;
|
||||
|
||||
if (_textureAtlas)
|
||||
{
|
||||
_textureAtlas->setTexture(_fontAtlas->getTexture(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30);
|
||||
}
|
||||
|
||||
if (_reusedLetter == nullptr)
|
||||
{
|
||||
_reusedLetter = Sprite::create();
|
||||
|
@ -401,7 +493,6 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
|||
_reusedLetter->retain();
|
||||
_reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
}
|
||||
_reusedLetter->setBatchNode(this);
|
||||
|
||||
if (_fontAtlas)
|
||||
{
|
||||
|
@ -594,12 +685,21 @@ void Label::alignText()
|
|||
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
||||
{
|
||||
auto batchNode = SpriteBatchNode::createWithTexture(textures.at(index));
|
||||
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vec2::ZERO);
|
||||
Node::addChild(batchNode,0,Node::INVALID_TAG);
|
||||
_batchNodes.push_back(batchNode);
|
||||
if (batchNode)
|
||||
{
|
||||
_blendFunc = batchNode->getBlendFunc();
|
||||
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vec2::ZERO);
|
||||
_batchNodes.pushBack(batchNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_batchNodes.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_reusedLetter->setBatchNode(_batchNodes.at(0));
|
||||
|
||||
LabelTextFormatter::createStringSprites(this);
|
||||
if(_maxLineWidth > 0 && _contentSize.width > _maxLineWidth && LabelTextFormatter::multilineText(this) )
|
||||
LabelTextFormatter::createStringSprites(this);
|
||||
|
@ -607,39 +707,36 @@ void Label::alignText()
|
|||
if(_labelWidth > 0 || (_currNumLines > 1 && _hAlignment != TextHAlignment::LEFT))
|
||||
LabelTextFormatter::alignText(this);
|
||||
|
||||
if (!_children.empty())
|
||||
if (!_letters.empty())
|
||||
{
|
||||
int strLen = static_cast<int>(_currentUTF16String.length());
|
||||
Rect uvRect;
|
||||
Sprite* letterSprite;
|
||||
for (auto index = 0; index < _children.size();) {
|
||||
auto child = _children.at(index);
|
||||
int tag = child->getTag();
|
||||
if (tag >= strLen)
|
||||
{
|
||||
child->removeFromParentAndCleanup(true);
|
||||
}
|
||||
else if (tag >= 0)
|
||||
{
|
||||
letterSprite = dynamic_cast<Sprite*>(child);
|
||||
if (letterSprite)
|
||||
{
|
||||
auto& letterDef = _lettersInfo[tag].def;
|
||||
uvRect.size.height = letterDef.height;
|
||||
uvRect.size.width = letterDef.width;
|
||||
uvRect.origin.x = letterDef.U;
|
||||
uvRect.origin.y = letterDef.V;
|
||||
int letterIndex;
|
||||
|
||||
letterSprite->setBatchNode(_batchNodes[letterDef.textureID]);
|
||||
letterSprite->setTextureRect(uvRect, false, uvRect.size);
|
||||
letterSprite->setPosition(_lettersInfo[tag].position.x + letterDef.width/2,
|
||||
_lettersInfo[tag].position.y - letterDef.height/2);
|
||||
}
|
||||
++index;
|
||||
for (auto it = _letters.begin(); it != _letters.end();)
|
||||
{
|
||||
letterIndex = it->first;
|
||||
letterSprite = it->second;
|
||||
|
||||
if (letterIndex >= _limitShowCount)
|
||||
{
|
||||
Node::removeChild(letterSprite, true);
|
||||
it = _letters.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++index;
|
||||
auto& letterDef = _lettersInfo[letterIndex].def;
|
||||
uvRect.size.height = letterDef.height;
|
||||
uvRect.size.width = letterDef.width;
|
||||
uvRect.origin.x = letterDef.U;
|
||||
uvRect.origin.y = letterDef.V;
|
||||
|
||||
letterSprite->setBatchNode(_batchNodes.at(letterDef.textureID));
|
||||
letterSprite->setTextureRect(uvRect, false, uvRect.size);
|
||||
letterSprite->setPosition(_lettersInfo[letterIndex].position.x + letterDef.width / 2,
|
||||
_lettersInfo[letterIndex].position.y - letterDef.height / 2);
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -700,9 +797,9 @@ void Label::updateQuads()
|
|||
_reusedLetter->setTextureRect(_reusedRect,false,_reusedRect.size);
|
||||
|
||||
_reusedLetter->setPosition(_lettersInfo[ctr].position);
|
||||
index = static_cast<int>(_batchNodes[letterDef.textureID]->getTextureAtlas()->getTotalQuads());
|
||||
index = static_cast<int>(_batchNodes.at(letterDef.textureID)->getTextureAtlas()->getTotalQuads());
|
||||
_lettersInfo[ctr].atlasIndex = index;
|
||||
_batchNodes[letterDef.textureID]->insertQuadFromSprite(_reusedLetter,index);
|
||||
_batchNodes.at(letterDef.textureID)->insertQuadFromSprite(_reusedLetter,index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -738,16 +835,6 @@ bool Label::recordPlaceholderInfo(int spriteIndex)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Label::addChild(Node * child, int zOrder/* =0 */, int tag/* =0 */)
|
||||
{
|
||||
CCASSERT(0, "addChild: is not supported on Label.");
|
||||
}
|
||||
|
||||
void Label::sortAllChildren()
|
||||
{
|
||||
// Label ignore sort children
|
||||
}
|
||||
|
||||
void Label::enableGlow(const Color4B& glowColor)
|
||||
{
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
|
@ -821,7 +908,7 @@ void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const
|
|||
{
|
||||
if (shadowColor != _shadowColor4F)
|
||||
{
|
||||
Node::removeChild(_shadowNode, true);
|
||||
_shadowNode->release();
|
||||
_shadowNode = nullptr;
|
||||
createShadowSpriteForSystemFont();
|
||||
}
|
||||
|
@ -872,11 +959,7 @@ void Label::disableEffect(LabelEffect effect)
|
|||
if (_shadowEnabled)
|
||||
{
|
||||
_shadowEnabled = false;
|
||||
if (_shadowNode)
|
||||
{
|
||||
Node::removeChild(_shadowNode, true);
|
||||
_shadowNode = nullptr;
|
||||
}
|
||||
CC_SAFE_RELEASE_NULL(_shadowNode);
|
||||
}
|
||||
break;
|
||||
case cocos2d::LabelEffect::GLOW:
|
||||
|
@ -904,121 +987,6 @@ void Label::setFontScale(float fontScale)
|
|||
Node::setScale(_fontScale);
|
||||
}
|
||||
|
||||
void Label::onDraw(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
// Optimization: Fast Dispatch
|
||||
if( _textureAtlas == NULL || (_batchNodes.size() == 1 && _textureAtlas->getTotalQuads() == 0) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto glprogram = getGLProgram();
|
||||
glprogram->use();
|
||||
GL::blendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
||||
if (_shadowEnabled)
|
||||
{
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
{
|
||||
glprogram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a);
|
||||
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
|
||||
{
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a);
|
||||
}
|
||||
|
||||
getGLProgram()->setUniformsForBuiltins(_shadowTransform);
|
||||
for (const auto &child : _children)
|
||||
{
|
||||
child->updateTransform();
|
||||
}
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Color3B oldColor = _realColor;
|
||||
GLubyte oldOPacity = _displayedOpacity;
|
||||
_displayedOpacity = _shadowOpacity;
|
||||
setColor(_shadowColor3B);
|
||||
|
||||
getGLProgram()->setUniformsForBuiltins(_shadowTransform);
|
||||
for (const auto &child : _children)
|
||||
{
|
||||
child->updateTransform();
|
||||
}
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
|
||||
_displayedOpacity = oldOPacity;
|
||||
setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
glprogram->setUniformsForBuiltins(transform);
|
||||
for(const auto &child: _children)
|
||||
{
|
||||
child->updateTransform();
|
||||
}
|
||||
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
{
|
||||
switch (_currLabelEffect) {
|
||||
case LabelEffect::OUTLINE:
|
||||
//draw text with outline
|
||||
glprogram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
|
||||
for (const auto& batchNode:_batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
|
||||
//draw text without outline
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, 0.f);
|
||||
break;
|
||||
case LabelEffect::GLOW:
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
|
||||
case LabelEffect::NORMAL:
|
||||
glprogram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& batchNode:_batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
}
|
||||
|
||||
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY;
|
||||
#if CC_USE_CULLING
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
||||
if(_insideBounds)
|
||||
#endif
|
||||
{
|
||||
_customCommand.init(_globalZOrder, transform, flags);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::createSpriteForSystemFont()
|
||||
{
|
||||
_currentLabelType = LabelType::STRING_TEXTURE;
|
||||
|
@ -1078,8 +1046,7 @@ void Label::createSpriteForSystemFont()
|
|||
_textSprite->setBlendFunc(_blendFunc);
|
||||
}
|
||||
|
||||
Node::addChild(_textSprite, 0, Node::INVALID_TAG);
|
||||
|
||||
_textSprite->retain();
|
||||
_textSprite->updateDisplayedColor(_displayedColor);
|
||||
_textSprite->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
|
@ -1117,8 +1084,8 @@ void Label::createShadowSpriteForSystemFont()
|
|||
_shadowNode->setCameraMask(getCameraMask());
|
||||
_shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
|
||||
Node::addChild(_shadowNode, 0, Node::INVALID_TAG);
|
||||
|
||||
_shadowNode->retain();
|
||||
_shadowNode->updateDisplayedColor(_displayedColor);
|
||||
_shadowNode->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
|
@ -1126,7 +1093,7 @@ void Label::createShadowSpriteForSystemFont()
|
|||
|
||||
void Label::setCameraMask(unsigned short mask, bool applyChildren)
|
||||
{
|
||||
SpriteBatchNode::setCameraMask(mask, applyChildren);
|
||||
Node::setCameraMask(mask, applyChildren);
|
||||
|
||||
if (_textSprite)
|
||||
{
|
||||
|
@ -1163,7 +1130,6 @@ void Label::updateContent()
|
|||
if (_fontAtlas)
|
||||
{
|
||||
_batchNodes.clear();
|
||||
_batchNodes.push_back(this);
|
||||
|
||||
FontAtlasCache::releaseFontAtlas(_fontAtlas);
|
||||
_fontAtlas = nullptr;
|
||||
|
@ -1172,16 +1138,8 @@ void Label::updateContent()
|
|||
_systemFontDirty = false;
|
||||
}
|
||||
|
||||
if (_textSprite)
|
||||
{
|
||||
Node::removeChild(_textSprite, true);
|
||||
_textSprite = nullptr;
|
||||
if (_shadowNode)
|
||||
{
|
||||
Node::removeChild(_shadowNode, true);
|
||||
_shadowNode = nullptr;
|
||||
}
|
||||
}
|
||||
CC_SAFE_RELEASE_NULL(_textSprite);
|
||||
CC_SAFE_RELEASE_NULL(_shadowNode);
|
||||
|
||||
if (_fontAtlas)
|
||||
{
|
||||
|
@ -1206,9 +1164,127 @@ void Label::updateContent()
|
|||
_contentDirty = false;
|
||||
}
|
||||
|
||||
void Label::onDrawShadow(GLProgram* glProgram)
|
||||
{
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
{
|
||||
glProgram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a);
|
||||
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
|
||||
{
|
||||
glProgram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a);
|
||||
}
|
||||
|
||||
glProgram->setUniformsForBuiltins(_shadowTransform);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
it.second->updateTransform();
|
||||
}
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Color3B oldColor = _realColor;
|
||||
GLubyte oldOPacity = _displayedOpacity;
|
||||
_displayedOpacity = _shadowOpacity;
|
||||
setColor(_shadowColor3B);
|
||||
|
||||
glProgram->setUniformsForBuiltins(_shadowTransform);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
it.second->updateTransform();
|
||||
}
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
|
||||
_displayedOpacity = oldOPacity;
|
||||
setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::onDraw(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
auto glprogram = getGLProgram();
|
||||
glprogram->use();
|
||||
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
|
||||
|
||||
if (_shadowEnabled)
|
||||
{
|
||||
onDrawShadow(glprogram);
|
||||
}
|
||||
|
||||
glprogram->setUniformsForBuiltins(transform);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
it.second->updateTransform();
|
||||
}
|
||||
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
{
|
||||
switch (_currLabelEffect) {
|
||||
case LabelEffect::OUTLINE:
|
||||
//draw text with outline
|
||||
glprogram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a);
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
|
||||
//draw text without outline
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, 0.f);
|
||||
break;
|
||||
case LabelEffect::GLOW:
|
||||
glprogram->setUniformLocationWith4f(_uniformEffectColor,
|
||||
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
|
||||
case LabelEffect::NORMAL:
|
||||
glprogram->setUniformLocationWith4f(_uniformTextColor,
|
||||
_textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& batchNode : _batchNodes)
|
||||
{
|
||||
batchNode->getTextureAtlas()->drawQuads();
|
||||
}
|
||||
}
|
||||
|
||||
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if (_batchNodes.empty() || _limitShowCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY;
|
||||
#if CC_USE_CULLING
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
||||
if (_insideBounds)
|
||||
#endif
|
||||
{
|
||||
_customCommand.init(_globalZOrder, transform, flags);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (! _visible || _originalUTF8String.empty())
|
||||
if (! _visible || (_originalUTF8String.empty() && _children.empty()) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1220,7 +1296,8 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
|
|||
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || (flags & FLAGS_DIRTY_MASK)))
|
||||
if (!_originalUTF8String.empty() && _shadowEnabled && _shadowBlurRadius <= 0
|
||||
&& (_shadowDirty || (flags & FLAGS_DIRTY_MASK)))
|
||||
{
|
||||
_position.x += _shadowOffset.width;
|
||||
_position.y += _shadowOffset.height;
|
||||
|
@ -1235,7 +1312,8 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
|
|||
_shadowDirty = false;
|
||||
}
|
||||
|
||||
if (!_textSprite && !isVisitableByVisitingCamera())
|
||||
bool visibleByCamera = isVisitableByVisitingCamera();
|
||||
if (_children.empty() && !_textSprite && !visibleByCamera)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1246,6 +1324,41 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
|
|||
_director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
_director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
if (!_children.empty())
|
||||
{
|
||||
sortAllChildren();
|
||||
|
||||
int i = 0;
|
||||
// draw children zOrder < 0
|
||||
for (; i < _children.size(); i++)
|
||||
{
|
||||
auto node = _children.at(i);
|
||||
|
||||
if (node && node->getLocalZOrder() < 0)
|
||||
node->visit(renderer, _modelViewTransform, flags);
|
||||
else
|
||||
break;
|
||||
}
|
||||
// self draw
|
||||
if (visibleByCamera)
|
||||
this->drawSelf(renderer, flags);
|
||||
|
||||
for (auto it = _children.cbegin() + i; it != _children.cend(); ++it)
|
||||
{
|
||||
(*it)->visit(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
}
|
||||
else if (visibleByCamera)
|
||||
{
|
||||
this->drawSelf(renderer, flags);
|
||||
}
|
||||
|
||||
_director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
}
|
||||
|
||||
void Label::drawSelf(Renderer* renderer, uint32_t flags)
|
||||
{
|
||||
if (_textSprite)
|
||||
{
|
||||
if (_shadowNode)
|
||||
|
@ -1258,12 +1371,6 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
|
|||
{
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
_director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
// FIX ME: Why need to set _orderOfArrival to 0??
|
||||
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
||||
// setOrderOfArrival(0);
|
||||
}
|
||||
|
||||
void Label::setSystemFontName(const std::string& systemFont)
|
||||
|
@ -1287,45 +1394,63 @@ void Label::setSystemFontSize(float fontSize)
|
|||
///// PROTOCOL STUFF
|
||||
Sprite * Label::getLetter(int letterIndex)
|
||||
{
|
||||
if (_systemFontDirty || _currentLabelType == LabelType::STRING_TEXTURE)
|
||||
Sprite* letter = nullptr;
|
||||
do
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (_contentDirty)
|
||||
{
|
||||
updateContent();
|
||||
}
|
||||
|
||||
if (! _textSprite && letterIndex < _limitShowCount)
|
||||
{
|
||||
const auto &letter = _lettersInfo[letterIndex];
|
||||
|
||||
if(! letter.def.validDefinition)
|
||||
return nullptr;
|
||||
|
||||
Sprite* sp = static_cast<Sprite*>(this->getChildByTag(letterIndex));
|
||||
|
||||
if (!sp)
|
||||
if (_systemFontDirty || _currentLabelType == LabelType::STRING_TEXTURE)
|
||||
{
|
||||
Rect uvRect;
|
||||
uvRect.size.height = letter.def.height;
|
||||
uvRect.size.width = letter.def.width;
|
||||
uvRect.origin.x = letter.def.U;
|
||||
uvRect.origin.y = letter.def.V;
|
||||
|
||||
sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect);
|
||||
sp->setBatchNode(_batchNodes[letter.def.textureID]);
|
||||
sp->setPosition(letter.position.x + uvRect.size.width / 2,
|
||||
letter.position.y - uvRect.size.height / 2);
|
||||
sp->setOpacity(_realOpacity);
|
||||
|
||||
_batchNodes[letter.def.textureID]->addSpriteWithoutQuad(sp, letter.atlasIndex, letterIndex);
|
||||
break;
|
||||
}
|
||||
return sp;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
auto contentDirty = _contentDirty;
|
||||
if (contentDirty)
|
||||
{
|
||||
updateContent();
|
||||
}
|
||||
|
||||
if (_textSprite == nullptr && letterIndex < _limitShowCount)
|
||||
{
|
||||
const auto &letterInfo = _lettersInfo[letterIndex];
|
||||
if (!letterInfo.def.validDefinition)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (_letters.find(letterIndex) != _letters.end())
|
||||
{
|
||||
letter = _letters[letterIndex];
|
||||
}
|
||||
|
||||
auto textureID = letterInfo.def.textureID;
|
||||
Rect uvRect;
|
||||
uvRect.size.height = letterInfo.def.height;
|
||||
uvRect.size.width = letterInfo.def.width;
|
||||
uvRect.origin.x = letterInfo.def.U;
|
||||
uvRect.origin.y = letterInfo.def.V;
|
||||
|
||||
if (letter == nullptr)
|
||||
{
|
||||
letter = LabelLetter::createWithTexture(_fontAtlas->getTexture(textureID), uvRect);
|
||||
letter->setTextureAtlas(_batchNodes.at(textureID)->getTextureAtlas());
|
||||
letter->setAtlasIndex(letterInfo.atlasIndex);
|
||||
|
||||
letter->setPosition(letterInfo.position.x + uvRect.size.width / 2,
|
||||
letterInfo.position.y - uvRect.size.height / 2);
|
||||
letter->setOpacity(_realOpacity);
|
||||
addChild(letter);
|
||||
|
||||
_letters[letterIndex] = letter;
|
||||
}
|
||||
else if (contentDirty)
|
||||
{
|
||||
letter->setTexture(_fontAtlas->getTexture(textureID));
|
||||
letter->setTextureRect(uvRect, false, uvRect.size);
|
||||
letter->setTextureAtlas(_batchNodes.at(textureID)->getTextureAtlas());
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
|
||||
return letter;
|
||||
}
|
||||
|
||||
void Label::setLineHeight(float height)
|
||||
|
@ -1416,10 +1541,7 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
|||
|
||||
void Label::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
updateColor();
|
||||
Node::updateDisplayedColor(parentColor);
|
||||
|
||||
if (_textSprite)
|
||||
{
|
||||
|
@ -1433,8 +1555,7 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
|
|||
|
||||
void Label::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
updateColor();
|
||||
Node::updateDisplayedOpacity(parentOpacity);
|
||||
|
||||
if (_textSprite)
|
||||
{
|
||||
|
@ -1468,7 +1589,7 @@ void Label::setTextColor(const Color4B &color)
|
|||
|
||||
void Label::updateColor()
|
||||
{
|
||||
if (nullptr == _textureAtlas)
|
||||
if (_batchNodes.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1539,4 +1660,23 @@ void Label::setBlendFunc(const BlendFunc &blendFunc)
|
|||
}
|
||||
}
|
||||
|
||||
void Label::removeAllChildrenWithCleanup(bool cleanup)
|
||||
{
|
||||
Node::removeAllChildrenWithCleanup(cleanup);
|
||||
_letters.clear();
|
||||
}
|
||||
|
||||
void Label::removeChild(Node* child, bool cleanup /* = true */)
|
||||
{
|
||||
Node::removeChild(child, cleanup);
|
||||
for (auto it : _letters)
|
||||
{
|
||||
if (it.second == child)
|
||||
{
|
||||
_letters.erase(it.first);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#ifndef _COCOS2D_CCLABEL_H_
|
||||
#define _COCOS2D_CCLABEL_H_
|
||||
|
||||
#include "2d/CCSpriteBatchNode.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "base/ccTypes.h"
|
||||
|
@ -83,8 +83,11 @@ typedef struct _ttfConfig
|
|||
}
|
||||
}TTFConfig;
|
||||
|
||||
class Sprite;
|
||||
class SpriteBatchNode;
|
||||
|
||||
/**
|
||||
* @brief Label is a subclass of SpriteBatchNode that knows how to render text labels.
|
||||
* @brief Label is a subclass of Node that knows how to render text labels.
|
||||
*
|
||||
* Label can be created with:
|
||||
* - A true type font file.
|
||||
|
@ -99,7 +102,7 @@ typedef struct _ttfConfig
|
|||
* - http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
||||
* @js NA
|
||||
*/
|
||||
class CC_DLL Label : public SpriteBatchNode, public LabelProtocol
|
||||
class CC_DLL Label : public Node, public LabelProtocol, public BlendProtocol
|
||||
{
|
||||
public:
|
||||
static const int DistanceFieldFontSize;
|
||||
|
@ -435,6 +438,7 @@ public:
|
|||
|
||||
FontAtlas* getFontAtlas() { return _fontAtlas; }
|
||||
|
||||
virtual const BlendFunc& getBlendFunc() const override { return _blendFunc; }
|
||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
|
@ -448,9 +452,6 @@ public:
|
|||
virtual float getScaleX() const override;
|
||||
virtual float getScaleY() const override;
|
||||
|
||||
virtual void addChild(Node * child, int zOrder=0, int tag=0) override;
|
||||
virtual void sortAllChildren() override;
|
||||
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
virtual const Size& getContentSize() const override;
|
||||
|
@ -462,6 +463,9 @@ public:
|
|||
|
||||
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
|
||||
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||
virtual void removeChild(Node* child, bool cleanup = true) override;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
|
||||
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
||||
TextVAlignment vAlignment = TextVAlignment::TOP);
|
||||
|
@ -491,6 +495,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
protected:
|
||||
void onDraw(const Mat4& transform, bool transformUpdated);
|
||||
void onDrawShadow(GLProgram* glProgram);
|
||||
|
||||
struct LetterInfo
|
||||
{
|
||||
|
@ -533,6 +538,8 @@ protected:
|
|||
|
||||
void reset();
|
||||
|
||||
void drawSelf(Renderer* renderer, uint32_t flags);
|
||||
|
||||
std::string _bmFontPath;
|
||||
|
||||
bool _isOpacityModifyRGB;
|
||||
|
@ -543,7 +550,7 @@ protected:
|
|||
float _systemFontSize;
|
||||
LabelType _currentLabelType;
|
||||
|
||||
std::vector<SpriteBatchNode*> _batchNodes;
|
||||
Vector<SpriteBatchNode*> _batchNodes;
|
||||
FontAtlas * _fontAtlas;
|
||||
std::vector<LetterInfo> _lettersInfo;
|
||||
EventListenerCustom* _purgeTextureListener;
|
||||
|
@ -607,9 +614,12 @@ protected:
|
|||
|
||||
bool _clipEnabled;
|
||||
bool _blendFuncDirty;
|
||||
BlendFunc _blendFunc;
|
||||
/// whether or not the sprite was inside bounds the previous frame
|
||||
bool _insideBounds;
|
||||
|
||||
std::unordered_map<int, Sprite*> _letters;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
||||
|
||||
|
|
|
@ -43,12 +43,6 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
|
||||
#define RENDER_IN_SUBPIXEL
|
||||
#else
|
||||
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
||||
#endif
|
||||
|
||||
// MARK: create, init, dealloc
|
||||
Sprite* Sprite::createWithTexture(Texture2D *texture)
|
||||
{
|
||||
|
@ -343,7 +337,7 @@ void Sprite::setTexture(const std::string &filename)
|
|||
void Sprite::setTexture(Texture2D *texture)
|
||||
{
|
||||
// If batchnode, then texture id should be the same
|
||||
CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode");
|
||||
CCASSERT(! _batchNode || (texture && texture->getName() == _batchNode->getTexture()->getName()), "CCSprite: Batched sprites should use the same texture as the batchnode");
|
||||
// accept texture==nil as argument
|
||||
CCASSERT( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
|
||||
|
||||
|
@ -626,10 +620,10 @@ void Sprite::updateTransform(void)
|
|||
float dx = x1 * cr - y2 * sr2 + x;
|
||||
float dy = x1 * sr + y2 * cr2 + y;
|
||||
|
||||
_quad.bl.vertices.set(RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ);
|
||||
_quad.br.vertices.set(RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ);
|
||||
_quad.tl.vertices.set(RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ);
|
||||
_quad.tr.vertices.set(RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ);
|
||||
_quad.bl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(ax), SPRITE_RENDER_IN_SUBPIXEL(ay), _positionZ);
|
||||
_quad.br.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(bx), SPRITE_RENDER_IN_SUBPIXEL(by), _positionZ);
|
||||
_quad.tl.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(dx), SPRITE_RENDER_IN_SUBPIXEL(dy), _positionZ);
|
||||
_quad.tr.vertices.set(SPRITE_RENDER_IN_SUBPIXEL(cx), SPRITE_RENDER_IN_SUBPIXEL(cy), _positionZ);
|
||||
}
|
||||
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
|
|
|
@ -47,6 +47,16 @@ class Size;
|
|||
class Texture2D;
|
||||
struct transformValues_;
|
||||
|
||||
#ifdef SPRITE_RENDER_IN_SUBPIXEL
|
||||
#undef SPRITE_RENDER_IN_SUBPIXEL
|
||||
#endif
|
||||
|
||||
#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
|
||||
#define SPRITE_RENDER_IN_SUBPIXEL
|
||||
#else
|
||||
#define SPRITE_RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup _2d
|
||||
* @{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 Chris Hannon http://www.channon.us
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
Copyright (c) 2015 Chris Hannon http://www.channon.us
|
||||
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -59,10 +59,10 @@ in the onClose method the pointer should be set to NULL or used to connect to a
|
|||
#ifndef __CC_SOCKETIO_H__
|
||||
#define __CC_SOCKETIO_H__
|
||||
|
||||
#include <string>
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "base/CCMap.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @addtogroup network
|
||||
|
@ -103,22 +103,22 @@ public:
|
|||
/** Destructor of SIODelegate. */
|
||||
virtual ~SIODelegate() {}
|
||||
/**
|
||||
* Pure virtual callback function, this function should be overrided by the subclass.
|
||||
* This is kept for backwards compatibility, connect is now fired as a socket.io event "connect"
|
||||
*
|
||||
* This function would be called when the related SIOClient object recevie messages that mean it have connected to endpoint sucessfully.
|
||||
*
|
||||
* @param client the connected SIOClient object.
|
||||
*/
|
||||
virtual void onConnect(SIOClient* client) = 0;
|
||||
virtual void onConnect(SIOClient* client) { CC_UNUSED_PARAM(client); CCLOG("SIODelegate onConnect fired"); };
|
||||
/**
|
||||
* Pure virtual callback function, this function should be overrided by the subclass.
|
||||
* This is kept for backwards compatibility, message is now fired as a socket.io event "message"
|
||||
*
|
||||
* This function would be called wwhen the related SIOClient object recevie message or json message.
|
||||
*
|
||||
* @param client the connected SIOClient object.
|
||||
* @param data the message,it could be json message
|
||||
*/
|
||||
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
|
||||
virtual void onMessage(SIOClient* client, const std::string& data) { CC_UNUSED_PARAM(client); CCLOG("SIODelegate onMessage fired with data: %s", data.c_str()); };
|
||||
/**
|
||||
* Pure virtual callback function, this function should be overrided by the subclass.
|
||||
*
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
* @param eventName the event's name.
|
||||
* @param data the event's data information.
|
||||
*/
|
||||
virtual void fireEventToScript(SIOClient* client, const std::string& eventName, const std::string& data) { CCLOG("SIODelegate event '%s' fired with data: %s", eventName.c_str(), data.c_str()); };
|
||||
virtual void fireEventToScript(SIOClient* client, const std::string& eventName, const std::string& data) { CC_UNUSED_PARAM(client); CCLOG("SIODelegate event '%s' fired with data: %s", eventName.c_str(), data.c_str()); };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
|
||||
void onOpen();
|
||||
void onConnect();
|
||||
void receivedDisconnect();
|
||||
void socketClosed();
|
||||
|
||||
friend class SIOClientImpl;
|
||||
|
||||
|
@ -242,13 +242,13 @@ public:
|
|||
*
|
||||
* @param s message.
|
||||
*/
|
||||
void send(std::string s);
|
||||
void send(const std::string& s);
|
||||
/**
|
||||
* Emit the eventname and the args to the endpoint that _path point to.
|
||||
* @param eventname
|
||||
* @param args
|
||||
*/
|
||||
void emit(std::string eventname, std::string args);
|
||||
void emit(const std::string& eventname, const std::string& args);
|
||||
/**
|
||||
* Used to register a socket.io event callback.
|
||||
* Event argument should be passed using CC_CALLBACK2(&Base::function, this).
|
||||
|
|
|
@ -11439,268 +11439,6 @@ DrawNode : function (
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class SpriteBatchNode
|
||||
*/
|
||||
cc.SpriteBatchNode = {
|
||||
|
||||
/**
|
||||
* @method appendChild
|
||||
* @param {cc.Sprite} arg0
|
||||
*/
|
||||
appendChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method addSpriteWithoutQuad
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {int} arg1
|
||||
* @param {int} arg2
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
addSpriteWithoutQuad : function (
|
||||
sprite,
|
||||
int,
|
||||
int
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method reorderBatch
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
reorderBatch : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
* @param {long} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithTexture : function (
|
||||
texture2d,
|
||||
long
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getBlendFunc
|
||||
* @return {cc.BlendFunc}
|
||||
*/
|
||||
getBlendFunc : function (
|
||||
)
|
||||
{
|
||||
return cc.BlendFunc;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method lowestAtlasIndexInChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @return {long}
|
||||
*/
|
||||
lowestAtlasIndexInChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method atlasIndexForChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {int} arg1
|
||||
* @return {long}
|
||||
*/
|
||||
atlasIndexForChild : function (
|
||||
sprite,
|
||||
int
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTextureAtlas
|
||||
* @param {cc.TextureAtlas} arg0
|
||||
*/
|
||||
setTextureAtlas : function (
|
||||
textureatlas
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithFile
|
||||
* @param {String} arg0
|
||||
* @param {long} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithFile : function (
|
||||
str,
|
||||
long
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTexture
|
||||
* @return {cc.Texture2D}
|
||||
*/
|
||||
getTexture : function (
|
||||
)
|
||||
{
|
||||
return cc.Texture2D;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method increaseAtlasCapacity
|
||||
*/
|
||||
increaseAtlasCapacity : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTextureAtlas
|
||||
* @return {cc.TextureAtlas}
|
||||
*/
|
||||
getTextureAtlas : function (
|
||||
)
|
||||
{
|
||||
return cc.TextureAtlas;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method insertQuadFromSprite
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {long} arg1
|
||||
*/
|
||||
insertQuadFromSprite : function (
|
||||
sprite,
|
||||
long
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
*/
|
||||
setTexture : function (
|
||||
texture2d
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method rebuildIndexInOrder
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {long} arg1
|
||||
* @return {long}
|
||||
*/
|
||||
rebuildIndexInOrder : function (
|
||||
sprite,
|
||||
long
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method highestAtlasIndexInChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @return {long}
|
||||
*/
|
||||
highestAtlasIndexInChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeChildAtIndex
|
||||
* @param {long} arg0
|
||||
* @param {bool} arg1
|
||||
*/
|
||||
removeChildAtIndex : function (
|
||||
long,
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeSpriteFromAtlas
|
||||
* @param {cc.Sprite} arg0
|
||||
*/
|
||||
removeSpriteFromAtlas : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setBlendFunc
|
||||
* @param {cc.BlendFunc} arg0
|
||||
*/
|
||||
setBlendFunc : function (
|
||||
blendfunc
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @param {String} arg0
|
||||
* @param {long} arg1
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
create : function (
|
||||
str,
|
||||
long
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method createWithTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
* @param {long} arg1
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
createWithTexture : function (
|
||||
texture2d,
|
||||
long
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method SpriteBatchNode
|
||||
* @constructor
|
||||
*/
|
||||
SpriteBatchNode : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class Label
|
||||
*/
|
||||
|
@ -11776,6 +11514,16 @@ getTextColor : function (
|
|||
return cc.Color4B;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getBlendFunc
|
||||
* @return {cc.BlendFunc}
|
||||
*/
|
||||
getBlendFunc : function (
|
||||
)
|
||||
{
|
||||
return cc.BlendFunc;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setWidth
|
||||
* @param {float} arg0
|
||||
|
@ -11930,6 +11678,16 @@ getAdditionalKerning : function (
|
|||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeAllChildrenWithCleanup
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
removeAllChildrenWithCleanup : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setCharMap
|
||||
* @param {cc.Texture2D|String|String} texture2d
|
||||
|
@ -12090,6 +11848,16 @@ getSystemFontSize : function (
|
|||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setBlendFunc
|
||||
* @param {cc.BlendFunc} arg0
|
||||
*/
|
||||
setBlendFunc : function (
|
||||
blendfunc
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTextAlignment
|
||||
* @return {cc.TextHAlignment}
|
||||
|
@ -20713,6 +20481,268 @@ AnimationCache : function (
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class SpriteBatchNode
|
||||
*/
|
||||
cc.SpriteBatchNode = {
|
||||
|
||||
/**
|
||||
* @method appendChild
|
||||
* @param {cc.Sprite} arg0
|
||||
*/
|
||||
appendChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method addSpriteWithoutQuad
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {int} arg1
|
||||
* @param {int} arg2
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
addSpriteWithoutQuad : function (
|
||||
sprite,
|
||||
int,
|
||||
int
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method reorderBatch
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
reorderBatch : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
* @param {long} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithTexture : function (
|
||||
texture2d,
|
||||
long
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getBlendFunc
|
||||
* @return {cc.BlendFunc}
|
||||
*/
|
||||
getBlendFunc : function (
|
||||
)
|
||||
{
|
||||
return cc.BlendFunc;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method lowestAtlasIndexInChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @return {long}
|
||||
*/
|
||||
lowestAtlasIndexInChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method atlasIndexForChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {int} arg1
|
||||
* @return {long}
|
||||
*/
|
||||
atlasIndexForChild : function (
|
||||
sprite,
|
||||
int
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTextureAtlas
|
||||
* @param {cc.TextureAtlas} arg0
|
||||
*/
|
||||
setTextureAtlas : function (
|
||||
textureatlas
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithFile
|
||||
* @param {String} arg0
|
||||
* @param {long} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithFile : function (
|
||||
str,
|
||||
long
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTexture
|
||||
* @return {cc.Texture2D}
|
||||
*/
|
||||
getTexture : function (
|
||||
)
|
||||
{
|
||||
return cc.Texture2D;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method increaseAtlasCapacity
|
||||
*/
|
||||
increaseAtlasCapacity : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTextureAtlas
|
||||
* @return {cc.TextureAtlas}
|
||||
*/
|
||||
getTextureAtlas : function (
|
||||
)
|
||||
{
|
||||
return cc.TextureAtlas;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method insertQuadFromSprite
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {long} arg1
|
||||
*/
|
||||
insertQuadFromSprite : function (
|
||||
sprite,
|
||||
long
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
*/
|
||||
setTexture : function (
|
||||
texture2d
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method rebuildIndexInOrder
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {long} arg1
|
||||
* @return {long}
|
||||
*/
|
||||
rebuildIndexInOrder : function (
|
||||
sprite,
|
||||
long
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method highestAtlasIndexInChild
|
||||
* @param {cc.Sprite} arg0
|
||||
* @return {long}
|
||||
*/
|
||||
highestAtlasIndexInChild : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeChildAtIndex
|
||||
* @param {long} arg0
|
||||
* @param {bool} arg1
|
||||
*/
|
||||
removeChildAtIndex : function (
|
||||
long,
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeSpriteFromAtlas
|
||||
* @param {cc.Sprite} arg0
|
||||
*/
|
||||
removeSpriteFromAtlas : function (
|
||||
sprite
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setBlendFunc
|
||||
* @param {cc.BlendFunc} arg0
|
||||
*/
|
||||
setBlendFunc : function (
|
||||
blendfunc
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @param {String} arg0
|
||||
* @param {long} arg1
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
create : function (
|
||||
str,
|
||||
long
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method createWithTexture
|
||||
* @param {cc.Texture2D} arg0
|
||||
* @param {long} arg1
|
||||
* @return {cc.SpriteBatchNode}
|
||||
*/
|
||||
createWithTexture : function (
|
||||
texture2d,
|
||||
long
|
||||
)
|
||||
{
|
||||
return cc.SpriteBatchNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method SpriteBatchNode
|
||||
* @constructor
|
||||
*/
|
||||
SpriteBatchNode : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class SpriteFrameCache
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2144,36 +2144,6 @@ bool js_cocos2dx_DrawNode_drawCubicBezier(JSContext *cx, uint32_t argc, jsval *v
|
|||
bool js_cocos2dx_DrawNode_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_DrawNode_DrawNode(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_SpriteBatchNode_class;
|
||||
extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype;
|
||||
|
||||
bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_SpriteBatchNode_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_SpriteBatchNode(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Label_class;
|
||||
extern JSObject *jsb_cocos2d_Label_prototype;
|
||||
|
||||
|
@ -2188,6 +2158,7 @@ bool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -2203,6 +2174,7 @@ bool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, js
|
|||
bool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_enableOutline(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getDimensions(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -2218,6 +2190,7 @@ bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -3705,6 +3678,36 @@ bool js_cocos2dx_AnimationCache_destroyInstance(JSContext *cx, uint32_t argc, js
|
|||
bool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_AnimationCache_AnimationCache(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_SpriteBatchNode_class;
|
||||
extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype;
|
||||
|
||||
bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_SpriteBatchNode_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_SpriteBatchNode_SpriteBatchNode(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_SpriteFrameCache_class;
|
||||
extern JSObject *jsb_cocos2d_SpriteFrameCache_prototype;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
--------------------------------
|
||||
-- @module Label
|
||||
-- @extend SpriteBatchNode,LabelProtocol
|
||||
-- @extend Node,LabelProtocol,BlendProtocol
|
||||
-- @parent_module cc
|
||||
|
||||
--------------------------------
|
||||
|
@ -59,6 +59,12 @@
|
|||
-- @param self
|
||||
-- @return color4b_table#color4b_table ret (return value: color4b_table)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] getBlendFunc
|
||||
-- @param self
|
||||
-- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc)
|
||||
|
||||
--------------------------------
|
||||
-- Makes the Label exactly this untransformed width.<br>
|
||||
-- The Label's width be used for text align if the value not equal zero.
|
||||
|
@ -175,6 +181,13 @@
|
|||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] removeAllChildrenWithCleanup
|
||||
-- @param self
|
||||
-- @param #bool cleanup
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
-- @overload self, cc.Texture2D, int, int, int
|
||||
-- @overload self, string, int, int, int
|
||||
|
@ -290,6 +303,13 @@
|
|||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] setBlendFunc
|
||||
-- @param self
|
||||
-- @param #cc.BlendFunc blendFunc
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
-- Returns the Label's text horizontal alignment.
|
||||
-- @function [parent=#Label] getTextAlignment
|
||||
|
@ -390,15 +410,6 @@
|
|||
-- @param #unsigned int flags
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] addChild
|
||||
-- @param self
|
||||
-- @param #cc.Node child
|
||||
-- @param #int zOrder
|
||||
-- @param #int tag
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] setScaleY
|
||||
|
@ -427,10 +438,9 @@
|
|||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] setBlendFunc
|
||||
-- @function [parent=#Label] getScaleX
|
||||
-- @param self
|
||||
-- @param #cc.BlendFunc blendFunc
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
|
@ -441,12 +451,6 @@
|
|||
-- @param #unsigned int parentFlags
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] getScaleX
|
||||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] getDescription
|
||||
|
@ -469,15 +473,17 @@
|
|||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] sortAllChildren
|
||||
-- @function [parent=#Label] updateDisplayedOpacity
|
||||
-- @param self
|
||||
-- @param #unsigned char parentOpacity
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Label] updateDisplayedOpacity
|
||||
-- @function [parent=#Label] removeChild
|
||||
-- @param self
|
||||
-- @param #unsigned char parentOpacity
|
||||
-- @param #cc.Node child
|
||||
-- @param #bool cleanup
|
||||
-- @return Label#Label self (return value: cc.Label)
|
||||
|
||||
--------------------------------
|
||||
|
|
|
@ -766,11 +766,6 @@
|
|||
-- @field [parent=#cc] DrawNode#DrawNode DrawNode preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc SpriteBatchNode
|
||||
-- @field [parent=#cc] SpriteBatchNode#SpriteBatchNode SpriteBatchNode preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc Label
|
||||
-- @field [parent=#cc] Label#Label Label preloaded module
|
||||
|
@ -1241,6 +1236,11 @@
|
|||
-- @field [parent=#cc] AnimationCache#AnimationCache AnimationCache preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc SpriteBatchNode
|
||||
-- @field [parent=#cc] SpriteBatchNode#SpriteBatchNode SpriteBatchNode preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc SpriteFrameCache
|
||||
-- @field [parent=#cc] SpriteFrameCache#SpriteFrameCache SpriteFrameCache preloaded module
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2061,6 +2061,9 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,28 @@
|
|||
//
|
||||
// SocketIOTest.cpp
|
||||
// TestCpp
|
||||
//
|
||||
// Created by Chris Hannon on 6/26/13.
|
||||
//
|
||||
//
|
||||
/****************************************************************************
|
||||
Copyright (c) 2015 Chris Hannon http://www.channon.us
|
||||
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "SocketIOTest.h"
|
||||
#include "../ExtensionsTest.h"
|
||||
|
@ -22,81 +39,82 @@ SocketIOTests::SocketIOTests()
|
|||
SocketIOTest::SocketIOTest()
|
||||
: _sioClient(nullptr)
|
||||
, _sioEndpoint(nullptr)
|
||||
{
|
||||
//set the clients to nullptr until we are ready to connect
|
||||
, _sioClientStatus(nullptr)
|
||||
{//set the clients to nullptr until we are ready to connect
|
||||
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
|
||||
const int MARGIN = 40;
|
||||
const int SPACE = 35;
|
||||
const int MARGIN = 40;
|
||||
const int SPACE = 35;
|
||||
|
||||
auto menuRequest = Menu::create();
|
||||
menuRequest->setPosition(Vec2::ZERO);
|
||||
addChild(menuRequest);
|
||||
auto menuRequest = Menu::create();
|
||||
menuRequest->setPosition(Vec2::ZERO);
|
||||
addChild(menuRequest);
|
||||
|
||||
// Test to create basic client in the default namespace
|
||||
auto labelSIOClient = Label::createWithTTF("Open SocketIO Client", "fonts/arial.ttf", 22);
|
||||
auto itemSIOClient = MenuItemLabel::create(labelSIOClient, CC_CALLBACK_1(SocketIOTest::onMenuSIOClientClicked, this));
|
||||
// Test to create basic client in the default namespace
|
||||
auto labelSIOClient = Label::createWithTTF("Open SocketIO Client", "fonts/arial.ttf", 22);
|
||||
auto itemSIOClient = MenuItemLabel::create(labelSIOClient, CC_CALLBACK_1(SocketIOTest::onMenuSIOClientClicked, this));
|
||||
itemSIOClient->setPosition(Vec2(VisibleRect::left().x + labelSIOClient->getContentSize().width / 2 + 5, winSize.height - MARGIN - SPACE));
|
||||
menuRequest->addChild(itemSIOClient);
|
||||
menuRequest->addChild(itemSIOClient);
|
||||
|
||||
// Test to create a client at the endpoint '/testpoint'
|
||||
auto labelSIOEndpoint = Label::createWithTTF("Open SocketIO Endpoint", "fonts/arial.ttf", 22);
|
||||
auto itemSIOEndpoint = MenuItemLabel::create(labelSIOEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuSIOEndpointClicked, this));
|
||||
auto labelSIOEndpoint = Label::createWithTTF("Open SocketIO Endpoint", "fonts/arial.ttf", 22);
|
||||
auto itemSIOEndpoint = MenuItemLabel::create(labelSIOEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuSIOEndpointClicked, this));
|
||||
itemSIOEndpoint->setPosition(Vec2(VisibleRect::right().x - labelSIOEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - SPACE));
|
||||
menuRequest->addChild(itemSIOEndpoint);
|
||||
menuRequest->addChild(itemSIOEndpoint);
|
||||
|
||||
// Test sending message to default namespace
|
||||
auto labelTestMessage = Label::createWithTTF("Send Test Message", "fonts/arial.ttf", 22);
|
||||
auto itemTestMessage = MenuItemLabel::create(labelTestMessage, CC_CALLBACK_1(SocketIOTest::onMenuTestMessageClicked, this));
|
||||
itemTestMessage->setPosition(Vec2(VisibleRect::left().x + labelTestMessage->getContentSize().width / 2 + 5, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemTestMessage);
|
||||
auto labelTestMessage = Label::createWithTTF("Send Test Message", "fonts/arial.ttf", 22);
|
||||
auto itemTestMessage = MenuItemLabel::create(labelTestMessage, CC_CALLBACK_1(SocketIOTest::onMenuTestMessageClicked, this));
|
||||
itemTestMessage->setPosition(Vec2(VisibleRect::left().x + labelTestMessage->getContentSize().width / 2 + 5, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemTestMessage);
|
||||
|
||||
// Test sending message to the endpoint '/testpoint'
|
||||
auto labelTestMessageEndpoint = Label::createWithTTF("Test Endpoint Message", "fonts/arial.ttf", 22);
|
||||
auto itemTestMessageEndpoint = MenuItemLabel::create(labelTestMessageEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuTestMessageEndpointClicked, this));
|
||||
itemTestMessageEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestMessageEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemTestMessageEndpoint);
|
||||
auto labelTestMessageEndpoint = Label::createWithTTF("Test Endpoint Message", "fonts/arial.ttf", 22);
|
||||
auto itemTestMessageEndpoint = MenuItemLabel::create(labelTestMessageEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuTestMessageEndpointClicked, this));
|
||||
itemTestMessageEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestMessageEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemTestMessageEndpoint);
|
||||
|
||||
// Test sending event 'echotest' to default namespace
|
||||
auto labelTestEvent = Label::createWithTTF("Send Test Event", "fonts/arial.ttf", 22);
|
||||
auto itemTestEvent = MenuItemLabel::create(labelTestEvent, CC_CALLBACK_1(SocketIOTest::onMenuTestEventClicked, this));
|
||||
itemTestEvent->setPosition(Vec2(VisibleRect::left().x + labelTestEvent->getContentSize().width / 2 + 5, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemTestEvent);
|
||||
auto labelTestEvent = Label::createWithTTF("Send Test Event", "fonts/arial.ttf", 22);
|
||||
auto itemTestEvent = MenuItemLabel::create(labelTestEvent, CC_CALLBACK_1(SocketIOTest::onMenuTestEventClicked, this));
|
||||
itemTestEvent->setPosition(Vec2(VisibleRect::left().x + labelTestEvent->getContentSize().width / 2 + 5, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemTestEvent);
|
||||
|
||||
// Test sending event 'echotest' to the endpoint '/testpoint'
|
||||
auto labelTestEventEndpoint = Label::createWithTTF("Test Endpoint Event", "fonts/arial.ttf", 22);
|
||||
auto itemTestEventEndpoint = MenuItemLabel::create(labelTestEventEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuTestEventEndpointClicked, this));
|
||||
itemTestEventEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestEventEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemTestEventEndpoint);
|
||||
auto labelTestEventEndpoint = Label::createWithTTF("Test Endpoint Event", "fonts/arial.ttf", 22);
|
||||
auto itemTestEventEndpoint = MenuItemLabel::create(labelTestEventEndpoint, CC_CALLBACK_1(SocketIOTest::onMenuTestEventEndpointClicked, this));
|
||||
itemTestEventEndpoint->setPosition(Vec2(VisibleRect::right().x - labelTestEventEndpoint->getContentSize().width / 2 - 5, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemTestEventEndpoint);
|
||||
|
||||
// Test disconnecting basic client
|
||||
auto labelTestClientDisconnect = Label::createWithTTF("Disconnect Socket", "fonts/arial.ttf", 22);
|
||||
auto itemClientDisconnect = MenuItemLabel::create(labelTestClientDisconnect, CC_CALLBACK_1(SocketIOTest::onMenuTestClientDisconnectClicked, this));
|
||||
itemClientDisconnect->setPosition(Vec2(VisibleRect::left().x + labelTestClientDisconnect->getContentSize().width / 2 + 5, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemClientDisconnect);
|
||||
auto labelTestClientDisconnect = Label::createWithTTF("Disconnect Socket", "fonts/arial.ttf", 22);
|
||||
auto itemClientDisconnect = MenuItemLabel::create(labelTestClientDisconnect, CC_CALLBACK_1(SocketIOTest::onMenuTestClientDisconnectClicked, this));
|
||||
itemClientDisconnect->setPosition(Vec2(VisibleRect::left().x + labelTestClientDisconnect->getContentSize().width / 2 + 5, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemClientDisconnect);
|
||||
|
||||
// Test disconnecting the endpoint '/testpoint'
|
||||
auto labelTestEndpointDisconnect = Label::createWithTTF("Disconnect Endpoint", "fonts/arial.ttf", 22);
|
||||
auto itemTestEndpointDisconnect = MenuItemLabel::create(labelTestEndpointDisconnect, CC_CALLBACK_1(SocketIOTest::onMenuTestEndpointDisconnectClicked, this));
|
||||
itemTestEndpointDisconnect->setPosition(Vec2(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemTestEndpointDisconnect);
|
||||
auto labelTestEndpointDisconnect = Label::createWithTTF("Disconnect Endpoint", "fonts/arial.ttf", 22);
|
||||
auto itemTestEndpointDisconnect = MenuItemLabel::create(labelTestEndpointDisconnect, CC_CALLBACK_1(SocketIOTest::onMenuTestEndpointDisconnectClicked, this));
|
||||
itemTestEndpointDisconnect->setPosition(Vec2(VisibleRect::right().x - labelTestEndpointDisconnect->getContentSize().width / 2 - 5, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemTestEndpointDisconnect);
|
||||
|
||||
// Shared Status Label
|
||||
_sioClientStatus = Label::createWithTTF("Not connected...", "fonts/arial.ttf", 14, Size(320, 100), TextHAlignment::LEFT);
|
||||
_sioClientStatus->setAnchorPoint(Vec2(0, 0));
|
||||
_sioClientStatus->setPosition(Vec2(VisibleRect::left().x, VisibleRect::rightBottom().y));
|
||||
this->addChild(_sioClientStatus);
|
||||
_sioClientStatus = Label::createWithTTF("Not connected...", "fonts/arial.ttf", 14, Size(320, 100), TextHAlignment::LEFT);
|
||||
_sioClientStatus->setAnchorPoint(Vec2(0, 0));
|
||||
_sioClientStatus->setPosition(Vec2(VisibleRect::left().x, VisibleRect::rightBottom().y));
|
||||
this->addChild(_sioClientStatus);
|
||||
}
|
||||
|
||||
SocketIOTest::~SocketIOTest()
|
||||
|
||||
SocketIOTest::~SocketIOTest(void)
|
||||
{
|
||||
}
|
||||
|
||||
//test event callback handlers, these will be registered with socket.io
|
||||
void SocketIOTest::testevent(SIOClient *client, const std::string& data) {
|
||||
|
||||
log("SocketIOTest::testevent called with data: %s", data.c_str());
|
||||
CCLOGINFO("SocketIOTest::testevent called with data: %s", data.c_str());
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " received event testevent with data: " << data.c_str();
|
||||
|
@ -107,7 +125,7 @@ void SocketIOTest::testevent(SIOClient *client, const std::string& data) {
|
|||
|
||||
void SocketIOTest::echotest(SIOClient *client, const std::string& data) {
|
||||
|
||||
log("SocketIOTest::echotest called with data: %s", data.c_str());
|
||||
CCLOGINFO("SocketIOTest::echotest called with data: %s", data.c_str());
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " received event echotest with data: " << data.c_str();
|
||||
|
@ -116,91 +134,11 @@ void SocketIOTest::echotest(SIOClient *client, const std::string& data) {
|
|||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuSIOClientClicked(cocos2d::Ref *sender)
|
||||
// onMessage is no longer a required override from the delegate class
|
||||
// 'message' events and handlers are now registered in the same way that other events are
|
||||
void SocketIOTest::message(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
//create a client by using this static method, url does not need to contain the protocol
|
||||
_sioClient = SocketIO::connect("ws://channon.us:3000", *this);
|
||||
//you may set a tag for the client for reference in callbacks
|
||||
_sioClient->setTag("Test Client");
|
||||
|
||||
//register event callbacks using the CC_CALLBACK_2() macro and passing the instance of the target class
|
||||
_sioClient->on("testevent", CC_CALLBACK_2(SocketIOTest::testevent, this));
|
||||
_sioClient->on("echotest", CC_CALLBACK_2(SocketIOTest::echotest, this));
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuSIOEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//repeat the same connection steps for the namespace "testpoint"
|
||||
_sioEndpoint = SocketIO::connect("ws://channon.us:3000/testpoint", *this);
|
||||
//a tag to differentiate in shared callbacks
|
||||
_sioEndpoint->setTag("Test Endpoint");
|
||||
|
||||
//demonstrating how callbacks can be shared within a delegate
|
||||
_sioEndpoint->on("testevent", CC_CALLBACK_2(SocketIOTest::testevent, this));
|
||||
_sioEndpoint->on("echotest", CC_CALLBACK_2(SocketIOTest::echotest, this));
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestMessageClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//check that the socket is != nullptr before sending or emitting events
|
||||
//the client should be nullptr either before initialization and connection or after disconnect
|
||||
if(_sioClient != nullptr) _sioClient->send("Hello Socket.IO!");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestMessageEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if(_sioEndpoint != nullptr) _sioEndpoint->send("Hello Socket.IO!");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEventClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//check that the socket is != nullptr before sending or emitting events
|
||||
//the client should be nullptr either before initialization and connection or after disconnect
|
||||
if(_sioClient != nullptr) _sioClient->emit("echotest","[{\"name\":\"myname\",\"type\":\"mytype\"}]");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEventEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if(_sioEndpoint != nullptr) _sioEndpoint->emit("echotest","[{\"name\":\"myname\",\"type\":\"mytype\"}]");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestClientDisconnectClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if(_sioClient != nullptr) _sioClient->disconnect();
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEndpointDisconnectClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if(_sioEndpoint != nullptr) _sioEndpoint->disconnect();
|
||||
|
||||
}
|
||||
|
||||
// Delegate methods
|
||||
|
||||
void SocketIOTest::onConnect(network::SIOClient* client)
|
||||
{
|
||||
log("SocketIOTest::onConnect called");
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " connected!";
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMessage(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
log("SocketIOTest::onMessage received: %s", data.c_str());
|
||||
CCLOGINFO("SocketIOTest::message received: %s", data.c_str());
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " received message with content: " << data.c_str();
|
||||
|
@ -208,29 +146,168 @@ void SocketIOTest::onMessage(network::SIOClient* client, const std::string& data
|
|||
|
||||
}
|
||||
|
||||
void SocketIOTest::json(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
CCLOGINFO("SocketIOTest::json received: %s", data.c_str());
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " received json message with content: " << data.c_str();
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::connect(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
CCLOGINFO("SocketIOTest::connect called");
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " connected!";
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::disconnect(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
CCLOGINFO("SocketIOTest::disconnect called");
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " disconnected by server!";
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
this->closedSocketAction(client);
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::closedSocketAction(network::SIOClient* client)
|
||||
{
|
||||
//set the local pointer to nullptr or connect to another client
|
||||
//the client object will be released on its own after this method completes
|
||||
if (client == _sioClient) {
|
||||
|
||||
_sioClient = nullptr;
|
||||
}
|
||||
else if (client == _sioEndpoint) {
|
||||
|
||||
_sioEndpoint = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuSIOClientClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//create a client by using this static method, url does not need to contain the protocol
|
||||
_sioClient = SocketIO::connect("ws://dev.channon.us:3010", *this);
|
||||
//you may set a tag for the client for reference in callbacks
|
||||
_sioClient->setTag("Test Client");
|
||||
|
||||
//register event callbacks using the CC_CALLBACK_2() macro and passing the instance of the target class
|
||||
_sioClient->on("testevent", CC_CALLBACK_2(SocketIOTest::testevent, this));
|
||||
_sioClient->on("echotest", CC_CALLBACK_2(SocketIOTest::echotest, this));
|
||||
_sioClient->on("message", CC_CALLBACK_2(SocketIOTest::message, this));
|
||||
_sioClient->on("json", CC_CALLBACK_2(SocketIOTest::json, this));
|
||||
_sioClient->on("connect", CC_CALLBACK_2(SocketIOTest::connect, this));
|
||||
_sioClient->on("disconnect", CC_CALLBACK_2(SocketIOTest::disconnect, this));
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuSIOEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//repeat the same connection steps for the namespace "testpoint"
|
||||
_sioEndpoint = SocketIO::connect("ws://dev.channon.us:3010/testpoint", *this);
|
||||
//a tag to differentiate in shared callbacks
|
||||
_sioEndpoint->setTag("Test Endpoint");
|
||||
|
||||
//demonstrating how callbacks can be shared within a delegate
|
||||
_sioEndpoint->on("testevent", CC_CALLBACK_2(SocketIOTest::testevent, this));
|
||||
_sioEndpoint->on("echotest", CC_CALLBACK_2(SocketIOTest::echotest, this));
|
||||
_sioEndpoint->on("message", CC_CALLBACK_2(SocketIOTest::message, this));
|
||||
_sioEndpoint->on("json", CC_CALLBACK_2(SocketIOTest::json, this));
|
||||
_sioEndpoint->on("connect", CC_CALLBACK_2(SocketIOTest::connect, this));
|
||||
_sioEndpoint->on("disconnect", CC_CALLBACK_2(SocketIOTest::disconnect, this));
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestMessageClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//check that the socket is != nullptr before sending or emitting events
|
||||
//the client should be nullptr either before initialization and connection or after disconnect
|
||||
if (_sioClient != nullptr) _sioClient->send("Hello Socket.IO!");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestMessageEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if (_sioEndpoint != nullptr) _sioEndpoint->send("Hello Socket.IO!");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEventClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
//check that the socket is != nullptr before sending or emitting events
|
||||
//the client should be nullptr either before initialization and connection or after disconnect
|
||||
if (_sioClient != nullptr) _sioClient->emit("echotest", "{\"name\":\"myname\",\"type\":\"mytype\"}");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEventEndpointClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
|
||||
if (_sioEndpoint != nullptr) _sioEndpoint->emit("echotest", "{\"name\":\"myname\",\"type\":\"mytype\"}");
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestClientDisconnectClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
// Disconnecting from the default namespace "" or "/" will also disconnect all other endpoints
|
||||
std::stringstream s;
|
||||
|
||||
if (_sioClient != nullptr) {
|
||||
s << _sioClient->getTag() << " manually closed!";
|
||||
_sioClient->disconnect();
|
||||
_sioClient = nullptr;
|
||||
}
|
||||
else {
|
||||
s << "Socket.io Test Client not initialized!";
|
||||
}
|
||||
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onMenuTestEndpointDisconnectClicked(cocos2d::Ref *sender)
|
||||
{
|
||||
std::stringstream s;
|
||||
|
||||
if (_sioEndpoint != nullptr) {
|
||||
s << _sioEndpoint->getTag() << " manually closed!";
|
||||
_sioEndpoint->disconnect();
|
||||
_sioEndpoint = nullptr;
|
||||
}
|
||||
else {
|
||||
s << "Socket.io Test Endpoint not initialized!";
|
||||
}
|
||||
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
}
|
||||
|
||||
// SIODelegate methods to catch network/socket level events outside of the socket.io events
|
||||
|
||||
void SocketIOTest::onClose(network::SIOClient* client)
|
||||
{
|
||||
log("SocketIOTest::onClose called");
|
||||
CCLOGINFO("SocketIOTest::onClose called");
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " closed!";
|
||||
_sioClientStatus->setString(s.str().c_str());
|
||||
|
||||
//set the local pointer to nullptr or connect to another client
|
||||
//the client object will be released on its own after this method completes
|
||||
if(client == _sioClient) {
|
||||
|
||||
_sioClient = nullptr;
|
||||
} else if(client == _sioEndpoint) {
|
||||
|
||||
_sioEndpoint = nullptr;
|
||||
}
|
||||
this->closedSocketAction(client);
|
||||
|
||||
}
|
||||
|
||||
void SocketIOTest::onError(network::SIOClient* client, const std::string& data)
|
||||
{
|
||||
log("SocketIOTest::onError received: %s", data.c_str());
|
||||
CCLOGERROR("SocketIOTest::onError received: %s", data.c_str());
|
||||
|
||||
std::stringstream s;
|
||||
s << client->getTag() << " received error with content: " << data.c_str();
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
//
|
||||
// SocketIOTest.h
|
||||
// TestCpp
|
||||
//
|
||||
// Created by Chris Hannon on 6/26/13.
|
||||
//
|
||||
//
|
||||
/****************************************************************************
|
||||
Copyright (c) 2015 Chris Hannon http://www.channon.us
|
||||
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __TestCpp__SocketIOTest__
|
||||
#define __TestCpp__SocketIOTest__
|
||||
|
||||
|
@ -24,27 +43,63 @@ public:
|
|||
SocketIOTest();
|
||||
virtual ~SocketIOTest();
|
||||
|
||||
virtual void onConnect(cocos2d::network::SIOClient* client);
|
||||
virtual void onMessage(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
virtual void onClose(cocos2d::network::SIOClient* client);
|
||||
virtual void onError(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
/**
|
||||
* @brief Used for network level socket close (not for disconnect from the socket.io server)
|
||||
*/
|
||||
virtual void onClose(cocos2d::network::SIOClient* client);
|
||||
/**
|
||||
* @brief Used for network level socket error (not for disconnect from the socket.io server)
|
||||
**/
|
||||
virtual void onError(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
/**
|
||||
* @brief Common function to call on both socket.io disconnect and websocket close
|
||||
**/
|
||||
void closedSocketAction(cocos2d::network::SIOClient* client);
|
||||
|
||||
// test action handlers for main Test Client that connects to defaul namespace "" or "/"
|
||||
void onMenuSIOClientClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestMessageClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestEventClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestClientDisconnectClicked(cocos2d::Ref *sender);
|
||||
|
||||
// test action handlers for Test Endpoint that connects to /testpoint endpoint
|
||||
void onMenuSIOEndpointClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestMessageEndpointClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestEventEndpointClicked(cocos2d::Ref *sender);
|
||||
void onMenuTestEndpointDisconnectClicked(cocos2d::Ref *sender);
|
||||
|
||||
// custom handlers for socket.io related events
|
||||
|
||||
/**
|
||||
* @brief Socket.io event handler for custom event "testevent"
|
||||
**/
|
||||
void testevent(cocos2d::network::SIOClient *client, const std::string& data);
|
||||
/**
|
||||
* @brief Socket.io event handler for custom event "echoevent"
|
||||
**/
|
||||
void echotest(cocos2d::network::SIOClient *client, const std::string& data);
|
||||
/**
|
||||
* @brief Socket.io event handler for event "connect"
|
||||
**/
|
||||
void connect(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
/**
|
||||
* @brief Socket.io event handler for event "disconnect"
|
||||
**/
|
||||
void disconnect(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
/**
|
||||
* @brief Socket.io event handler for event "message"
|
||||
**/
|
||||
void message(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
/**
|
||||
* @brief Socket.io event handler for event "json"
|
||||
* This is only used in v 0.9.x, in 1.x this is handled as a "message" event
|
||||
**/
|
||||
void json(cocos2d::network::SIOClient* client, const std::string& data);
|
||||
|
||||
virtual std::string title() const override{ return "SocketIO Extension Test"; }
|
||||
|
||||
protected:
|
||||
|
||||
cocos2d::network::SIOClient *_sioClient, *_sioEndpoint;
|
||||
|
||||
cocos2d::Label *_sioClientStatus;
|
||||
|
|
|
@ -80,6 +80,7 @@ NewLabelTests::NewLabelTests()
|
|||
ADD_TEST_CASE(LabelIssue11699Test);
|
||||
ADD_TEST_CASE(LabelIssue12259Test);
|
||||
ADD_TEST_CASE(LabelIssue12409Test);
|
||||
ADD_TEST_CASE(LabelAddChildTest);
|
||||
};
|
||||
|
||||
LabelTTFAlignmentNew::LabelTTFAlignmentNew()
|
||||
|
@ -2011,3 +2012,26 @@ std::string LabelIssue12409Test::subtitle() const
|
|||
{
|
||||
return "Testing auto-wrapping without space.";
|
||||
}
|
||||
|
||||
LabelAddChildTest::LabelAddChildTest()
|
||||
{
|
||||
auto center = VisibleRect::center();
|
||||
|
||||
auto label = Label::createWithTTF("Label with child node:", "fonts/arial.ttf", 24);
|
||||
label->setPosition(center.x, center.y);
|
||||
addChild(label);
|
||||
|
||||
auto jump = JumpBy::create(1.0f, Vec2::ZERO, 60, 1);
|
||||
auto jump_4ever = RepeatForever::create(jump);
|
||||
label->runAction(jump_4ever);
|
||||
|
||||
auto spite = Sprite::create("Images/SpookyPeas.png");
|
||||
spite->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
|
||||
spite->setPosition(label->getContentSize().width, label->getContentSize().height/2);
|
||||
label->addChild(spite);
|
||||
}
|
||||
|
||||
std::string LabelAddChildTest::title() const
|
||||
{
|
||||
return "Label support add child nodes";
|
||||
}
|
||||
|
|
|
@ -609,4 +609,14 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class LabelAddChildTest : public AtlasDemoNew
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LabelAddChildTest);
|
||||
|
||||
LabelAddChildTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,16 @@ if('NODE_NAME' in os.environ):
|
|||
node_name = os.environ['NODE_NAME']
|
||||
else:
|
||||
node_name = 'ios'
|
||||
|
||||
if('language' in os.environ):
|
||||
language = os.environ['language']
|
||||
else:
|
||||
language = 'lua'
|
||||
|
||||
if('daily_build_type' in os.environ):
|
||||
daily_build_type = os.environ['daily_build_type']
|
||||
else:
|
||||
daily_build_type = 'tests'
|
||||
# for local debugging purpose, you could change the value to 0 and run
|
||||
# this scripts in your local machine
|
||||
remote_build = 1
|
||||
|
@ -56,26 +66,27 @@ def gen_scripting_bindings():
|
|||
|
||||
|
||||
def do_build_slaves():
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + daily_build_type + os.sep
|
||||
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
slave_build_scripts = ""
|
||||
if(node_name == 'android') or (node_name == 'android_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "android-build.sh"
|
||||
slave_build_scripts = jenkins_script_path + "android-build.sh "
|
||||
elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "win32-build.bat"
|
||||
slave_build_scripts = jenkins_script_path + "win32-build.bat "
|
||||
elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "windows-universal.bat"
|
||||
slave_build_scripts = jenkins_script_path + "windows-universal.bat "
|
||||
elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "ios-build.sh"
|
||||
slave_build_scripts = jenkins_script_path + "ios-build.sh "
|
||||
elif(node_name == 'mac' or node_name == 'mac_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "mac-build.sh"
|
||||
slave_build_scripts = jenkins_script_path + "mac-build.sh "
|
||||
elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "linux-build.sh"
|
||||
slave_build_scripts = jenkins_script_path + "linux-build.sh "
|
||||
elif(node_name == 'wp8'):
|
||||
if(branch != 'v4'):
|
||||
slave_build_scripts = jenkins_script_path + "wp8-v3.bat"
|
||||
slave_build_scripts = jenkins_script_path + "wp8-v3.bat "
|
||||
|
||||
slave_build_scripts += language
|
||||
ret = os.system(slave_build_scripts)
|
||||
|
||||
#get build result
|
||||
|
@ -102,12 +113,12 @@ def main():
|
|||
exit_code = 1
|
||||
|
||||
# #clean workspace, we don't won't clean the repository
|
||||
if remote_build == 1:
|
||||
os.system("cd " + workspace)
|
||||
os.system("git reset --hard")
|
||||
os.system("git clean -xdf -f")
|
||||
else:
|
||||
print "local build, no need to cleanup"
|
||||
# if remote_build == 1:
|
||||
# os.system("cd " + workspace)
|
||||
# os.system("git reset --hard")
|
||||
# os.system("git clean -xdf -f")
|
||||
# else:
|
||||
# print "local build, no need to cleanup"
|
||||
|
||||
return(exit_code)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ def do_build_slaves():
|
|||
global branch
|
||||
global node_name
|
||||
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "tests" + os.sep
|
||||
|
||||
if(branch != 'v1' and branch != 'v2'):
|
||||
slave_build_scripts = ""
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
#Cocos2D-X framework project daily build
|
||||
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
if('branch' in os.environ):
|
||||
branch = os.environ['branch']
|
||||
else:
|
||||
branch = 'v4-develop'
|
||||
|
||||
if('WORKSPACE' in os.environ):
|
||||
workspace = os.environ['WORKSPACE']
|
||||
else:
|
||||
workspace = "."
|
||||
|
||||
if('NODE_NAME' in os.environ):
|
||||
node_name = os.environ['NODE_NAME']
|
||||
else:
|
||||
node_name = 'android'
|
||||
# for local debugging purpose, you could change the value to 0 and run
|
||||
# this scripts in your local machine
|
||||
remote_build = 1
|
||||
|
||||
def download_3rd_library():
|
||||
#run download-deps.py
|
||||
print("prepare to downloading ...")
|
||||
os.system('python download-deps.py -r no')
|
||||
|
||||
|
||||
def sync_remote_repo():
|
||||
#reset path to workspace root
|
||||
os.system("cd " + workspace)
|
||||
|
||||
#pull latest code
|
||||
os.system("git fetch origin " + branch)
|
||||
os.system("git checkout " + branch)
|
||||
os.system("git merge origin/" + branch)
|
||||
#clean workspace
|
||||
print "Before checkout: git clean -xdf -f"
|
||||
os.system("git clean -xdf -f")
|
||||
|
||||
#update submodule
|
||||
git_update_submodule = "git submodule update --init --force"
|
||||
ret = os.system(git_update_submodule)
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def gen_scripting_bindings():
|
||||
# Generate binding glue codes
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py")
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def do_build_slaves():
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "framework" + os.sep
|
||||
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
slave_build_scripts = ""
|
||||
if(node_name == 'android') or (node_name == 'android_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "android-build.sh"
|
||||
elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "win32-build.bat"
|
||||
elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "windows-universal.bat"
|
||||
elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "ios-build.sh"
|
||||
elif(node_name == 'mac' or node_name == 'mac_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "mac-build.sh"
|
||||
elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "linux-build.sh"
|
||||
elif(node_name == 'wp8'):
|
||||
if(branch != 'v4'):
|
||||
slave_build_scripts = jenkins_script_path + "wp8-v3.bat"
|
||||
|
||||
ret = os.system(slave_build_scripts)
|
||||
|
||||
#get build result
|
||||
print "build finished and return " + str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
if remote_build == 1:
|
||||
#syntronize local git repository with remote and merge the PR
|
||||
sync_remote_repo()
|
||||
#copy check_current_3rd_libs
|
||||
download_3rd_library()
|
||||
#generate jsb and luabindings
|
||||
gen_scripting_bindings()
|
||||
|
||||
#start build jobs on each slave
|
||||
ret = do_build_slaves()
|
||||
|
||||
exit_code = 1
|
||||
if ret == 0:
|
||||
exit_code = 0
|
||||
else:
|
||||
exit_code = 1
|
||||
|
||||
return(exit_code)
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
sys_ret = 0
|
||||
try:
|
||||
sys_ret = main()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
sys_ret = 1
|
||||
finally:
|
||||
sys.exit(sys_ret)
|
|
@ -75,7 +75,8 @@ def main():
|
|||
#set commit status to pending
|
||||
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
|
||||
|
||||
if(action == 'closed' or action == 'assigned' or branch == 'v2' or branch == 'v3-doc'):
|
||||
if(action == 'closed' or action == 'assigned'
|
||||
or branch == 'v2' or branch == 'v3-doc' or action == 'unassigned'):
|
||||
print 'pull request #' + str(pr_num) + ' is ' + action + ', no build triggered'
|
||||
return(0)
|
||||
|
||||
|
|
|
@ -75,8 +75,9 @@ def main():
|
|||
except:
|
||||
print 'Can not find build in queue'
|
||||
|
||||
if(action == 'closed' or action == 'labeled'
|
||||
or action == 'assigned' or action == 'unlabeled' or branch == 'v2' or branch == 'v3-doc'):
|
||||
if(action == 'closed' or action == 'labeled' or action == 'unassigned'
|
||||
or action == 'assigned' or action == 'unlabeled'
|
||||
or branch == 'v2' or branch == 'v3-doc'):
|
||||
print 'pull request #' + str(pr_num) + ' is ' + action + ', no build triggered'
|
||||
return(0)
|
||||
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
#Cocos2D-X runtime project daily build
|
||||
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
if('branch' in os.environ):
|
||||
branch = os.environ['branch']
|
||||
else:
|
||||
branch = 'v4-develop'
|
||||
|
||||
if('WORKSPACE' in os.environ):
|
||||
workspace = os.environ['WORKSPACE']
|
||||
else:
|
||||
workspace = "."
|
||||
|
||||
if('NODE_NAME' in os.environ):
|
||||
node_name = os.environ['NODE_NAME']
|
||||
else:
|
||||
node_name = 'win32'
|
||||
|
||||
if('language' in os.environ):
|
||||
language = os.environ['language']
|
||||
else:
|
||||
language = 'lua'
|
||||
|
||||
# for local debugging purpose, you could change the value to 0 and run
|
||||
# this scripts in your local machine
|
||||
remote_build = 1
|
||||
|
||||
def download_3rd_library():
|
||||
#run download-deps.py
|
||||
print("prepare to downloading ...")
|
||||
os.system('python download-deps.py -r no')
|
||||
|
||||
|
||||
def sync_remote_repo():
|
||||
#reset path to workspace root
|
||||
os.system("cd " + workspace)
|
||||
|
||||
#pull latest code
|
||||
os.system("git fetch origin " + branch)
|
||||
os.system("git checkout " + branch)
|
||||
os.system("git merge origin/" + branch)
|
||||
#clean workspace
|
||||
print "Before checkout: git clean -xdf -f"
|
||||
os.system("git clean -xdf -f")
|
||||
|
||||
#update submodule
|
||||
git_update_submodule = "git submodule update --init --force"
|
||||
ret = os.system(git_update_submodule)
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def gen_scripting_bindings():
|
||||
# Generate binding glue codes
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py")
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def do_build_slaves():
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "runtime" + os.sep
|
||||
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
slave_build_scripts = ""
|
||||
if(node_name == 'android') or (node_name == 'android_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "android-build.sh " + language
|
||||
elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "win32-build.bat " + language
|
||||
elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "windows-universal.bat " + language
|
||||
elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "ios-build.sh " + language
|
||||
elif(node_name == 'mac' or node_name == 'mac_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "mac-build.sh " + language
|
||||
elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "linux-build.sh " + language
|
||||
elif(node_name == 'wp8'):
|
||||
if(branch != 'v4'):
|
||||
slave_build_scripts = jenkins_script_path + "wp8-v3.bat"
|
||||
|
||||
ret = os.system(slave_build_scripts)
|
||||
|
||||
#get build result
|
||||
print "build finished and return " + str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
if remote_build == 1:
|
||||
#syntronize local git repository with remote and merge the PR
|
||||
sync_remote_repo()
|
||||
#copy check_current_3rd_libs
|
||||
download_3rd_library()
|
||||
#generate jsb and luabindings
|
||||
gen_scripting_bindings()
|
||||
|
||||
#start build jobs on each slave
|
||||
ret = do_build_slaves()
|
||||
|
||||
exit_code = 1
|
||||
if ret == 0:
|
||||
exit_code = 0
|
||||
else:
|
||||
exit_code = 1
|
||||
|
||||
#clean workspace, we don't won't clean the repository
|
||||
if remote_build == 1:
|
||||
os.system("cd " + workspace)
|
||||
os.system("git reset --hard")
|
||||
os.system("git clean -xdf -f")
|
||||
else:
|
||||
print "local build, no need to cleanup"
|
||||
|
||||
return(exit_code)
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
sys_ret = 0
|
||||
try:
|
||||
sys_ret = main()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
sys_ret = 1
|
||||
finally:
|
||||
sys.exit(sys_ret)
|
|
@ -5,16 +5,21 @@ $mycocos new -l $1 -t runtime
|
|||
if [ $1 = "cpp" ];then
|
||||
schemename="MyCppGame-mobile"
|
||||
projectpath="MyCppGame/proj.ios_mac/MyCppGame.xcodeproj"
|
||||
cocos_project_path="MyCppGame"
|
||||
elif [ $1 = "lua" ];then
|
||||
schemename="MyLuaGame-mobile"
|
||||
projectpath="MyLuaGame/frameworks/runtime-src/proj.ios_mac/MyLuaGame.xcodeproj"
|
||||
cocos_project_path="MyLuaGame"
|
||||
elif [ $1 = "js" ];then
|
||||
schemename="MyJSGame-mobile"
|
||||
projectpath="MyJSGame/frameworks/runtime-src/proj.ios_mac/MyJSGame.xcodeproj"
|
||||
cocos_project_path="MyJSGame"
|
||||
fi
|
||||
|
||||
echo "start building..."
|
||||
xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty
|
||||
xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty
|
||||
#the following commands must not be removed
|
||||
xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build
|
||||
cocos compile -p ios -s $cocos_project_path | xcpretty
|
||||
cocos compile -p ios -s $cocos_project_path
|
||||
# xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty
|
||||
# xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty
|
||||
# #the following commands must not be removed
|
||||
# xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
set mycocos=tools/cocos2d-console/bin/cocos.bat
|
||||
set language=%1
|
||||
rmdir /s /q .git
|
||||
call %mycocos% new -l %language% -t runtime
|
||||
|
||||
set projectname=
|
||||
|
@ -11,4 +12,4 @@ if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win32
|
|||
|
||||
echo %projectname%
|
||||
call "%VS120COMNTOOLS%vsvars32.bat"
|
||||
msbuild %projectname% /t:Build /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
msbuild %projectname% /t:Build /p:VisualStudioVersion=12.0 /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
set mycocos=tools/cocos2d-console/bin/cocos.bat
|
||||
set language=%1
|
||||
rmdir /s /q .git
|
||||
call %mycocos% new -l %language%
|
||||
|
||||
set projectname=
|
||||
|
@ -11,4 +12,4 @@ if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win8.
|
|||
|
||||
echo %projectname%
|
||||
call "%VS120COMNTOOLS%vsvars32.bat"
|
||||
msbuild %projectname% /t:Build /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
msbuild %projectname% /t:Build /p:VisualStudioVersion=12.0 /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
set mycocos=tools/cocos2d-console/bin/cocos.bat
|
||||
set language=%1
|
||||
rmdir /s /q .git
|
||||
call %mycocos% new -l %language%
|
||||
|
||||
set projectname=
|
||||
|
@ -11,4 +12,4 @@ if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win32
|
|||
|
||||
echo %projectname%
|
||||
call "%VS120COMNTOOLS%vsvars32.bat"
|
||||
msbuild %projectname% /t:Build
|
||||
msbuild %projectname% /t:Build /p:VisualStudioVersion=12.0 /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
set mycocos=tools/cocos2d-console/bin/cocos.bat
|
||||
set language=%1
|
||||
|
||||
rmdir /s /q .git
|
||||
call %mycocos% new -l %language%
|
||||
|
||||
set projectname=
|
||||
|
@ -11,4 +13,4 @@ if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win8.
|
|||
|
||||
echo %projectname%
|
||||
call "%VS120COMNTOOLS%vsvars32.bat"
|
||||
msbuild %projectname% /t:Build
|
||||
msbuild %projectname% /t:Build /p:VisualStudioVersion=12.0 /p:Platform="Win32" /p:Configuration="Release" /m
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#put xctool.sh into your PATH
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
COCOS2DX_ROOT="$DIR"/../../..
|
||||
COCOS2DX_ROOT="$DIR"/../../../..
|
||||
cd ${COCOS2DX_ROOT}
|
||||
python build/android-build.py -p 10 cpp-tests lua-tests js-tests
|
|
@ -1,6 +1,6 @@
|
|||
#put xctool.sh into your PATH
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
COCOS2DX_ROOT="$DIR"/../../..
|
||||
COCOS2DX_ROOT="$DIR"/../../../..
|
||||
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests iOS" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty
|
||||
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests iOS" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty
|
||||
#the following commands must not be removed
|
|
@ -1,6 +1,6 @@
|
|||
#put xctool.sh into your PATH
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
COCOS2DX_ROOT="$DIR"/../../..
|
||||
COCOS2DX_ROOT="$DIR"/../../../..
|
||||
cd ${COCOS2DX_ROOT}
|
||||
mkdir linux-build
|
||||
cd linux-build
|
|
@ -15,7 +15,7 @@
|
|||
# xcode build
|
||||
#######
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
COCOS2DX_ROOT="$DIR"/../../..
|
||||
COCOS2DX_ROOT="$DIR"/../../../..
|
||||
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests Mac" clean | xcpretty
|
||||
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests Mac" build | xcpretty
|
||||
#xcpretty has a bug, some xcodebuid fails return value would be treated as 0.
|
|
@ -1,129 +0,0 @@
|
|||
#Cocos2D-X template project daily build
|
||||
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
if('branch' in os.environ):
|
||||
branch = os.environ['branch']
|
||||
else:
|
||||
branch = 'v4-develop'
|
||||
|
||||
if('WORKSPACE' in os.environ):
|
||||
workspace = os.environ['WORKSPACE']
|
||||
else:
|
||||
workspace = "."
|
||||
|
||||
if('NODE_NAME' in os.environ):
|
||||
node_name = os.environ['NODE_NAME']
|
||||
else:
|
||||
node_name = 'windows-universal'
|
||||
|
||||
if('language' in os.environ):
|
||||
language = os.environ['language']
|
||||
else:
|
||||
language = 'cpp'
|
||||
|
||||
# for local debugging purpose, you could change the value to 0 and run
|
||||
# this scripts in your local machine
|
||||
remote_build = 1
|
||||
|
||||
def download_3rd_library():
|
||||
#run download-deps.py
|
||||
print("prepare to downloading ...")
|
||||
os.system('python download-deps.py -r no')
|
||||
|
||||
|
||||
def sync_remote_repo():
|
||||
#reset path to workspace root
|
||||
os.system("cd " + workspace)
|
||||
|
||||
#pull latest code
|
||||
os.system("git fetch origin " + branch)
|
||||
os.system("git checkout " + branch)
|
||||
os.system("git merge origin/" + branch)
|
||||
#clean workspace
|
||||
print "Before checkout: git clean -xdf -f"
|
||||
os.system("git clean -xdf -f")
|
||||
|
||||
#update submodule
|
||||
git_update_submodule = "git submodule update --init --force"
|
||||
ret = os.system(git_update_submodule)
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def gen_scripting_bindings():
|
||||
# Generate binding glue codes
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py")
|
||||
if(ret != 0):
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
def do_build_slaves():
|
||||
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "templates" + os.sep
|
||||
|
||||
if(branch == 'v3' or branch == 'v4-develop'):
|
||||
slave_build_scripts = ""
|
||||
if(node_name == 'android') or (node_name == 'android_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "android-build.sh " + language
|
||||
elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "win32-build.bat " + language
|
||||
elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "windows-universal.bat " + language
|
||||
elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "ios-build.sh " + language
|
||||
elif(node_name == 'mac' or node_name == 'mac_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "mac-build.sh " + language
|
||||
elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'):
|
||||
slave_build_scripts = jenkins_script_path + "linux-build.sh " + language
|
||||
elif(node_name == 'wp8'):
|
||||
if(branch != 'v4'):
|
||||
slave_build_scripts = jenkins_script_path + "wp8-v3.bat"
|
||||
|
||||
ret = os.system(slave_build_scripts)
|
||||
|
||||
#get build result
|
||||
print "build finished and return " + str(ret)
|
||||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
if remote_build == 1:
|
||||
#syntronize local git repository with remote and merge the PR
|
||||
sync_remote_repo()
|
||||
#copy check_current_3rd_libs
|
||||
download_3rd_library()
|
||||
#generate jsb and luabindings
|
||||
gen_scripting_bindings()
|
||||
|
||||
#start build jobs on each slave
|
||||
ret = do_build_slaves()
|
||||
|
||||
exit_code = 1
|
||||
if ret == 0:
|
||||
exit_code = 0
|
||||
else:
|
||||
exit_code = 1
|
||||
|
||||
#clean workspace, we don't won't clean the repository
|
||||
if remote_build == 1:
|
||||
os.system("cd " + workspace)
|
||||
os.system("git reset --hard")
|
||||
os.system("git clean -xdf -f")
|
||||
else:
|
||||
print "local build, no need to cleanup"
|
||||
|
||||
return(exit_code)
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
sys_ret = 0
|
||||
try:
|
||||
sys_ret = main()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
sys_ret = 1
|
||||
finally:
|
||||
sys.exit(sys_ret)
|
Loading…
Reference in New Issue