mirror of https://github.com/axmolengine/axmol.git
commit
2f4b094598
|
@ -2,7 +2,8 @@ language: cpp
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- GEN_JSB=YES
|
- GEN_JSB=YES
|
||||||
- PLATFORM=linux DEBUG=1
|
- PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++
|
||||||
|
- PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++
|
||||||
# Since switching to C++11 only the ARM version of the nactive client
|
# Since switching to C++11 only the ARM version of the nactive client
|
||||||
# port currently builds. TODO(sbc): Re-enable all architectures.
|
# port currently builds. TODO(sbc): Re-enable all architectures.
|
||||||
# Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex.
|
# Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex.
|
||||||
|
@ -23,6 +24,8 @@ env:
|
||||||
9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh
|
9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh
|
||||||
X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI=
|
X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI=
|
||||||
script:
|
script:
|
||||||
|
- export CC=$CC_COMPILER
|
||||||
|
- export CXX=$CXX_COMPILER
|
||||||
- tools/travis-scripts/run-script.sh
|
- tools/travis-scripts/run-script.sh
|
||||||
before_install:
|
before_install:
|
||||||
- tools/travis-scripts/before-install.sh
|
- tools/travis-scripts/before-install.sh
|
||||||
|
|
7
AUTHORS
7
AUTHORS
|
@ -356,6 +356,7 @@ Developers:
|
||||||
|
|
||||||
ThePickleMan
|
ThePickleMan
|
||||||
Adding 'rotationIsDir' property to ParticleSystem.
|
Adding 'rotationIsDir' property to ParticleSystem.
|
||||||
|
DrawNode supports to draw triangle, quad bezier, cubic bezier.
|
||||||
|
|
||||||
Jianghua (jxhgzs)
|
Jianghua (jxhgzs)
|
||||||
Adding an additional transform for CCNode.
|
Adding an additional transform for CCNode.
|
||||||
|
@ -519,6 +520,7 @@ Developers:
|
||||||
Correcting the type detecting order for Lua CCBProxy::getNodeTypeName.
|
Correcting the type detecting order for Lua CCBProxy::getNodeTypeName.
|
||||||
Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash.
|
Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash.
|
||||||
fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern.
|
fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern.
|
||||||
|
Fixed a bug that Websocket doesn't support send/receive data which larger than 4096 bytes.
|
||||||
|
|
||||||
musikov
|
musikov
|
||||||
Fixing a bug that missing precision when getting strokeColor and fontFillColor
|
Fixing a bug that missing precision when getting strokeColor and fontFillColor
|
||||||
|
@ -657,6 +659,7 @@ Developers:
|
||||||
|
|
||||||
xhcnb
|
xhcnb
|
||||||
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
|
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
|
||||||
|
Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder.
|
||||||
|
|
||||||
bopohaa
|
bopohaa
|
||||||
Fixed a bug that Webp test crashes.
|
Fixed a bug that Webp test crashes.
|
||||||
|
@ -705,6 +708,10 @@ Developers:
|
||||||
Fixed a typo in Director class.
|
Fixed a typo in Director class.
|
||||||
Removed an unnecessary boolean flag in CCFontAtlasCache.cpp.
|
Removed an unnecessary boolean flag in CCFontAtlasCache.cpp.
|
||||||
|
|
||||||
|
v1ctor
|
||||||
|
ControlSlider supports to set selected thumb sprite.
|
||||||
|
ControlButton supports to set scale ratio of touchdown state
|
||||||
|
|
||||||
Retired Core Developers:
|
Retired Core Developers:
|
||||||
WenSheng Yang
|
WenSheng Yang
|
||||||
Author of windows port, CCTextField,
|
Author of windows port, CCTextField,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
cocos2d-x-3.0final ?.? ?
|
cocos2d-x-3.0final ?.? ?
|
||||||
[All]
|
[All]
|
||||||
[FIX] Crash was triggered if there is not `textureFileName`section in particle plist file.
|
[FIX] Crash was triggered if there is not `textureFileName`section in particle plist file.
|
||||||
|
[FIX] ControlSlider doesn't support to set selected thumb sprite.
|
||||||
|
[FIX] ControlButton doesn't support to set scale ratio of touchdown state.
|
||||||
|
[FIX] Websocket doesn't support send/receive data which larger than 4096 bytes.
|
||||||
|
[NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier.
|
||||||
cocos2d-x-3.0beta Jan.7 2014
|
cocos2d-x-3.0beta Jan.7 2014
|
||||||
[All]
|
[All]
|
||||||
[NEW] New label: shadow, outline, glow support
|
[NEW] New label: shadow, outline, glow support
|
||||||
|
|
|
@ -948,17 +948,20 @@ void Director::createStatsLabel()
|
||||||
*/
|
*/
|
||||||
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
|
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
|
||||||
|
|
||||||
_FPSLabel = new LabelAtlas;
|
_FPSLabel = LabelAtlas::create();
|
||||||
|
_FPSLabel->retain();
|
||||||
_FPSLabel->setIgnoreContentScaleFactor(true);
|
_FPSLabel->setIgnoreContentScaleFactor(true);
|
||||||
_FPSLabel->initWithString("00.0", texture, 12, 32 , '.');
|
_FPSLabel->initWithString("00.0", texture, 12, 32 , '.');
|
||||||
_FPSLabel->setScale(factor);
|
_FPSLabel->setScale(factor);
|
||||||
|
|
||||||
_SPFLabel = new LabelAtlas;
|
_SPFLabel = LabelAtlas::create();
|
||||||
|
_SPFLabel->retain();
|
||||||
_SPFLabel->setIgnoreContentScaleFactor(true);
|
_SPFLabel->setIgnoreContentScaleFactor(true);
|
||||||
_SPFLabel->initWithString("0.000", texture, 12, 32, '.');
|
_SPFLabel->initWithString("0.000", texture, 12, 32, '.');
|
||||||
_SPFLabel->setScale(factor);
|
_SPFLabel->setScale(factor);
|
||||||
|
|
||||||
_drawsLabel = new LabelAtlas;
|
_drawsLabel = LabelAtlas::create();
|
||||||
|
_drawsLabel->retain();
|
||||||
_drawsLabel->setIgnoreContentScaleFactor(true);
|
_drawsLabel->setIgnoreContentScaleFactor(true);
|
||||||
_drawsLabel->initWithString("000", texture, 12, 32, '.');
|
_drawsLabel->initWithString("000", texture, 12, 32, '.');
|
||||||
_drawsLabel->setScale(factor);
|
_drawsLabel->setScale(factor);
|
||||||
|
|
|
@ -456,6 +456,86 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl
|
||||||
free(extrude);
|
free(extrude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color)
|
||||||
|
{
|
||||||
|
unsigned int vertex_count = 2*3;
|
||||||
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
|
Color4B col = Color4B(color);
|
||||||
|
V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
|
||||||
|
V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
|
||||||
|
V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
|
||||||
|
|
||||||
|
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||||
|
V2F_C4B_T2F_Triangle triangle = {a, b, c};
|
||||||
|
triangles[0] = triangle;
|
||||||
|
|
||||||
|
_bufferCount += vertex_count;
|
||||||
|
_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color)
|
||||||
|
{
|
||||||
|
unsigned int vertex_count = (segments + 1) * 3;
|
||||||
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
|
Tex2F texCoord = Tex2F(0.0, 0.0);
|
||||||
|
Color4B col = Color4B(color);
|
||||||
|
Vertex2F vertex;
|
||||||
|
Vertex2F firstVertex = Vertex2F(from.x, from.y);
|
||||||
|
Vertex2F lastVertex = Vertex2F(to.x, to.y);
|
||||||
|
|
||||||
|
float t = 0;
|
||||||
|
for(unsigned int i = segments + 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x;
|
||||||
|
float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y;
|
||||||
|
vertex = Vertex2F(x, y);
|
||||||
|
|
||||||
|
V2F_C4B_T2F a = {firstVertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F b = {lastVertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F c = {vertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F_Triangle triangle = {a, b, c};
|
||||||
|
((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle;
|
||||||
|
|
||||||
|
lastVertex = vertex;
|
||||||
|
t += 1.0f / segments;
|
||||||
|
_bufferCount += 3;
|
||||||
|
}
|
||||||
|
_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color)
|
||||||
|
{
|
||||||
|
unsigned int vertex_count = (segments + 1) * 3;
|
||||||
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
|
Tex2F texCoord = Tex2F(0.0, 0.0);
|
||||||
|
Color4B col = Color4B(color);
|
||||||
|
Vertex2F vertex;
|
||||||
|
Vertex2F firstVertex = Vertex2F(from.x, from.y);
|
||||||
|
Vertex2F lastVertex = Vertex2F(to.x, to.y);
|
||||||
|
|
||||||
|
float t = 0;
|
||||||
|
for(unsigned int i = segments + 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x;
|
||||||
|
float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y;
|
||||||
|
vertex = Vertex2F(x, y);
|
||||||
|
|
||||||
|
V2F_C4B_T2F a = {firstVertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F b = {lastVertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F c = {vertex, col, texCoord };
|
||||||
|
V2F_C4B_T2F_Triangle triangle = {a, b, c};
|
||||||
|
((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle;
|
||||||
|
|
||||||
|
lastVertex = vertex;
|
||||||
|
t += 1.0f / segments;
|
||||||
|
_bufferCount += 3;
|
||||||
|
}
|
||||||
|
_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
void DrawNode::clear()
|
void DrawNode::clear()
|
||||||
{
|
{
|
||||||
_bufferCount = 0;
|
_bufferCount = 0;
|
||||||
|
|
|
@ -64,6 +64,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||||
|
|
||||||
|
/** draw a triangle with color */
|
||||||
|
void drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color);
|
||||||
|
|
||||||
|
/** draw a cubic bezier curve with color and number of segments */
|
||||||
|
void drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color);
|
||||||
|
|
||||||
|
/** draw a quadratic bezier curve with color and number of segments */
|
||||||
|
void drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color);
|
||||||
|
|
||||||
/** Clear the geometry in the node's buffer. */
|
/** Clear the geometry in the node's buffer. */
|
||||||
void clear();
|
void clear();
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,15 +43,30 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
//CCLabelAtlas - Creation & Init
|
//CCLabelAtlas - Creation & Init
|
||||||
|
|
||||||
|
LabelAtlas* LabelAtlas::create()
|
||||||
|
{
|
||||||
|
LabelAtlas* ret = new LabelAtlas();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
ret->autorelease();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE_NULL(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
|
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
|
||||||
{
|
{
|
||||||
LabelAtlas *pRet = new LabelAtlas();
|
LabelAtlas* ret = new LabelAtlas();
|
||||||
if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
|
if(ret && ret->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
|
||||||
{
|
{
|
||||||
pRet->autorelease();
|
ret->autorelease();
|
||||||
return pRet;
|
return ret;
|
||||||
}
|
}
|
||||||
CC_SAFE_DELETE(pRet);
|
CC_SAFE_DELETE(ret);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,23 +52,11 @@ A more flexible class is LabelBMFont. It supports variable width characters and
|
||||||
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
|
class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/** creates an empty LabelAtlas, user need to call initWithString(...) later to make this object work properly **/
|
||||||
* @js ctor
|
static LabelAtlas* create();
|
||||||
*/
|
|
||||||
LabelAtlas()
|
|
||||||
:_string("")
|
|
||||||
{}
|
|
||||||
/**
|
|
||||||
* @js NA
|
|
||||||
* @lua NA
|
|
||||||
*/
|
|
||||||
virtual ~LabelAtlas()
|
|
||||||
{
|
|
||||||
_string.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
/** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||||
static LabelAtlas * create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
static LabelAtlas* create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||||
|
|
||||||
/** creates the LabelAtlas with a string and a configuration file
|
/** creates the LabelAtlas with a string and a configuration file
|
||||||
@since v2.0
|
@since v2.0
|
||||||
|
@ -98,6 +86,15 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
LabelAtlas()
|
||||||
|
:_string("")
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~LabelAtlas()
|
||||||
|
{
|
||||||
|
_string.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// string to render
|
// string to render
|
||||||
std::string _string;
|
std::string _string;
|
||||||
// the first char in the charmap
|
// the first char in the charmap
|
||||||
|
|
|
@ -348,9 +348,8 @@ bool MenuItemAtlasFont::initWithString(const std::string& value, const std::stri
|
||||||
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
|
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||||
{
|
{
|
||||||
CCASSERT( value.size() != 0, "value length must be greater than 0");
|
CCASSERT( value.size() != 0, "value length must be greater than 0");
|
||||||
LabelAtlas *label = new LabelAtlas();
|
LabelAtlas *label = LabelAtlas::create();
|
||||||
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
|
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
|
||||||
label->autorelease();
|
|
||||||
if (MenuItemLabel::initWithLabel(label, callback))
|
if (MenuItemLabel::initWithLabel(label, callback))
|
||||||
{
|
{
|
||||||
// do something ?
|
// do something ?
|
||||||
|
|
|
@ -183,7 +183,7 @@ void TextureCache::loadImage()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_imageInfoMutex.unlock();
|
_imageInfoMutex.unlock();
|
||||||
if(infoSize > 0 && pos < infoSize)
|
if(infoSize == 0 || pos < infoSize)
|
||||||
generateImage = true;
|
generateImage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,7 +376,7 @@ namespace
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Image::Image()
|
Image::Image()
|
||||||
: _data(0)
|
: _data(nullptr)
|
||||||
, _dataLen(0)
|
, _dataLen(0)
|
||||||
, _width(0)
|
, _width(0)
|
||||||
, _height(0)
|
, _height(0)
|
||||||
|
@ -391,10 +391,7 @@ Image::Image()
|
||||||
|
|
||||||
Image::~Image()
|
Image::~Image()
|
||||||
{
|
{
|
||||||
if (_data != nullptr)
|
CC_SAFE_FREE(_data);
|
||||||
{
|
|
||||||
free(_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::initWithImageFile(const std::string& path)
|
bool Image::initWithImageFile(const std::string& path)
|
||||||
|
@ -1539,7 +1536,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
|
||||||
|
|
||||||
}while(false);
|
}while(false);
|
||||||
|
|
||||||
if (!ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
const unsigned char tgaSuffix[] = ".tga";
|
const unsigned char tgaSuffix[] = ".tga";
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
|
@ -1556,6 +1553,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
|
||||||
if (tgaData->imageData != nullptr)
|
if (tgaData->imageData != nullptr)
|
||||||
{
|
{
|
||||||
free(tgaData->imageData);
|
free(tgaData->imageData);
|
||||||
|
_data = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,52 +30,6 @@ namespace gui {
|
||||||
|
|
||||||
static const int LABELATLAS_RENDERER_Z = (-1);
|
static const int LABELATLAS_RENDERER_Z = (-1);
|
||||||
|
|
||||||
|
|
||||||
UICCLabelAtlas::UICCLabelAtlas()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
UICCLabelAtlas::~UICCLabelAtlas()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
UICCLabelAtlas* UICCLabelAtlas::create()
|
|
||||||
{
|
|
||||||
UICCLabelAtlas *pRet = new UICCLabelAtlas();
|
|
||||||
if(pRet)
|
|
||||||
{
|
|
||||||
pRet->autorelease();
|
|
||||||
return pRet;
|
|
||||||
}
|
|
||||||
CC_SAFE_DELETE(pRet);
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap)
|
|
||||||
{
|
|
||||||
initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UICCLabelAtlas::setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap)
|
|
||||||
{
|
|
||||||
initWithString(string, texture, itemWidth, itemHeight, startCharMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UICCLabelAtlas::draw()
|
|
||||||
{
|
|
||||||
if (!_textureAtlas)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtlasNode::draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TextAtlas::TextAtlas():
|
TextAtlas::TextAtlas():
|
||||||
_labelAtlasRenderer(nullptr),
|
_labelAtlasRenderer(nullptr),
|
||||||
_stringValue(""),
|
_stringValue(""),
|
||||||
|
@ -84,7 +38,6 @@ _itemWidth(0),
|
||||||
_itemHeight(0),
|
_itemHeight(0),
|
||||||
_startCharMap("")
|
_startCharMap("")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextAtlas::~TextAtlas()
|
TextAtlas::~TextAtlas()
|
||||||
|
@ -106,7 +59,7 @@ TextAtlas* TextAtlas::create()
|
||||||
|
|
||||||
void TextAtlas::initRenderer()
|
void TextAtlas::initRenderer()
|
||||||
{
|
{
|
||||||
_labelAtlasRenderer = UICCLabelAtlas::create();
|
_labelAtlasRenderer = LabelAtlas::create();
|
||||||
Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1);
|
Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +70,7 @@ void TextAtlas::setProperty(const std::string& stringValue, const std::string& c
|
||||||
_itemWidth = itemWidth;
|
_itemWidth = itemWidth;
|
||||||
_itemHeight = itemHeight;
|
_itemHeight = itemHeight;
|
||||||
_startCharMap = startCharMap;
|
_startCharMap = startCharMap;
|
||||||
_labelAtlasRenderer->setProperty(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0]));
|
_labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0]));
|
||||||
updateAnchorPoint();
|
updateAnchorPoint();
|
||||||
labelAtlasScaleChangedWithSize();
|
labelAtlasScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,31 +31,6 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
/**
|
|
||||||
* @js NA
|
|
||||||
* @lua NA
|
|
||||||
*/
|
|
||||||
class UICCLabelAtlas : public LabelAtlas
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Default constructor
|
|
||||||
*/
|
|
||||||
UICCLabelAtlas();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default destructor
|
|
||||||
*/
|
|
||||||
virtual ~UICCLabelAtlas();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates and initializes.
|
|
||||||
*/
|
|
||||||
static UICCLabelAtlas* create();
|
|
||||||
void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
|
||||||
void setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
|
||||||
virtual void draw(void) override;
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
|
@ -108,7 +83,7 @@ protected:
|
||||||
virtual Widget* createCloneInstance() override;
|
virtual Widget* createCloneInstance() override;
|
||||||
virtual void copySpecialProperties(Widget* model) override;
|
virtual void copySpecialProperties(Widget* model) override;
|
||||||
protected:
|
protected:
|
||||||
UICCLabelAtlas* _labelAtlasRenderer;
|
LabelAtlas* _labelAtlasRenderer;
|
||||||
std::string _stringValue;
|
std::string _stringValue;
|
||||||
std::string _charMapFileName;
|
std::string _charMapFileName;
|
||||||
int _itemWidth;
|
int _itemWidth;
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#include "libwebsockets.h"
|
#include "libwebsockets.h"
|
||||||
|
|
||||||
|
#define WS_WRITE_BUFFER_SIZE 2048
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
namespace network {
|
namespace network {
|
||||||
|
@ -44,7 +46,7 @@ namespace network {
|
||||||
class WsMessage
|
class WsMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WsMessage() : what(0), obj(NULL){}
|
WsMessage() : what(0), obj(nullptr){}
|
||||||
unsigned int what; // message type
|
unsigned int what; // message type
|
||||||
void* obj;
|
void* obj;
|
||||||
};
|
};
|
||||||
|
@ -112,7 +114,7 @@ public:
|
||||||
// Implementation of WsThreadHelper
|
// Implementation of WsThreadHelper
|
||||||
WsThreadHelper::WsThreadHelper()
|
WsThreadHelper::WsThreadHelper()
|
||||||
: _subThreadInstance(nullptr)
|
: _subThreadInstance(nullptr)
|
||||||
, _ws(NULL)
|
, _ws(nullptr)
|
||||||
, _needQuit(false)
|
, _needQuit(false)
|
||||||
{
|
{
|
||||||
_UIWsMessageQueue = new std::list<WsMessage*>();
|
_UIWsMessageQueue = new std::list<WsMessage*>();
|
||||||
|
@ -181,7 +183,7 @@ void WsThreadHelper::joinSubThread()
|
||||||
|
|
||||||
void WsThreadHelper::update(float dt)
|
void WsThreadHelper::update(float dt)
|
||||||
{
|
{
|
||||||
WsMessage *msg = NULL;
|
WsMessage *msg = nullptr;
|
||||||
|
|
||||||
// Returns quickly if no message
|
// Returns quickly if no message
|
||||||
std::lock_guard<std::mutex> lk(_UIWsMessageQueueMutex);
|
std::lock_guard<std::mutex> lk(_UIWsMessageQueueMutex);
|
||||||
|
@ -221,6 +223,9 @@ WebSocket::WebSocket()
|
||||||
, _delegate(nullptr)
|
, _delegate(nullptr)
|
||||||
, _SSLConnection(0)
|
, _SSLConnection(0)
|
||||||
, _wsProtocols(nullptr)
|
, _wsProtocols(nullptr)
|
||||||
|
, _pendingFrameDataLen(0)
|
||||||
|
, _currentDataLen(0)
|
||||||
|
, _currentData(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +243,7 @@ WebSocket::~WebSocket()
|
||||||
|
|
||||||
bool WebSocket::init(const Delegate& delegate,
|
bool WebSocket::init(const Delegate& delegate,
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const std::vector<std::string>* protocols/* = NULL*/)
|
const std::vector<std::string>* protocols/* = nullptr*/)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
bool useSSL = false;
|
bool useSSL = false;
|
||||||
|
@ -497,12 +502,13 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
|
|
||||||
case LWS_CALLBACK_CLIENT_WRITEABLE:
|
case LWS_CALLBACK_CLIENT_WRITEABLE:
|
||||||
{
|
{
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(_wsHelper->_subThreadWsMessageQueueMutex);
|
std::lock_guard<std::mutex> lk(_wsHelper->_subThreadWsMessageQueueMutex);
|
||||||
|
|
||||||
std::list<WsMessage*>::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin();
|
std::list<WsMessage*>::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin();
|
||||||
|
|
||||||
int bytesWrite = 0;
|
int bytesWrite = 0;
|
||||||
for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter)
|
for (; iter != _wsHelper->_subThreadWsMessageQueue->end();)
|
||||||
{
|
{
|
||||||
WsMessage* subThreadMsg = *iter;
|
WsMessage* subThreadMsg = *iter;
|
||||||
|
|
||||||
|
@ -511,45 +517,65 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
{
|
{
|
||||||
Data* data = (Data*)subThreadMsg->obj;
|
Data* data = (Data*)subThreadMsg->obj;
|
||||||
|
|
||||||
unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING
|
const size_t c_bufferSize = WS_WRITE_BUFFER_SIZE;
|
||||||
+ data->len + LWS_SEND_BUFFER_POST_PADDING];
|
|
||||||
|
|
||||||
memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, data->len);
|
size_t remaining = data->len - data->issued;
|
||||||
memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes, data->len);
|
size_t n = std::min(remaining, c_bufferSize );
|
||||||
|
CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", data->len, data->issued, remaining, n);
|
||||||
|
|
||||||
enum libwebsocket_write_protocol writeProtocol;
|
unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING];
|
||||||
|
|
||||||
if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what)
|
memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n);
|
||||||
{
|
|
||||||
writeProtocol = LWS_WRITE_TEXT;
|
int writeProtocol;
|
||||||
}
|
|
||||||
else
|
if (data->issued == 0) {
|
||||||
{
|
if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what)
|
||||||
writeProtocol = LWS_WRITE_BINARY;
|
{
|
||||||
|
writeProtocol = LWS_WRITE_TEXT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeProtocol = LWS_WRITE_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have more than 1 fragment
|
||||||
|
if (data->len > c_bufferSize)
|
||||||
|
writeProtocol |= LWS_WRITE_NO_FIN;
|
||||||
|
} else {
|
||||||
|
// we are in the middle of fragments
|
||||||
|
writeProtocol = LWS_WRITE_CONTINUATION;
|
||||||
|
// and if not in the last fragment
|
||||||
|
if (remaining != n)
|
||||||
|
writeProtocol |= LWS_WRITE_NO_FIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], data->len, writeProtocol);
|
bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], n, (libwebsocket_write_protocol)writeProtocol);
|
||||||
|
CCLOG("[websocket:send] bytesWrite => %d", bytesWrite);
|
||||||
|
|
||||||
|
// Buffer overrun?
|
||||||
if (bytesWrite < 0)
|
if (bytesWrite < 0)
|
||||||
{
|
{
|
||||||
CCLOGERROR("%s", "libwebsocket_write error...");
|
break;
|
||||||
}
|
}
|
||||||
if (bytesWrite < data->len)
|
// Do we have another fragments to send?
|
||||||
|
else if (remaining != n)
|
||||||
{
|
{
|
||||||
CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n");
|
data->issued += n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Safely done!
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE_ARRAY(data->bytes);
|
||||||
|
CC_SAFE_DELETE(data);
|
||||||
|
CC_SAFE_DELETE_ARRAY(buf);
|
||||||
|
_wsHelper->_subThreadWsMessageQueue->erase(iter++);
|
||||||
|
CC_SAFE_DELETE(subThreadMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_SAFE_DELETE_ARRAY(data->bytes);
|
|
||||||
CC_SAFE_DELETE(data);
|
|
||||||
CC_SAFE_DELETE_ARRAY(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_SAFE_DELETE(subThreadMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_wsHelper->_subThreadWsMessageQueue->clear();
|
|
||||||
|
|
||||||
|
|
||||||
/* get notified as soon as we can write again */
|
/* get notified as soon as we can write again */
|
||||||
|
|
||||||
libwebsocket_callback_on_writable(ctx, wsi);
|
libwebsocket_callback_on_writable(ctx, wsi);
|
||||||
|
@ -577,32 +603,64 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||||
{
|
{
|
||||||
if (in && len > 0)
|
if (in && len > 0)
|
||||||
{
|
{
|
||||||
WsMessage* msg = new WsMessage();
|
// Accumulate the data (increasing the buffer as we go)
|
||||||
msg->what = WS_MSG_TO_UITHREAD_MESSAGE;
|
if (_currentDataLen == 0)
|
||||||
|
|
||||||
char* bytes = NULL;
|
|
||||||
Data* data = new Data();
|
|
||||||
|
|
||||||
if (lws_frame_is_binary(wsi))
|
|
||||||
{
|
{
|
||||||
|
_currentData = new char[len];
|
||||||
bytes = new char[len];
|
memcpy (_currentData, in, len);
|
||||||
data->isBinary = true;
|
_currentDataLen = len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bytes = new char[len+1];
|
char *new_data = new char [_currentDataLen + len];
|
||||||
bytes[len] = '\0';
|
memcpy (new_data, _currentData, _currentDataLen);
|
||||||
data->isBinary = false;
|
memcpy (new_data + _currentDataLen, in, len);
|
||||||
|
CC_SAFE_DELETE_ARRAY(_currentData);
|
||||||
|
_currentData = new_data;
|
||||||
|
_currentDataLen = _currentDataLen + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(bytes, in, len);
|
_pendingFrameDataLen = libwebsockets_remaining_packet_payload (wsi);
|
||||||
|
|
||||||
data->bytes = bytes;
|
if (_pendingFrameDataLen > 0)
|
||||||
data->len = len;
|
{
|
||||||
msg->obj = (void*)data;
|
//CCLOG("%ld bytes of pending data to receive, consider increasing the libwebsocket rx_buffer_size value.", _pendingFrameDataLen);
|
||||||
|
}
|
||||||
|
|
||||||
_wsHelper->sendMessageToUIThread(msg);
|
// If no more data pending, send it to the client thread
|
||||||
|
if (_pendingFrameDataLen == 0)
|
||||||
|
{
|
||||||
|
WsMessage* msg = new WsMessage();
|
||||||
|
msg->what = WS_MSG_TO_UITHREAD_MESSAGE;
|
||||||
|
|
||||||
|
char* bytes = nullptr;
|
||||||
|
Data* data = new Data();
|
||||||
|
|
||||||
|
if (lws_frame_is_binary(wsi))
|
||||||
|
{
|
||||||
|
|
||||||
|
bytes = new char[_currentDataLen];
|
||||||
|
data->isBinary = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bytes = new char[_currentDataLen+1];
|
||||||
|
bytes[_currentDataLen] = '\0';
|
||||||
|
data->isBinary = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(bytes, _currentData, _currentDataLen);
|
||||||
|
|
||||||
|
data->bytes = bytes;
|
||||||
|
data->len = _currentDataLen;
|
||||||
|
msg->obj = (void*)data;
|
||||||
|
|
||||||
|
CC_SAFE_DELETE_ARRAY(_currentData);
|
||||||
|
_currentData = nullptr;
|
||||||
|
_currentDataLen = 0;
|
||||||
|
|
||||||
|
_wsHelper->sendMessageToUIThread(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -62,9 +62,9 @@ public:
|
||||||
*/
|
*/
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
Data():bytes(NULL), len(0), isBinary(false){}
|
Data():bytes(nullptr), len(0), issued(0), isBinary(false){}
|
||||||
char* bytes;
|
char* bytes;
|
||||||
ssize_t len;
|
ssize_t len, issued;
|
||||||
bool isBinary;
|
bool isBinary;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool init(const Delegate& delegate,
|
bool init(const Delegate& delegate,
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const std::vector<std::string>* protocols = NULL);
|
const std::vector<std::string>* protocols = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sends string data to websocket server.
|
* @brief Sends string data to websocket server.
|
||||||
|
@ -153,6 +153,10 @@ private:
|
||||||
unsigned int _port;
|
unsigned int _port;
|
||||||
std::string _path;
|
std::string _path;
|
||||||
|
|
||||||
|
size_t _pendingFrameDataLen;
|
||||||
|
unsigned int _currentDataLen;
|
||||||
|
char *_currentData;
|
||||||
|
|
||||||
friend class WsThreadHelper;
|
friend class WsThreadHelper;
|
||||||
WsThreadHelper* _wsHelper;
|
WsThreadHelper* _wsHelper;
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f387eb216fd0849b8482203c76b5a8ce1b99471b
|
Subproject commit f7835c13644591879f5a995074ccc8faf70c355e
|
|
@ -102,18 +102,22 @@ void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data)
|
||||||
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
|
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
|
||||||
if (NULL != luaWs) {
|
if (NULL != luaWs) {
|
||||||
if (data.isBinary) {
|
if (data.isBinary) {
|
||||||
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
|
||||||
if (0 != nHandler) {
|
if (0 != handler) {
|
||||||
SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len);
|
SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, data.len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
|
||||||
if (0 != nHandler) {
|
if (0 != handler)
|
||||||
CommonScriptData commonData(nHandler,data.bytes);
|
{
|
||||||
ScriptEvent event(kCommonEvent,(void*)&commonData);
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
if (nullptr != stack)
|
||||||
|
{
|
||||||
|
stack->pushString(data.bytes,data.len);
|
||||||
|
stack->executeFunctionByHandler(handler, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,13 +80,13 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
||||||
_parentInited = true;
|
_parentInited = true;
|
||||||
|
|
||||||
_isPushed = false;
|
_isPushed = false;
|
||||||
_zoomOnTouchDown = true;
|
|
||||||
|
|
||||||
// Adjust the background image by default
|
// Adjust the background image by default
|
||||||
setAdjustBackgroundImage(true);
|
setAdjustBackgroundImage(true);
|
||||||
setPreferredSize(Size::ZERO);
|
setPreferredSize(Size::ZERO);
|
||||||
// Zooming button by default
|
// Zooming button by default
|
||||||
_zoomOnTouchDown = true;
|
_zoomOnTouchDown = true;
|
||||||
|
_scaleRatio = 1.1f;
|
||||||
|
|
||||||
// Set the default anchor point
|
// Set the default anchor point
|
||||||
ignoreAnchorPointForPosition(false);
|
ignoreAnchorPointForPosition(false);
|
||||||
|
@ -199,7 +199,7 @@ void ControlButton::setHighlighted(bool enabled)
|
||||||
needsLayout();
|
needsLayout();
|
||||||
if( _zoomOnTouchDown )
|
if( _zoomOnTouchDown )
|
||||||
{
|
{
|
||||||
float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f;
|
float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? _scaleRatio : 1.0f;
|
||||||
Action *zoomAction = ScaleTo::create(0.05f, scaleValue);
|
Action *zoomAction = ScaleTo::create(0.05f, scaleValue);
|
||||||
zoomAction->setTag(kZoomActionTag);
|
zoomAction->setTag(kZoomActionTag);
|
||||||
runAction(zoomAction);
|
runAction(zoomAction);
|
||||||
|
|
|
@ -226,6 +226,8 @@ protected:
|
||||||
|
|
||||||
/** Adjust the button zooming on touchdown. Default value is YES. */
|
/** Adjust the button zooming on touchdown. Default value is YES. */
|
||||||
CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown);
|
CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown);
|
||||||
|
/** Scale ratio button on touchdown. Default value 1.1f */
|
||||||
|
CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio);
|
||||||
|
|
||||||
CC_PROPERTY_PASS_BY_REF(Point, _labelAnchorPoint, LabelAnchorPoint);
|
CC_PROPERTY_PASS_BY_REF(Point, _labelAnchorPoint, LabelAnchorPoint);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ ControlSlider::ControlSlider()
|
||||||
, _minimumAllowedValue(0.0f)
|
, _minimumAllowedValue(0.0f)
|
||||||
, _maximumAllowedValue(0.0f)
|
, _maximumAllowedValue(0.0f)
|
||||||
, _thumbSprite(NULL)
|
, _thumbSprite(NULL)
|
||||||
|
, _selectedThumbSprite(NULL)
|
||||||
, _progressSprite(NULL)
|
, _progressSprite(NULL)
|
||||||
, _backgroundSprite(NULL)
|
, _backgroundSprite(NULL)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +50,7 @@ ControlSlider::ControlSlider()
|
||||||
ControlSlider::~ControlSlider()
|
ControlSlider::~ControlSlider()
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE(_thumbSprite);
|
CC_SAFE_RELEASE(_thumbSprite);
|
||||||
|
CC_SAFE_RELEASE(_selectedThumbSprite);
|
||||||
CC_SAFE_RELEASE(_progressSprite);
|
CC_SAFE_RELEASE(_progressSprite);
|
||||||
CC_SAFE_RELEASE(_backgroundSprite);
|
CC_SAFE_RELEASE(_backgroundSprite);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,24 @@ ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFil
|
||||||
return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite);
|
return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile,
|
||||||
|
const char* selectedThumbSpriteFile)
|
||||||
|
{
|
||||||
|
// Prepare background for slider
|
||||||
|
Sprite *backgroundSprite = Sprite::create(bgFile);
|
||||||
|
|
||||||
|
// Prepare progress for slider
|
||||||
|
Sprite *progressSprite = Sprite::create(progressFile);
|
||||||
|
|
||||||
|
// Prepare thumb (menuItem) for slider
|
||||||
|
Sprite *thumbSprite = Sprite::create(thumbFile);
|
||||||
|
|
||||||
|
// Prepare selected thumb (menuItem) for slider
|
||||||
|
Sprite *selectedThumbSprite = Sprite::create(selectedThumbSpriteFile);
|
||||||
|
|
||||||
|
return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite);
|
||||||
|
}
|
||||||
|
|
||||||
ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite)
|
ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite)
|
||||||
{
|
{
|
||||||
ControlSlider *pRet = new ControlSlider();
|
ControlSlider *pRet = new ControlSlider();
|
||||||
|
@ -75,19 +95,39 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite)
|
ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite,
|
||||||
|
Sprite* selectedThumbSprite)
|
||||||
|
{
|
||||||
|
ControlSlider *pRet = new ControlSlider();
|
||||||
|
pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite, selectedThumbSprite);
|
||||||
|
pRet->autorelease();
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite)
|
||||||
|
{
|
||||||
|
Sprite* selectedThumbSprite = Sprite::createWithTexture(thumbSprite->getTexture(),
|
||||||
|
thumbSprite->getTextureRect());
|
||||||
|
selectedThumbSprite->setColor(Color3B::GRAY);
|
||||||
|
return this->initWithSprites(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite,
|
||||||
|
Sprite* selectedThumbSprite)
|
||||||
{
|
{
|
||||||
if (Control::init())
|
if (Control::init())
|
||||||
{
|
{
|
||||||
CCASSERT(backgroundSprite, "Background sprite must be not nil");
|
CCASSERT(backgroundSprite, "Background sprite must be not nil");
|
||||||
CCASSERT(progressSprite, "Progress sprite must be not nil");
|
CCASSERT(progressSprite, "Progress sprite must be not nil");
|
||||||
CCASSERT(thumbSprite, "Thumb sprite must be not nil");
|
CCASSERT(thumbSprite, "Thumb sprite must be not nil");
|
||||||
|
CCASSERT(selectedThumbSprite, "Thumb sprite must be not nil");
|
||||||
|
|
||||||
ignoreAnchorPointForPosition(false);
|
ignoreAnchorPointForPosition(false);
|
||||||
|
|
||||||
this->setBackgroundSprite(backgroundSprite);
|
this->setBackgroundSprite(backgroundSprite);
|
||||||
this->setProgressSprite(progressSprite);
|
this->setProgressSprite(progressSprite);
|
||||||
this->setThumbSprite(thumbSprite);
|
this->setThumbSprite(thumbSprite);
|
||||||
|
this->setSelectedThumbSprite(selectedThumbSprite);
|
||||||
|
|
||||||
// Defines the content size
|
// Defines the content size
|
||||||
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox());
|
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox());
|
||||||
|
@ -108,6 +148,10 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS
|
||||||
_thumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2));
|
_thumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2));
|
||||||
addChild(_thumbSprite);
|
addChild(_thumbSprite);
|
||||||
|
|
||||||
|
_selectedThumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2));
|
||||||
|
_selectedThumbSprite->setVisible(false);
|
||||||
|
addChild(_selectedThumbSprite);
|
||||||
|
|
||||||
// Init default values
|
// Init default values
|
||||||
_minimumValue = 0.0f;
|
_minimumValue = 0.0f;
|
||||||
_maximumValue = 1.0f;
|
_maximumValue = 1.0f;
|
||||||
|
@ -227,7 +271,8 @@ void ControlSlider::onTouchEnded(Touch *pTouch, Event *pEvent)
|
||||||
|
|
||||||
void ControlSlider::needsLayout()
|
void ControlSlider::needsLayout()
|
||||||
{
|
{
|
||||||
if (NULL == _thumbSprite || NULL == _backgroundSprite || NULL == _progressSprite)
|
if (NULL == _thumbSprite || NULL == _selectedThumbSprite || NULL == _backgroundSprite
|
||||||
|
|| NULL == _progressSprite)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -237,6 +282,7 @@ void ControlSlider::needsLayout()
|
||||||
Point pos = _thumbSprite->getPosition();
|
Point pos = _thumbSprite->getPosition();
|
||||||
pos.x = percent * _backgroundSprite->getContentSize().width;
|
pos.x = percent * _backgroundSprite->getContentSize().width;
|
||||||
_thumbSprite->setPosition(pos);
|
_thumbSprite->setPosition(pos);
|
||||||
|
_selectedThumbSprite->setPosition(pos);
|
||||||
|
|
||||||
// Stretches content proportional to newLevel
|
// Stretches content proportional to newLevel
|
||||||
Rect textureRect = _progressSprite->getTextureRect();
|
Rect textureRect = _progressSprite->getTextureRect();
|
||||||
|
@ -247,7 +293,8 @@ void ControlSlider::needsLayout()
|
||||||
void ControlSlider::sliderBegan(Point location)
|
void ControlSlider::sliderBegan(Point location)
|
||||||
{
|
{
|
||||||
this->setSelected(true);
|
this->setSelected(true);
|
||||||
this->getThumbSprite()->setColor(Color3B::GRAY);
|
_thumbSprite->setVisible(false);
|
||||||
|
_selectedThumbSprite->setVisible(true);
|
||||||
setValue(valueForLocation(location));
|
setValue(valueForLocation(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +309,8 @@ void ControlSlider::sliderEnded(Point location)
|
||||||
{
|
{
|
||||||
setValue(valueForLocation(_thumbSprite->getPosition()));
|
setValue(valueForLocation(_thumbSprite->getPosition()));
|
||||||
}
|
}
|
||||||
this->getThumbSprite()->setColor(Color3B::WHITE);
|
_thumbSprite->setVisible(true);
|
||||||
|
_selectedThumbSprite->setVisible(false);
|
||||||
this->setSelected(false);
|
this->setSelected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,22 @@ public:
|
||||||
* @see initWithSprites
|
* @see initWithSprites
|
||||||
*/
|
*/
|
||||||
static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite);
|
static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates slider with a background filename, a progress filename, a thumb
|
||||||
|
* and a selected thumb image filename.
|
||||||
|
*/
|
||||||
|
static ControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile,
|
||||||
|
const char* selectedThumbSpriteFile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a slider with a given background sprite and a progress bar, a thumb
|
||||||
|
* and a selected thumb .
|
||||||
|
*
|
||||||
|
* @see initWithSprites
|
||||||
|
*/
|
||||||
|
static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite,
|
||||||
|
Sprite* selectedThumbSprite);
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
*/
|
*/
|
||||||
|
@ -72,12 +88,24 @@ public:
|
||||||
* Initializes a slider with a background sprite, a progress bar and a thumb
|
* Initializes a slider with a background sprite, a progress bar and a thumb
|
||||||
* item.
|
* item.
|
||||||
*
|
*
|
||||||
* @param backgroundSprite Sprite, that is used as a background.
|
* @param backgroundSprite Sprite, that is used as a background.
|
||||||
* @param progressSprite Sprite, that is used as a progress bar.
|
* @param progressSprite Sprite, that is used as a progress bar.
|
||||||
* @param thumbSprite Sprite, that is used as a thumb.
|
* @param thumbSprite Sprite, that is used as a thumb.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite);
|
virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a slider with a background sprite, a progress bar and a thumb
|
||||||
|
* item.
|
||||||
|
*
|
||||||
|
* @param backgroundSprite Sprite, that is used as a background.
|
||||||
|
* @param progressSprite Sprite, that is used as a progress bar.
|
||||||
|
* @param thumbSprite Sprite, that is used as a thumb.
|
||||||
|
* @param selectedThumbSprite Sprite, that is used as a selected thumb.
|
||||||
|
*/
|
||||||
|
virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite,
|
||||||
|
Sprite* selectedThumbSprite);
|
||||||
|
|
||||||
virtual void needsLayout();
|
virtual void needsLayout();
|
||||||
|
|
||||||
virtual void setMaximumValue(float val);
|
virtual void setMaximumValue(float val);
|
||||||
|
@ -116,8 +144,10 @@ protected:
|
||||||
|
|
||||||
// maybe this should be read-only
|
// maybe this should be read-only
|
||||||
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite);
|
CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite);
|
||||||
|
CC_SYNTHESIZE_RETAIN(Sprite*, _selectedThumbSprite, SelectedThumbSprite);
|
||||||
CC_SYNTHESIZE_RETAIN(Sprite*, _progressSprite, ProgressSprite);
|
CC_SYNTHESIZE_RETAIN(Sprite*, _progressSprite, ProgressSprite);
|
||||||
CC_SYNTHESIZE_RETAIN(Sprite*, _backgroundSprite, BackgroundSprite);
|
CC_SYNTHESIZE_RETAIN(Sprite*, _backgroundSprite, BackgroundSprite);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of GUI group
|
// end of GUI group
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
#include "extensions/GUI/CCControlExtension/CCControlSlider.h"
|
#include "extensions/GUI/CCControlExtension/CCControlSlider.h"
|
||||||
|
|
||||||
// android effect only support ogg
|
// android effect only support ogg
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFOR_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
#define EFFECT_FILE "effect2.ogg"
|
#define EFFECT_FILE "effect2.ogg"
|
||||||
#elif( CC_TARGET_PLATFORM == CC_PLATFOR_MARMALADE)
|
#elif( CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
||||||
#define EFFECT_FILE "effect1.raw"
|
#define EFFECT_FILE "effect1.raw"
|
||||||
#else
|
#else
|
||||||
#define EFFECT_FILE "effect1.wav"
|
#define EFFECT_FILE "effect1.wav"
|
||||||
#endif // CC_PLATFOR_ANDROID
|
#endif // CC_PLATFOR_ANDROID
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFOR_WIN32)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
#define MUSIC_FILE "music.mid"
|
#define MUSIC_FILE "music.mid"
|
||||||
#elif (CC_TARGET_PLATFORM == CC_PLATFOR_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFOR_LINUX )
|
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX )
|
||||||
#define MUSIC_FILE "background.ogg"
|
#define MUSIC_FILE "background.ogg"
|
||||||
#else
|
#else
|
||||||
#define MUSIC_FILE "background.mp3"
|
#define MUSIC_FILE "background.mp3"
|
||||||
|
|
|
@ -302,6 +302,14 @@ DrawNodeTest::DrawNodeTest()
|
||||||
draw->drawSegment(Point(20,s.height), Point(20,s.height/2), 10, Color4F(0, 1, 0, 1));
|
draw->drawSegment(Point(20,s.height), Point(20,s.height/2), 10, Color4F(0, 1, 0, 1));
|
||||||
|
|
||||||
draw->drawSegment(Point(10,s.height/2), Point(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5));
|
draw->drawSegment(Point(10,s.height/2), Point(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5));
|
||||||
|
|
||||||
|
// Draw triangle
|
||||||
|
draw->drawTriangle(Point(10, 10), Point(70, 30), Point(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5));
|
||||||
|
|
||||||
|
// Draw some beziers
|
||||||
|
draw->drawQuadraticBezier(Point(s.width - 150, s.height - 150), Point(s.width - 70, s.height - 10), Point(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5));
|
||||||
|
|
||||||
|
draw->drawCubicBezier(Point(s.width - 250, 40), Point(s.width - 70, 100), Point(s.width - 30, 250), Point(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
string DrawNodeTest::title() const
|
string DrawNodeTest::title() const
|
||||||
|
|
|
@ -25,6 +25,7 @@ static std::function<Layer*()> createFunctions[] = {
|
||||||
CL(LayerExtendedBlendOpacityTest),
|
CL(LayerExtendedBlendOpacityTest),
|
||||||
CL(LayerBug3162A),
|
CL(LayerBug3162A),
|
||||||
CL(LayerBug3162B),
|
CL(LayerBug3162B),
|
||||||
|
CL(LayerColorOccludeBug),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sceneIdx=-1;
|
static int sceneIdx=-1;
|
||||||
|
@ -954,3 +955,27 @@ std::string LayerBug3162B::subtitle() const
|
||||||
{
|
{
|
||||||
return "u and m layer color is effected/diseffected with b layer";
|
return "u and m layer color is effected/diseffected with b layer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string LayerColorOccludeBug::title() const
|
||||||
|
{
|
||||||
|
return "Layer Color Occlude Bug Test";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LayerColorOccludeBug::subtitle() const
|
||||||
|
{
|
||||||
|
return "Layer Color Should not occlude titles and any sprites";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerColorOccludeBug::onEnter()
|
||||||
|
{
|
||||||
|
LayerTest::onEnter();
|
||||||
|
Director::getInstance()->setDepthTest(true);
|
||||||
|
_layer = LayerColor::create(Color4B(0, 80, 95, 255));
|
||||||
|
addChild(_layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerColorOccludeBug::onExit()
|
||||||
|
{
|
||||||
|
LayerTest::onExit();
|
||||||
|
Director::getInstance()->setDepthTest(false);
|
||||||
|
}
|
||||||
|
|
|
@ -202,6 +202,19 @@ private:
|
||||||
LayerColor* _layer[3];
|
LayerColor* _layer[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LayerColorOccludeBug : public LayerTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(LayerColorOccludeBug);
|
||||||
|
virtual void onEnter() override;
|
||||||
|
virtual void onExit() override;
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
LayerColor* _layer;
|
||||||
|
};
|
||||||
|
|
||||||
class LayerTestScene : public TestScene
|
class LayerTestScene : public TestScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -19,7 +19,7 @@ r = requests.get(api_get_pr)
|
||||||
pr = r.json()
|
pr = r.json()
|
||||||
|
|
||||||
#forge a payload
|
#forge a payload
|
||||||
payload = {"action":"open","number":"","pull_request":""}
|
payload = {"action":"opened","number":"","pull_request":""}
|
||||||
payload['number']=pr_num
|
payload['number']=pr_num
|
||||||
payload['pull_request']=pr
|
payload['pull_request']=pr
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Generate JS and Lua bindings for Cocos2D-X
|
||||||
|
# ... using Android NDK system headers
|
||||||
|
# ... and automatically update submodule references
|
||||||
|
# ... and push these changes to remote repos
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
#
|
||||||
|
# For bindings generator:
|
||||||
|
# (see ../../../tojs/genbindings.sh and ../../../tolua/genbindings.sh
|
||||||
|
# ... for the defaults used if the environment is not customized)
|
||||||
|
#
|
||||||
|
# * $PYTHON_BIN
|
||||||
|
# * $CLANG_ROOT
|
||||||
|
# * $NDK_ROOT
|
||||||
|
#
|
||||||
|
echo "[test]start generate js binding..."
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
COCOS2DX_ROOT="$DIR"/../..
|
||||||
|
TOJS_ROOT=$COCOS2DX_ROOT/tools/tojs
|
||||||
|
TOLUA_ROOT=$COCOS2DX_ROOT/tools/tolua
|
||||||
|
GENERATED_WORKTREE="$COCOS2DX_ROOT"/cocos/scripting/auto-generated
|
||||||
|
|
||||||
|
|
||||||
|
# Exit on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
generate_bindings_glue_codes()
|
||||||
|
{
|
||||||
|
echo "Create auto-generated jsbinding glue codes."
|
||||||
|
pushd "$TOJS_ROOT"
|
||||||
|
./genbindings.sh
|
||||||
|
popd
|
||||||
|
|
||||||
|
echo "Create auto-generated luabinding glue codes."
|
||||||
|
pushd "$TOLUA_ROOT"
|
||||||
|
./genbindings.sh
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
# Update submodule of auto-gen Binding repo.
|
||||||
|
pushd "$GENERATED_WORKTREE"
|
||||||
|
|
||||||
|
echo "Delete all directories and files except '.git' and 'README.md'."
|
||||||
|
ls -a | grep -E -v ^\[.\]\{1,2\}$ | grep -E -v ^\.git$ | grep -E -v ^README\.md$ | xargs -I{} rm -rf {}
|
||||||
|
popd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 1. Generate JS bindings
|
||||||
|
generate_bindings_glue_codes
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo Bindings generated successfully
|
||||||
|
echo
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,8 @@ def main():
|
||||||
action = payload['action']
|
action = payload['action']
|
||||||
print 'action: ' + action
|
print 'action: ' + action
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pr = payload['pull_request']
|
pr = payload['pull_request']
|
||||||
|
|
||||||
url = pr['html_url']
|
url = pr['html_url']
|
||||||
print "url:" + url
|
print "url:" + url
|
||||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
||||||
|
@ -62,6 +61,17 @@ def main():
|
||||||
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
|
r = requests.get(pr['url']+"/commits")
|
||||||
|
commits = r.json()
|
||||||
|
last_commit = commits[len(commits)-1]
|
||||||
|
message = last_commit['commit']['message']
|
||||||
|
|
||||||
|
pattern = re.compile("\[ci(\s+)skip\]", re.I)
|
||||||
|
result = pattern.search(message)
|
||||||
|
if result is not None:
|
||||||
|
print 'skip build for pull request #' + str(pr_num)
|
||||||
|
return(0)
|
||||||
|
|
||||||
data = {"state":"pending", "target_url":target_url}
|
data = {"state":"pending", "target_url":target_url}
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
Headers = {"Authorization":"token " + access_token}
|
Headers = {"Authorization":"token " + access_token}
|
||||||
|
@ -79,6 +89,7 @@ def main():
|
||||||
print "git clean -xdf"
|
print "git clean -xdf"
|
||||||
os.system("git clean -xdf")
|
os.system("git clean -xdf")
|
||||||
|
|
||||||
|
|
||||||
#fetch pull request to local repo
|
#fetch pull request to local repo
|
||||||
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head"
|
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head"
|
||||||
os.system(git_fetch_pr)
|
os.system(git_fetch_pr)
|
||||||
|
@ -91,6 +102,10 @@ def main():
|
||||||
git_update_submodule = "git submodule update --init --force"
|
git_update_submodule = "git submodule update --init --force"
|
||||||
os.system(git_update_submodule)
|
os.system(git_update_submodule)
|
||||||
|
|
||||||
|
# Generate binding glue codes
|
||||||
|
if(platform.system() == 'Darwin'):
|
||||||
|
os.system("tools/jenkins-scripts/gen_jsb.sh")
|
||||||
|
|
||||||
#make temp dir
|
#make temp dir
|
||||||
print "current dir is" + os.environ['WORKSPACE']
|
print "current dir is" + os.environ['WORKSPACE']
|
||||||
os.system("cd " + os.environ['WORKSPACE']);
|
os.system("cd " + os.environ['WORKSPACE']);
|
||||||
|
|
Loading…
Reference in New Issue