Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into support_for_xcode_iphone_64bit_simulator

This commit is contained in:
boyu0 2014-03-14 14:21:52 +08:00
commit fddffae611
39 changed files with 672 additions and 268 deletions

View File

@ -1 +1 @@
b8bc5839895bfc413816baa425d43a2b8e48205d
25c5be6d07f3ad8b7e96afbd2e2046d4691b9aa1

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
# android-build.py
# Build android
# Build android
import sys
import os, os.path
@ -12,21 +12,21 @@ LUA_SAMPLES = ['lua-empty-test', 'lua-tests']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
def get_num_of_cpu():
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
'''
try:
platform = sys.platform
if platform == 'win32':
if 'NUMBER_OF_PROCESSORS' in os.environ:
return int(os.environ['NUMBER_OF_PROCESSORS'])
else:
return 1
else:
from numpy.distutils import cpuinfo
return cpuinfo.cpu._getNCPUs()
except Exception:
print "Can't know cpuinfo, use default 1 cpu"
return 1
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
'''
try:
platform = sys.platform
if platform == 'win32':
if 'NUMBER_OF_PROCESSORS' in os.environ:
return int(os.environ['NUMBER_OF_PROCESSORS'])
else:
return 1
else:
from numpy.distutils import cpuinfo
return cpuinfo.cpu._getNCPUs()
except Exception:
print "Can't know cpuinfo, use default 1 cpu"
return 1
def check_environment_variables():
''' Checking the environment NDK_ROOT, which will be used for building
@ -39,7 +39,7 @@ def check_environment_variables():
sys.exit(1)
return NDK_ROOT
def check_environment_variables_sdk():
''' Checking the environment ANDROID_SDK_ROOT, which will be used for building
'''
@ -74,7 +74,7 @@ def select_toolchain_version():
def caculate_built_samples(args):
''' Compute the sampels to be built
'cpp' for short of all cpp tests
'lua' for short of all lua tests
'lua' for short of all lua tests
'''
if 'all' in args:
@ -115,17 +115,17 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an
if os.system(command) != 0:
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
elif android_platform is not None:
sdk_tool_path = os.path.join(sdk_root, "tools/android")
cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java")
command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
if os.system(command) != 0:
raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
if os.system(command) != 0:
raise Exception("update project [ " + app_android_root + " ] fails!")
buildfile_path = os.path.join(app_android_root, "build.xml")
command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
os.system(command)
sdk_tool_path = os.path.join(sdk_root, "tools/android")
cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java")
command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
if os.system(command) != 0:
raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
if os.system(command) != 0:
raise Exception("update project [ " + app_android_root + " ] fails!")
buildfile_path = os.path.join(app_android_root, "build.xml")
command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
os.system(command)
def copy_files(src, dst):
@ -166,7 +166,7 @@ def copy_resources(target, app_android_root):
assets_src_dir = os.path.join(assets_dir, "src");
os.mkdir(assets_src_dir)
copy_files(resources_dir, assets_src_dir)
resources_dir = os.path.join(app_android_root, "../../../../cocos/scripting/lua-bindings/script")
copy_files(resources_dir, assets_dir)
@ -184,20 +184,20 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
current_dir = os.path.dirname(os.path.realpath(__file__))
cocos_root = os.path.join(current_dir, "..")
if android_platform is not None:
sdk_root = check_environment_variables_sdk()
if android_platform.isdigit():
android_platform = 'android-'+android_platform
else:
print 'please use vaild android platform'
exit(1)
sdk_root = check_environment_variables_sdk()
if android_platform.isdigit():
android_platform = 'android-'+android_platform
else:
print 'please use vaild android platform'
exit(1)
if build_mode is None:
build_mode = 'debug'
build_mode = 'debug'
elif build_mode != 'release':
build_mode = 'debug'
app_android_root = ''
target_proj_path_map = {
@ -214,8 +214,8 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
print 'unknown target: %s' % target
continue
copy_resources(target, app_android_root)
do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode)
copy_resources(target, app_android_root)
do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,android_platform,build_mode)
# -------------- main --------------
if __name__ == '__main__':
@ -223,8 +223,8 @@ if __name__ == '__main__':
#parse the params
usage = """
This script is mainy used for building tests built-in with cocos2d-x.
Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests]
Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests|cpp|lua|all]
If you are new to cocos2d-x, I recommend you start with cpp-empty-test, lua-empty-test.
@ -237,16 +237,17 @@ if __name__ == '__main__':
"""
parser = OptionParser(usage=usage)
parser.add_option("-n", "--ndk", dest="ndk_build_param",
parser.add_option("-n", "--ndk", dest="ndk_build_param",
help='Parameter for ndk-build')
parser.add_option("-p", "--platform", dest="android_platform",
parser.add_option("-p", "--platform", dest="android_platform",
help='Parameter for android-update. Without the parameter,the script just build dynamic library for the projects. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]')
parser.add_option("-b", "--build", dest="build_mode",
parser.add_option("-b", "--build", dest="build_mode",
help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args()
if len(args) == 0:
parser.print_help()
sys.exit(1)
else:
try:
build_samples(args, opts.ndk_build_param,opts.android_platform,opts.build_mode)

View File

@ -46,7 +46,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
int fontSize = config.fontSize;
if (useDistanceField)
{
fontSize = Label::DefultFontSize;
fontSize = Label::DistanceFieldFontSize;
}
std::string atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField);

View File

@ -36,7 +36,7 @@
NS_CC_BEGIN
const int Label::DefultFontSize = 50;
const int Label::DistanceFieldFontSize = 50;
Label* Label::create()
{
@ -208,15 +208,15 @@ bool Label::setCharMap(const std::string& plistFile)
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(plistFile);
if (!newAtlas)
return false;
if (initWithFontAtlas(newAtlas))
{
_currentLabelType = LabelType::CHARMAP;
return true;
reset();
return false;
}
return false;
setFontAtlas(newAtlas);
_currentLabelType = LabelType::CHARMAP;
return true;
}
bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
@ -224,15 +224,15 @@ bool Label::setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int st
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(texture,itemWidth,itemHeight,startCharMap);
if (!newAtlas)
return false;
if (initWithFontAtlas(newAtlas))
{
_currentLabelType = LabelType::CHARMAP;
return true;
reset();
return false;
}
return false;
setFontAtlas(newAtlas);
_currentLabelType = LabelType::CHARMAP;
return true;
}
bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
@ -240,15 +240,15 @@ bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHe
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasCharMap(charMapFile,itemWidth,itemHeight,startCharMap);
if (!newAtlas)
return false;
if (initWithFontAtlas(newAtlas))
{
_currentLabelType = LabelType::CHARMAP;
return true;
reset();
return false;
}
return false;
setFontAtlas(newAtlas);
_currentLabelType = LabelType::CHARMAP;
return true;
}
Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */,
@ -274,17 +274,10 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
, _currNumLines(-1)
, _textSprite(nullptr)
, _contentDirty(false)
, _currentLabelType(LabelType::STRING_TEXTURE)
, _currLabelEffect(LabelEffect::NORMAL)
, _shadowBlurRadius(0)
{
_cascadeColorEnabled = true;
_batchNodes.push_back(this);
_fontDefinition._fontName = "Helvetica";
_fontDefinition._fontSize = 12;
_fontDefinition._alignment = TextHAlignment::LEFT;
_fontDefinition._vertAlignment = TextVAlignment::TOP;
reset();
}
Label::~Label()
@ -301,28 +294,40 @@ Label::~Label()
CC_SAFE_RELEASE_NULL(_reusedLetter);
}
bool Label::init()
{
bool ret = true;
if(_fontAtlas)
{
ret = SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30);
if (_reusedLetter == nullptr)
{
_reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0));
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
_reusedLetter->retain();
_reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT);
_reusedLetter->setBatchNode(this);
}
}
_currLabelEffect = LabelEffect::NORMAL;
initProgram();
void Label::reset()
{
TTFConfig temp;
_fontConfig = temp;
return ret;
_fontDefinition._fontName = "Helvetica";
_fontDefinition._fontSize = 12;
_fontDefinition._alignment = _hAlignment;
_fontDefinition._vertAlignment = _vAlignment;
_fontDirty = false;
_fontName = "Helvetica";
_fontSize = 12;
_batchNodes.clear();
_batchNodes.push_back(this);
if (_fontAtlas)
{
FontAtlasCache::releaseFontAtlas(_fontAtlas);
_fontAtlas = nullptr;
}
_currentLabelType = LabelType::STRING_TEXTURE;
_currLabelEffect = LabelEffect::NORMAL;
_shadowBlurRadius = 0;
Node::removeAllChildrenWithCleanup(true);
_textSprite = nullptr;
CC_SAFE_RELEASE_NULL(_reusedLetter);
}
void Label::initProgram()
void Label::updateShaderProgram()
{
switch (_currLabelEffect)
{
@ -349,32 +354,33 @@ void Label::initProgram()
_uniformEffectColor = glGetUniformLocation(_shaderProgram->getProgram(), "v_effectColor");
}
bool Label::initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */)
void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */)
{
FontAtlas *oldAtlas = _fontAtlas;
bool oldDistanceFieldEnable = _useDistanceField;
bool oldA8ShaderEnabel = _useA8Shader;
if (atlas == _fontAtlas)
{
FontAtlasCache::releaseFontAtlas(atlas);
return;
}
if (_fontAtlas)
{
FontAtlasCache::releaseFontAtlas(_fontAtlas);
_fontAtlas = nullptr;
}
_fontAtlas = atlas;
_useDistanceField = distanceFieldEnabled;
_useA8Shader = useA8Shader;
bool ret = Label::init();
if (oldAtlas)
SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30);
if (_reusedLetter == nullptr)
{
if (ret)
{
FontAtlasCache::releaseFontAtlas(oldAtlas);
}
else
{
_fontAtlas = oldAtlas;
_useDistanceField = oldDistanceFieldEnable;
_useA8Shader = oldA8ShaderEnabel;
Label::init();
FontAtlasCache::releaseFontAtlas(atlas);
}
_reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0));
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
_reusedLetter->retain();
_reusedLetter->setAnchorPoint(Point::ANCHOR_TOP_LEFT);
_reusedLetter->setBatchNode(this);
}
else
{
_reusedLetter->setTexture(_fontAtlas->getTexture(0));
}
if (_fontAtlas)
@ -382,8 +388,10 @@ bool Label::initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = fa
_commonLineHeight = _fontAtlas->getCommonLineHeight();
_contentDirty = true;
}
return ret;
_useDistanceField = distanceFieldEnabled;
_useA8Shader = useA8Shader;
_currLabelEffect = LabelEffect::NORMAL;
updateShaderProgram();
}
bool Label::setTTFConfig(const TTFConfig& ttfConfig)
@ -391,30 +399,30 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasTTF(ttfConfig);
if (!newAtlas)
{
reset();
return false;
}
if (initWithFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true))
setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
_fontConfig = ttfConfig;
if (_fontConfig.outlineSize > 0)
{
_fontConfig = ttfConfig;
if (ttfConfig.outlineSize > 0)
{
_fontConfig.distanceFieldEnabled = false;
_useDistanceField = false;
_useA8Shader = false;
_currLabelEffect = LabelEffect::OUTLINE;
initProgram();
}
else if(ttfConfig.distanceFieldEnabled)
{
this->setFontScale(1.0f * ttfConfig.fontSize / DefultFontSize);
}
_currentLabelType = LabelType::TTF;
return true;
_fontConfig.distanceFieldEnabled = false;
_useDistanceField = false;
_useA8Shader = false;
_currLabelEffect = LabelEffect::OUTLINE;
updateShaderProgram();
}
else
else if(ttfConfig.distanceFieldEnabled)
{
return false;
this->setFontScale(1.0f * ttfConfig.fontSize / DistanceFieldFontSize);
}
_currentLabelType = LabelType::TTF;
return true;
}
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset /* = Point::ZERO */)
@ -422,21 +430,23 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& im
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
if (!newAtlas)
return false;
if (initWithFontAtlas(newAtlas))
{
_currentLabelType = LabelType::BMFONT;
return true;
reset();
return false;
}
return false;
setFontAtlas(newAtlas);
_currentLabelType = LabelType::BMFONT;
return true;
}
void Label::setFontDefinition(const FontDefinition& textDefinition)
{
reset();
_fontDefinition = textDefinition;
_currentLabelType = LabelType::STRING_TEXTURE;
_fontName = textDefinition._fontName;
_fontSize = textDefinition._fontSize;
_contentDirty = true;
}
@ -744,7 +754,7 @@ void Label::enableGlow(const Color3B& glowColor)
return;
_currLabelEffect = LabelEffect::GLOW;
_effectColor = glowColor;
initProgram();
updateShaderProgram();
}
void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = 1 */)
@ -760,7 +770,7 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = 1 */)
auto config = _fontConfig;
config.outlineSize = outlineSize;
setTTFConfig(config);
initProgram();
updateShaderProgram();
}
}
_fontDefinition._stroke._strokeEnabled = true;
@ -797,7 +807,7 @@ void Label::disableEffect()
setTTFConfig(_fontConfig);
}
_currLabelEffect = LabelEffect::NORMAL;
initProgram();
updateShaderProgram();
_contentDirty = true;
}
@ -940,12 +950,30 @@ void Label::updateContent()
_contentDirty = false;
}
void Label::updateFont()
{
if (_fontName.find('.') != _fontName.npos)
{
_fontConfig.fontFilePath = _fontName;
_fontConfig.fontSize = _fontSize;
setTTFConfig(_fontConfig);
}
_fontDefinition._fontName = _fontName;
_fontDefinition._fontSize = _fontSize;
_contentDirty = true;
_fontDirty = false;
}
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
if (! _visible || _originalUTF8String.empty())
{
return;
}
if (_fontDirty)
{
updateFont();
}
if (_contentDirty)
{
updateContent();
@ -987,19 +1015,10 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
void Label::setFontName(const std::string& fontName)
{
if (fontName.find('.') != fontName.npos)
if (fontName != _fontName)
{
auto config = _fontConfig;
config.fontFilePath = fontName;
if (setTTFConfig(config))
{
return;
}
}
if (_fontDefinition._fontName != fontName)
{
_fontDefinition._fontName = fontName;
_contentDirty = true;
_fontName = fontName;
_fontDirty = true;
}
}
@ -1016,29 +1035,10 @@ const std::string& Label::getFontName() const
void Label::setFontSize(int fontSize)
{
if (_currentLabelType == LabelType::TTF)
if (_fontSize != fontSize)
{
if (_fontConfig.fontSize == fontSize)
{
return;
}
if (_fontConfig.distanceFieldEnabled)
{
_fontConfig.fontSize = fontSize;
this->setFontScale(1.0f * fontSize / DefultFontSize);
}
else
{
auto fontConfig = _fontConfig;
fontConfig.fontSize = fontSize;
setTTFConfig(fontConfig);
}
}
else if(_fontDefinition._fontSize != fontSize)
{
_fontDefinition._fontSize = fontSize;
_fontConfig.fontSize = fontSize;
_contentDirty = true;
_fontSize = fontSize;
_fontDirty = true;
}
}
@ -1204,6 +1204,10 @@ std::string Label::getDescription() const
const Size& Label::getContentSize() const
{
if (_fontDirty)
{
const_cast<Label*>(this)->updateFont();
}
if (_contentDirty)
{
const_cast<Label*>(this)->updateContent();

View File

@ -59,7 +59,7 @@ typedef struct _ttfConfig
bool distanceFieldEnabled;
int outlineSize;
_ttfConfig(const char* filePath = "",int size = 36, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
_ttfConfig(const char* filePath = "",int size = 12, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
const char *customGlyphCollection = nullptr,bool useDistanceField = false,int outline = 0)
:fontFilePath(filePath)
,fontSize(size)
@ -78,7 +78,7 @@ typedef struct _ttfConfig
class CC_DLL Label : public SpriteBatchNode, public LabelProtocol
{
public:
static const int DefultFontSize;
static const int DistanceFieldFontSize;
static Label* create();
@ -259,14 +259,12 @@ protected:
*/
virtual ~Label();
virtual bool initWithFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false);
virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false);
bool recordLetterInfo(const cocos2d::Point& point,const FontLetterDefinition& letterDef, int spriteIndex);
bool recordPlaceholderInfo(int spriteIndex);
void setFontScale(float fontScale);
virtual bool init();
virtual void alignText();
@ -279,14 +277,20 @@ protected:
virtual void updateColor() override;
virtual void initProgram();
virtual void updateShaderProgram();
void drawShadowWithoutBlur();
void createSpriteWithFontDefinition();
void updateFont();
void reset();
bool _isOpacityModifyRGB;
bool _contentDirty;
bool _fontDirty;
std::string _fontName;
int _fontSize;
LabelType _currentLabelType;
std::vector<SpriteBatchNode*> _batchNodes;

View File

@ -121,13 +121,31 @@ float tweenTo(float time, TweenType type, float *easingParam)
break;
case Elastic_EaseIn:
delta = elasticEaseIn(time, easingParam[0]);
{
float period = 0.3f;
if (nullptr != easingParam) {
period = easingParam[0];
}
delta = elasticEaseIn(time, period);
}
break;
case Elastic_EaseOut:
delta = elasticEaseOut(time, easingParam[0]);
{
float period = 0.3f;
if (nullptr != easingParam) {
period = easingParam[0];
}
delta = elasticEaseOut(time, period);
}
break;
case Elastic_EaseInOut:
delta = elasticEaseInOut(time, easingParam[0]);
{
float period = 0.3f;
if (nullptr != easingParam) {
period = easingParam[0];
}
delta = elasticEaseInOut(time, period);
}
break;

View File

@ -235,7 +235,7 @@ public:
*/
void setMoment(float moment);
/** get the body moment of inertia. */
inline float getMoment(float moment) const { return _moment; }
inline float getMoment() const { return _moment; }
/**
* @brief add moment of inertia to body.
* if _moment(moment of the body) == PHYSICS_INFINITY, it remains.

View File

@ -504,8 +504,8 @@ void PhysicsShapeBox::getPoints(Point* points) const
Size PhysicsShapeBox::getSize() const
{
cpShape* shape = _info->getShapes().front();
return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1)),
cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2))));
return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)),
cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1))));
}
// PhysicsShapePolygon

View File

@ -211,6 +211,11 @@ void PhysicsWorld::debugDraw()
{
PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj);
if (!body->isEnabled())
{
continue;
}
for (auto& shape : body->getShapes())
{
_debugDraw->drawShape(*dynamic_cast<PhysicsShape*>(shape));

View File

@ -43,7 +43,6 @@
--------------------------------
-- @function [parent=#PhysicsBody] getMoment
-- @param self
-- @param #float float
-- @return float#float ret (return value: float)
--------------------------------

View File

@ -0,0 +1,16 @@
--------------------------------
-- @module RichElement
--------------------------------
-- @function [parent=#RichElement] init
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#RichElement] RichElement
-- @param self
return nil

View File

@ -0,0 +1,26 @@
--------------------------------
-- @module RichElementCustomNode
--------------------------------
-- @function [parent=#RichElementCustomNode] init
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #cc.Node node
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#RichElementCustomNode] create
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #cc.Node node
-- @return RichElementCustomNode#RichElementCustomNode ret (return value: ccui.RichElementCustomNode)
--------------------------------
-- @function [parent=#RichElementCustomNode] RichElementCustomNode
-- @param self
return nil

View File

@ -0,0 +1,26 @@
--------------------------------
-- @module RichElementImage
--------------------------------
-- @function [parent=#RichElementImage] init
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #char char
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#RichElementImage] create
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #char char
-- @return RichElementImage#RichElementImage ret (return value: ccui.RichElementImage)
--------------------------------
-- @function [parent=#RichElementImage] RichElementImage
-- @param self
return nil

View File

@ -0,0 +1,30 @@
--------------------------------
-- @module RichElementText
--------------------------------
-- @function [parent=#RichElementText] init
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #char char
-- @param #char char
-- @param #float float
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#RichElementText] create
-- @param self
-- @param #int int
-- @param #color3B_table color3b
-- @param #unsigned char char
-- @param #char char
-- @param #char char
-- @param #float float
-- @return RichElementText#RichElementText ret (return value: ccui.RichElementText)
--------------------------------
-- @function [parent=#RichElementText] RichElementText
-- @param self
return nil

View File

@ -0,0 +1,57 @@
--------------------------------
-- @module RichText
--------------------------------
-- @function [parent=#RichText] insertElement
-- @param self
-- @param #ccui.RichElement richelement
-- @param #int int
--------------------------------
-- @function [parent=#RichText] setAnchorPoint
-- @param self
-- @param #point_table point
--------------------------------
-- @function [parent=#RichText] pushBackElement
-- @param self
-- @param #ccui.RichElement richelement
--------------------------------
-- @function [parent=#RichText] formatText
-- @param self
--------------------------------
-- @function [parent=#RichText] ignoreContentAdaptWithSize
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#RichText] setVerticalSpace
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#RichText] getContentSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- overload function: removeElement(ccui.RichElement)
--
-- overload function: removeElement(int)
--
-- @function [parent=#RichText] removeElement
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#RichText] create
-- @param self
-- @return RichText#RichText ret (return value: ccui.RichText)
--------------------------------
-- @function [parent=#RichText] RichText
-- @param self
return nil

View File

@ -91,4 +91,29 @@
-- @field [parent=#ccui] Helper#Helper Helper preloaded module
--------------------------------------------------------
-- the ccui RichElement
-- @field [parent=#ccui] RichElement#RichElement RichElement preloaded module
--------------------------------------------------------
-- the ccui RichElementText
-- @field [parent=#ccui] RichElementText#RichElementText RichElementText preloaded module
--------------------------------------------------------
-- the ccui RichElementImage
-- @field [parent=#ccui] RichElementImage#RichElementImage RichElementImage preloaded module
--------------------------------------------------------
-- the ccui RichElementCustomNode
-- @field [parent=#ccui] RichElementCustomNode#RichElementCustomNode RichElementCustomNode preloaded module
--------------------------------------------------------
-- the ccui RichText
-- @field [parent=#ccui] RichText#RichText RichText preloaded module
return nil

View File

@ -1 +1 @@
b0dc5acd96b5d7e94c40c01097a6f969719a6110
44ccccc9572e8345c6b9903e8f10abcf0937d1cc

View File

@ -1 +1 @@
337366fa551a6f02e7f44e832e351fad51895ca5
cb29285429f792ed191dc2135b5f80ca5e52e9d1

View File

@ -1 +1 @@
6deb0e9e9ec193559f4eaa0f48310265bc32a491
6830e4b8f10511215bf059042bfd7eca7cc03679

View File

@ -25,7 +25,7 @@ int lua_cocos2dx_spine_Skeleton_setToSetupPose(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setToSetupPose'", nullptr);
return 0;
}
#endif
@ -68,7 +68,7 @@ int lua_cocos2dx_spine_Skeleton_setBlendFunc(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBlendFunc'", nullptr);
return 0;
}
#endif
@ -114,7 +114,7 @@ int lua_cocos2dx_spine_Skeleton_onDraw(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_onDraw'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_onDraw'", nullptr);
return 0;
}
#endif
@ -163,7 +163,7 @@ int lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSlotsToSetupPose'", nullptr);
return 0;
}
#endif
@ -206,7 +206,7 @@ int lua_cocos2dx_spine_Skeleton_getBlendFunc(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_getBlendFunc'", nullptr);
return 0;
}
#endif
@ -250,7 +250,7 @@ int lua_cocos2dx_spine_Skeleton_setSkin(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSkin'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setSkin'", nullptr);
return 0;
}
#endif
@ -297,7 +297,7 @@ int lua_cocos2dx_spine_Skeleton_setBonesToSetupPose(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_Skeleton_setBonesToSetupPose'", nullptr);
return 0;
}
#endif
@ -329,7 +329,7 @@ static int lua_cocos2dx_spine_Skeleton_finalize(lua_State* tolua_S)
int lua_register_cocos2dx_spine_Skeleton(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"sp.Skeleton");
tolua_cclass(tolua_S,"Skeleton","sp.Skeleton","cc.Node",NULL);
tolua_cclass(tolua_S,"Skeleton","sp.Skeleton","cc.Node",nullptr);
tolua_beginmodule(tolua_S,"Skeleton");
tolua_function(tolua_S,"setToSetupPose",lua_cocos2dx_spine_Skeleton_setToSetupPose);
@ -366,7 +366,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_addAnimation(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_addAnimation'", nullptr);
return 0;
}
#endif
@ -439,7 +439,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_getCurrent(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_getCurrent'", nullptr);
return 0;
}
#endif
@ -494,7 +494,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_setMix(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setMix'", nullptr);
return 0;
}
#endif
@ -546,7 +546,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_setAnimation(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_setAnimation'", nullptr);
return 0;
}
#endif
@ -599,7 +599,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTracks(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTracks'", nullptr);
return 0;
}
#endif
@ -642,7 +642,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_clearTrack'", nullptr);
return 0;
}
#endif
@ -695,7 +695,7 @@ int lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(lua_State* tolua_
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", NULL);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", nullptr);
return 0;
}
#endif
@ -739,7 +739,7 @@ static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S)
int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"sp.SkeletonAnimation");
tolua_cclass(tolua_S,"SkeletonAnimation","sp.SkeletonAnimation","sp.Skeleton",NULL);
tolua_cclass(tolua_S,"SkeletonAnimation","sp.SkeletonAnimation","sp.Skeleton",nullptr);
tolua_beginmodule(tolua_S,"SkeletonAnimation");
tolua_function(tolua_S,"addAnimation",lua_cocos2dx_spine_SkeletonAnimation_addAnimation);

View File

@ -1 +1 @@
b1abe1fd74f3d67444e32b3a3a0cad5c86b4269a
0a46232432ba108d165f69ca9435f3ae0e911a27

View File

@ -1 +1 @@
d0b810bd90f5639ba15e03fc5e083b762225a16d
11bba6be0cebc89eb4c7195a61d021e51719468f

View File

@ -328,6 +328,32 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);

View File

@ -68,14 +68,16 @@ static const int CC_EDIT_BOX_PADDING = 5;
bool EditBoxImplAndroid::initWithSize(const Size& size)
{
int fontSize = getFontSizeAccordingHeightJni(size.height-12);
_label = LabelTTF::create("", "", size.height-12);
_label = Label::create();
_label->setFontSize(size.height-12);
// align the text vertically center
_label->setAnchorPoint(Point(0, 0.5f));
_label->setPosition(Point(CC_EDIT_BOX_PADDING, size.height / 2.0f));
_label->setColor(_colText);
_editBox->addChild(_label);
_labelPlaceHolder = LabelTTF::create("", "", size.height-12);
_labelPlaceHolder = Label::create();
_labelPlaceHolder->setFontSize(size.height-12);
// align the text vertically center
_labelPlaceHolder->setAnchorPoint(Point(0, 0.5f));
_labelPlaceHolder->setPosition(Point(CC_EDIT_BOX_PADDING, size.height / 2.0f));
@ -167,7 +169,7 @@ void EditBoxImplAndroid::setText(const char* pText)
long length = cc_utf8_strlen(_text.c_str(), -1);
for (long i = 0; i < length; i++)
{
strToShow.append("\u25CF");
strToShow.append("*");
}
}
else
@ -178,15 +180,12 @@ void EditBoxImplAndroid::setText(const char* pText)
_label->setString(strToShow.c_str());
// Clip the text width to fit to the text box
// FIXME: After re-implement LabelTTF by Label, '(g|s)etTextureRect' will not work, it's because LabelTTF is inherited from Node rather than Sprite now.
// float fMaxWidth = _editSize.width - CC_EDIT_BOX_PADDING * 2;
// Rect clippingRect = _label->getTextureRect();
// if(clippingRect.size.width > fMaxWidth) {
// clippingRect.size.width = fMaxWidth;
// _label->setTextureRect(clippingRect);
// }
float fMaxWidth = _editSize.width - CC_EDIT_BOX_PADDING * 2;
auto labelSize = _label->getContentSize();
if(labelSize.width > fMaxWidth) {
_label->setDimensions(fMaxWidth,labelSize.height);
}
}
else
{

View File

@ -84,8 +84,8 @@ public:
virtual void closeKeyboard();
private:
LabelTTF* _label;
LabelTTF* _labelPlaceHolder;
Label* _label;
Label* _labelPlaceHolder;
EditBox::InputMode _editBoxInputMode;
EditBox::InputFlag _editBoxInputFlag;
EditBox::KeyboardReturnType _keyboardReturnType;

View File

@ -123,8 +123,8 @@ private:
void adjustTextFieldPosition();
void placeInactiveLabels();
LabelTTF* _label;
LabelTTF* _labelPlaceHolder;
Label* _label;
Label* _labelPlaceHolder;
Size _contentSize;
Point _position;
Point _anchorPoint;

View File

@ -327,13 +327,13 @@ void EditBoxImplIOS::initInactiveLabels(const Size& size)
{
const char* pDefaultFontName = [[_systemControl.textField.font fontName] UTF8String];
_label = LabelTTF::create("", "", 0.0f);
_label = Label::create();
_label->setAnchorPoint(Point(0, 0.5f));
_label->setColor(Color3B::WHITE);
_label->setVisible(false);
_editBox->addChild(_label, kLabelZOrder);
_labelPlaceHolder = LabelTTF::create("", "", 0.0f);
_labelPlaceHolder = Label::create();
// align the text vertically center
_labelPlaceHolder->setAnchorPoint(Point(0, 0.5f));
_labelPlaceHolder->setColor(Color3B::GRAY);
@ -362,14 +362,11 @@ void EditBoxImplIOS::setInactiveText(const char* pText)
_label->setString(getText());
// Clip the text width to fit to the text box
// FIXME: After re-implement LabelTTF by Label, '(g|s)etTextureRect' will not work, it's because LabelTTF is inherited from Node rather than Sprite now.
// float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2;
// Rect clippingRect = _label->getTextureRect();
// if(clippingRect.size.width > fMaxWidth)
// {
// clippingRect.size.width = fMaxWidth;
// _label->setTextureRect(clippingRect);
// }
float fMaxWidth = _editBox->getContentSize().width - CC_EDIT_BOX_PADDING * 2;
Size labelSize = _label->getContentSize();
if(labelSize.width > fMaxWidth) {
_label->setDimensions(fMaxWidth,labelSize.height);
}
}
void EditBoxImplIOS::setFont(const char* pFontName, int fontSize)

View File

@ -70,14 +70,16 @@ void EditBoxImplWin::doAnimationWhenKeyboardMove(float duration, float distance)
bool EditBoxImplWin::initWithSize(const Size& size)
{
//! int fontSize = getFontSizeAccordingHeightJni(size.height-12);
_label = LabelTTF::create("", "", size.height-12);
_label = Label::create();
_label->setFontSize(size.height-12);
// align the text vertically center
_label->setAnchorPoint(Point(0, 0.5f));
_label->setPosition(Point(5, size.height / 2.0f));
_label->setColor(_colText);
_editBox->addChild(_label);
_labelPlaceHolder = LabelTTF::create("", "", size.height-12);
_labelPlaceHolder = Label::create();
_labelPlaceHolder->setFontSize(size.height-12);
// align the text vertically center
_labelPlaceHolder->setAnchorPoint(Point(0, 0.5f));
_labelPlaceHolder->setPosition(Point(5, size.height / 2.0f));

View File

@ -84,8 +84,8 @@ public:
virtual void onEnter(void);
private:
LabelTTF* _label;
LabelTTF* _labelPlaceHolder;
Label* _label;
Label* _labelPlaceHolder;
EditBox::InputMode _editBoxInputMode;
EditBox::InputFlag _editBoxInputFlag;
EditBox::KeyboardReturnType _keyboardReturnType;

View File

@ -87,19 +87,6 @@ class SetEnvVar(object):
return file_to_write
def _update_system_variable(self, origin_content, target_content):
is_updated = False
file = open(self.file_used_for_setup, 'a')
for line in fileinput.input(file_to_write, inplace=1):
if line.startswith(origin_content):
line = target_content
if_undated = True
sys.stdout.write(line)
file.close()
return is_updated
def _find_string_in_file(self, string, file_path):
with open(file_path) as f:
for line in f:
@ -118,7 +105,9 @@ class SetEnvVar(object):
0,
_winreg.KEY_SET_VALUE | _winreg.KEY_READ)
_winreg.SetValueEx(env, key, 0, _winreg.REG_SZ, value)
_winreg.FlushKey(env)
_winreg.CloseKey(env)
except Exception:
if env:
_winreg.CloseKey(env)
@ -271,7 +260,10 @@ class SetEnvVar(object):
if not android_sdk_root:
return False
android_path = os.path.join(android_sdk_root, 'tools/android')
if self._isWindows():
android_path = os.path.join(android_sdk_root, 'tools/android.bat')
else:
android_path = os.path.join(android_sdk_root, 'tools/android')
if os.path.isfile(android_path):
return True
else:
@ -281,7 +273,7 @@ class SetEnvVar(object):
ant_path = ''
if self._isWindows():
ant_path = os.path.join(ant_root, 'ant.exe')
ant_path = os.path.join(ant_root, 'ant.bat')
else:
ant_path = os.path.join(ant_root, 'ant')
@ -290,6 +282,35 @@ class SetEnvVar(object):
else:
return False
def set_windows_path(self, cocos_consle_root):
import _winreg
try:
env = None
path = None
env = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
'Environment',
0,
_winreg.KEY_SET_VALUE | _winreg.KEY_READ)
path = _winreg.QueryValueEx(env, 'Path')[0]
path = path + ';' + cocos_consle_root
path.replace('/', '\\')
_winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path)
_winreg.FlushKey(env)
_winreg.CloseKey(env)
except Exception:
if not path:
path = cocos_consle_root.replace('/', '\\')
_winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path)
_winreg.FlushKey(env)
else:
_winreg.SetValueEx(env, 'Path', 0, _winreg.REG_SZ, path)
_winreg.FlushKey(env)
if env:
_winreg.CloseKey(env)
return False
return True
def set_console_root(self):
@ -297,6 +318,8 @@ class SetEnvVar(object):
print '-> Adding COCOS2D_CONSOLE_ROOT environment variable...',
if not self._find_environment_variable(COCOS_CONSOLE_ROOT):
cocos_consle_root = os.path.join(self.current_absolute_path, 'tools/cocos2d-console/bin')
if self._isWindows():
self.set_windows_path(cocos_consle_root)
if self._set_environment_variable(COCOS_CONSOLE_ROOT, cocos_consle_root):
print 'OK'
print ' -> Added: %s = %s' % (COCOS_CONSOLE_ROOT, cocos_consle_root)
@ -410,7 +433,7 @@ class SetEnvVar(object):
print '\nCOCOS_CONSOLE_ROOT was already added. Edit "%s" for manual changes' % target
if self._isWindows():
print '\nPlease restart the terminal to make added system variables take effect'
print '\nPlease restart the terminal or restart computer to make added system variables take effect'
else:
print '\nPlease execute command: "source %s" to make added system variables take effect' % target
@ -418,7 +441,7 @@ if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-n', '--ndkroot', dest='ndk_root', help='directory of ndk root')
parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root')
parser.add_option('-t', '--antroot', dest='ant_root', help='directory of ant root')
parser.add_option('-t', '--antroot', dest='ant_root', help='directory that contains ant/ant.bat')
opts, args = parser.parse_args()
# set environment variables

View File

@ -1 +1 @@
879acef60464ae6a0af99e8e5d809245f8cdbe56
725d085b1800d788b0a8cf1ec615d750573dce15

View File

@ -31,7 +31,7 @@ function AssetManagerModule.newScene(backfunc)
helloLabel:setPosition(cc.p(winSize.width / 2, winSize.height - 40))
layer:addChild(helloLabel, 5)
local sprite = cc.Sprite:create("background.png")
local sprite = cc.Sprite:create("Images/background.png")
sprite:setAnchorPoint(cc.p(0.5, 0.5))
sprite:setPosition(cc.p(winSize.width / 2, winSize.height / 2))
layer:addChild(sprite, 0)

View File

@ -100,7 +100,8 @@ local function updateLayer()
local function enter(sender)
if not isUpdateItemClicked then
addSearchPath(pathToSave,true)
local realPath = pathToSave .. "/package"
addSearchPath(realPath,true)
end
assetsManagerModule = reloadModule("src/AssetsManagerTest/AssetsManagerModule")

@ -1 +1 @@
Subproject commit cd30a5b87d5c9b6fdbd57cdc5a9213bcb975f65b
Subproject commit f2e408f1ce29df573b0ed6bbcc83cf9fd7a795d5

@ -1 +1 @@
Subproject commit f52d834ee7b4f412f7b972ef484a0e406ce6c1fd
Subproject commit 223a7cd9fdf1d399ecb7b97346e2b5dea5f25331

View File

@ -0,0 +1,87 @@
#!/usr/bin/python
#create new project by cocos-console
#build new project and run
import os
import sys
project_types = ['cpp', 'lua']
PROJ_SUFFIX = 'Proj'
phonePlats = ['mac','ios','android']
cocos_console_dir = 'tools/cocos2d-console/bin/'
#now cocos2d-console suport different run on Platforms, e.g: only run android on win
runSupport = {
'darwin' : [1, 1, 1],
'win' : [0, 0, 1],
'linux' : [0, 0, 1]
}
_argvs = sys.argv
print 'input argvs:', _argvs[1], _argvs[2]
_will_create = False
_will_run = False
if _argvs[1]=='create' || _argvs[2]=='create':
_will_create = True
if _argvs[1]=='run' || _argvs[2]=='run':
_will_create = True
_will_run = True
if _will_create == False and _will_run == False:
_will_create = True
_will_run = True
curPlat = sys.platform
if curPlat.find('linux') >= 0:
curPlat = 'linux'
elif curPlat.find('darwin') >= 0:
curPlat = 'darwin'
else:
curPlat = 'win'
print 'current platform is:', curPlat
def clean_project():
for proj in project_types:
cmd = 'rm -rf '+proj+PROJ_SUFFIX
os.system(cmd)
def create_project():
print 'will create_project: '
idx = 0
for proj in project_types:
print 'proj: ', proj
cmd = 'cocos new -l '+proj+' '+proj+PROJ_SUFFIX
print proj,'cmd:',cmd
idx += 1
info_create = os.system(cmd) #call cmd on win is diff
print 'create project',proj,' is:', not info_create
def build_run():
print 'will build and run'
for proj in project_types:
idx = 0
for phone in phonePlats:
cmd = 'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX
print proj,'cmd:',cmd
if runSupport[curPlat][idx]:
info_run = os.system(cmd)
print 'run project', proj, 'is:', not info_run
idx += 1
def main():
if _will_create:
clean_project()
create_project()
if _will_run:
build_run()
# -------------- main --------------
if __name__ == '__main__':
sys_ret = 0
try:
sys_ret = main()
except:
traceback.print_exc()
sys_ret = 1
finally:
sys.exit(sys_ret)

View File

@ -0,0 +1,58 @@
import jenkinsapi
from jenkinsapi.jenkins import Jenkins
import sys
import time
import os
#check & kill dead buid
def build_time(_job):
#get jenkins-job-watchdog-threshold
threshold = os.environ['jenkins-job-watchdog-threshold']
#Get last build running
build = _job.get_last_build()
running = build.is_running()
print 'build_job:',_job,'running:',running
if not running:
return False
#Get numerical ID of the last build.
buildnu = _job.get_last_buildnumber()
print "buildnumber:#",buildnu
#get nowtime
nowtime = time.strftime('%M',time.localtime(time.time()))
#print 'nowtime:',nowtime
#get build start time
timeb = build.get_timestamp()
#print 'buildtime:',str(timeb)[14:16]
buildtime = int(str(timeb)[14:16])
subtime = 0
if int(nowtime) >= buildtime:
subtime = int(nowtime)-buildtime
else:
subtime = 60-buildtime+int(nowtime)
if subtime > threshold:
#print 'subtime',subtime
#kill dead buid
build.stop()
def main():
username = os.environ['username']
password = os.environ['password']
J = Jenkins('http://115.28.134.83:8000',username,password)
#get all jenkins jobs
for key,job in J.iteritems():
build_time(job)
return(0)
# -------------- main --------------
if __name__ == '__main__':
sys_ret = 0
try:
sys_ret = main()
except:
traceback.print_exc()
sys_ret = 1
finally:
sys.exit(sys_ret)

View File

@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter
classes = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter Rich.*
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also