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

This commit is contained in:
zhangbin 2014-03-20 15:29:12 +08:00
commit 74cb49661a
57 changed files with 294 additions and 597 deletions

View File

@ -1 +1 @@
474442e74e1b39c748e79eceb26039d513d9a715
3840d977454e06d4afa20ec009eee081f988ee03

View File

@ -1 +1 @@
b8986c04c89d3861f82fb99b0df633ac2cc4a13c
044fbe06a7419f54a1da5bd5e597fe75024b6b88

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1 +1 @@
2c5a07d179e9514618036dfb7cfedd3f9cf4c506
59cab787aa72667424fc666730a33ab58d8e42cb

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -44,7 +44,6 @@ public:
virtual int* getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const = 0;
virtual const char* getCurrentGlyphCollection() const;
virtual unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const { return 0; }
virtual int getFontMaxHeight() const { return 0; }

View File

@ -221,8 +221,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
int length = cc_wcslen(utf16String);
float offsetAdjust = _letterPadding / 2;
int bitmapWidth;
int bitmapHeight;
long bitmapWidth;
long bitmapHeight;
Rect tempRect;
FontLetterDefinition tempDef;

View File

@ -28,6 +28,7 @@
#include <unordered_map>
#include "CCPlatformMacros.h"
#include "CCRef.h"
#include "CCStdC.h"
NS_CC_BEGIN
@ -72,7 +73,7 @@ public:
bool prepareLetterDefinitions(unsigned short *utf16String);
inline const std::unordered_map<int, Texture2D*>& getTextures() const{ return _atlasTextures;}
inline const std::unordered_map<ssize_t, Texture2D*>& getTextures() const{ return _atlasTextures;}
void addTexture(Texture2D *texture, int slot);
float getCommonLineHeight() const;
void setCommonLineHeight(float newHeight);
@ -98,7 +99,7 @@ public:
private:
void relaseTextures();
std::unordered_map<int, Texture2D*> _atlasTextures;
std::unordered_map<ssize_t, Texture2D*> _atlasTextures;
std::unordered_map<unsigned short, FontLetterDefinition> _fontLetterDefinitions;
float _commonLineHeight;
Font * _font;

View File

@ -219,7 +219,7 @@ int FontFreeType::getFontAscender() const
return (static_cast<int>(_fontRef->size->metrics.ascender >> 6));
}
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight, Rect &outRect,int &xAdvance)
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance)
{
bool invalidChar = true;
unsigned char * ret = nullptr;
@ -260,8 +260,8 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidt
auto copyBitmap = new unsigned char[outWidth * outHeight];
memcpy(copyBitmap,ret,outWidth * outHeight * sizeof(unsigned char));
int bitmapWidth;
int bitmapHeight;
long bitmapWidth;
long bitmapHeight;
FT_BBox bbox;
auto outlineBitmap = getGlyphBitmapWithOutline(theChar,bbox);
if(outlineBitmap == nullptr)
@ -274,7 +274,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidt
bitmapWidth = (bbox.xMax - bbox.xMin)>>6;
bitmapHeight = (bbox.yMax - bbox.yMin)>>6;
int index;
long index;
auto blendImage = new unsigned char[bitmapWidth * bitmapHeight * 2];
memset(blendImage, 0, bitmapWidth * bitmapHeight * 2);
for (int x = 0; x < bitmapWidth; ++x)
@ -286,8 +286,8 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidt
}
}
int maxX = outWidth + _outlineSize;
int maxY = outHeight + _outlineSize;
long maxX = outWidth + _outlineSize;
long maxY = outHeight + _outlineSize;
for (int x = _outlineSize; x < maxX; ++x)
{
for (int y = _outlineSize; y < maxY; ++y)
@ -347,15 +347,15 @@ unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar,
{
FT_Outline *outline = &reinterpret_cast<FT_OutlineGlyph>(glyph)->outline;
FT_Glyph_Get_CBox(glyph,FT_GLYPH_BBOX_GRIDFIT,&bbox);
int width = (bbox.xMax - bbox.xMin)>>6;
int rows = (bbox.yMax - bbox.yMin)>>6;
long width = (bbox.xMax - bbox.xMin)>>6;
long rows = (bbox.yMax - bbox.yMin)>>6;
FT_Bitmap bmp;
bmp.buffer = new unsigned char[width * rows];
memset(bmp.buffer, 0, width * rows);
bmp.width = width;
bmp.rows = rows;
bmp.pitch = width;
bmp.width = (int)width;
bmp.rows = (int)rows;
bmp.pitch = (int)width;
bmp.pixel_mode = FT_PIXEL_MODE_GRAY;
bmp.num_grays = 256;
@ -377,9 +377,9 @@ unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar,
return ret;
}
unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigned int height)
unsigned char * makeDistanceMap( unsigned char *img, long width, long height)
{
unsigned int pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread);
long pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread);
short * xdist = (short *) malloc( pixelAmount * sizeof(short) );
short * ydist = (short *) malloc( pixelAmount * sizeof(short) );
@ -391,7 +391,7 @@ unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigne
unsigned int i,j;
// Convert img into double (data) rescale image levels between 0 and 1
unsigned int outWidth = width + 2 * FontFreeType::DistanceMapSpread;
long outWidth = width + 2 * FontFreeType::DistanceMapSpread;
for (i = 0; i < width; ++i)
{
for (j = 0; j < height; ++j)
@ -404,8 +404,8 @@ unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigne
height += 2 * FontFreeType::DistanceMapSpread;
// Transform background (outside contour, in areas of 0's)
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, width, height, xdist, ydist, outside);
computegradient( data, (int)width, (int)height, gx, gy);
edtaa3(data, gx, gy, (int)width, (int)height, xdist, ydist, outside);
for( i=0; i< pixelAmount; i++)
if( outside[i] < 0.0 )
outside[i] = 0.0;
@ -413,8 +413,8 @@ unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigne
// Transform foreground (inside contour, in areas of 1's)
for( i=0; i< pixelAmount; i++)
data[i] = 1 - data[i];
computegradient( data, width, height, gx, gy);
edtaa3(data, gx, gy, width, height, xdist, ydist, inside);
computegradient( data, (int)width, (int)height, gx, gy);
edtaa3(data, gx, gy, (int)width, (int)height, xdist, ydist, inside);
for( i=0; i< pixelAmount; i++)
if( inside[i] < 0.0 )
inside[i] = 0.0;
@ -458,7 +458,7 @@ unsigned char * makeDistanceMap( unsigned char *img, unsigned int width, unsigne
return out;
}
void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,int bitmapWidth,int bitmapHeight)
void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight)
{
int iX = posX;
int iY = posY;
@ -470,9 +470,9 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
bitmapWidth += 2 * DistanceMapSpread;
bitmapHeight += 2 * DistanceMapSpread;
for (int y = 0; y < bitmapHeight; ++y)
for (long y = 0; y < bitmapHeight; ++y)
{
int bitmap_y = y * bitmapWidth;
long bitmap_y = y * bitmapWidth;
for (int x = 0; x < bitmapWidth; ++x)
{
@ -497,9 +497,9 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
else if(_outlineSize > 0)
{
unsigned char tempChar;
for (int y = 0; y < bitmapHeight; ++y)
for (long y = 0; y < bitmapHeight; ++y)
{
int bitmap_y = y * bitmapWidth;
long bitmap_y = y * bitmapWidth;
for (int x = 0; x < bitmapWidth; ++x)
{
@ -518,9 +518,9 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
}
else
{
for (int y = 0; y < bitmapHeight; ++y)
for (long y = 0; y < bitmapHeight; ++y)
{
int bitmap_y = y * bitmapWidth;
long bitmap_y = y * bitmapWidth;
for (int x = 0; x < bitmapWidth; ++x)
{

View File

@ -48,12 +48,12 @@ public:
bool isDistanceFieldEnabled() const { return _distanceFieldEnabled;}
int getOutlineSize() const { return _outlineSize; }
void renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,int bitmapWidth,int bitmapHeight);
void renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight);
virtual FontAtlas * createFontAtlas() override;
virtual int * getHorizontalKerningForTextUTF16(unsigned short *text, int &outNumLetters) const override;
unsigned char * getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight, Rect &outRect,int &xAdvance);
unsigned char * getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance);
virtual int getFontMaxHeight() const override;
virtual int getFontAscender() const;

View File

@ -103,7 +103,7 @@ protected:
* @js NA
* @lua NA
*/
virtual void insertText(const char * text, int len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);}
virtual void insertText(const char * text, size_t len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);}
/**
@brief Called by IMEDispatcher after the user clicks the backward key.

View File

@ -214,7 +214,7 @@ void IMEDispatcher::removeDelegate(IMEDelegate* delegate)
// dispatch text message
//////////////////////////////////////////////////////////////////////////
void IMEDispatcher::dispatchInsertText(const char * text, int len)
void IMEDispatcher::dispatchInsertText(const char * text, size_t len)
{
do
{

View File

@ -64,7 +64,7 @@ public:
* @js NA
* @lua NA
*/
void dispatchInsertText(const char * text, int len);
void dispatchInsertText(const char * text, size_t len);
/**
@brief Dispatches the delete-backward operation.

View File

@ -711,7 +711,7 @@ void Label::updateQuads()
_reusedLetter->setTextureRect(_reusedRect,false,_reusedRect.size);
_reusedLetter->setPosition(_lettersInfo[ctr].position);
index = _batchNodes[letterDef.textureID]->getTextureAtlas()->getTotalQuads();
index = static_cast<int>(_batchNodes[letterDef.textureID]->getTextureAtlas()->getTotalQuads());
_lettersInfo[ctr].atlasIndex = index;
_batchNodes[letterDef.textureID]->insertQuadFromSprite(_reusedLetter,index);
}
@ -1054,7 +1054,7 @@ const std::string& Label::getFontName() const
return _fontName;
}
void Label::setFontSize(int fontSize)
void Label::setFontSize(float fontSize)
{
if (_fontSize != fontSize)
{
@ -1063,7 +1063,7 @@ void Label::setFontSize(int fontSize)
}
}
int Label::getFontSize() const
float Label::getFontSize() const
{
return _fontSize;
}
@ -1141,7 +1141,7 @@ void Label::computeStringNumLines()
int Label::getStringLength() const
{
return _currentUTF16String ? cc_wcslen(_currentUTF16String) : _originalUTF8String.length();
return _currentUTF16String ? cc_wcslen(_currentUTF16String) : (int)_originalUTF8String.length();
}
// RGBA protocol

View File

@ -200,8 +200,8 @@ public:
virtual void setFontName(const std::string& fontName);
virtual const std::string& getFontName() const;
virtual void setFontSize(int fontSize);
virtual int getFontSize() const;
virtual void setFontSize(float fontSize);
virtual float getFontSize() const;
virtual bool isOpacityModifyRGB() const override;
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
@ -303,7 +303,7 @@ protected:
bool _contentDirty;
bool _fontDirty;
std::string _fontName;
int _fontSize;
float _fontSize;
LabelType _currentLabelType;
std::vector<SpriteBatchNode*> _batchNodes;

View File

@ -120,7 +120,7 @@ const std::string& LabelTTF::getString() const
std::string LabelTTF::getDescription() const
{
return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %.1f, Label = '%s'>", _renderLabel->getFontName().c_str(), _renderLabel->getFontSize(), _renderLabel->getString().c_str());
return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %f, Label = '%s'>", _renderLabel->getFontName().c_str(), _renderLabel->getFontSize(), _renderLabel->getString().c_str());
}
TextHAlignment LabelTTF::getHorizontalAlignment() const

View File

@ -160,7 +160,7 @@ bool TextFieldTTF::canDetachWithIME()
return (_delegate) ? (! _delegate->onTextFieldDetachWithIME(this)) : true;
}
void TextFieldTTF::insertText(const char * text, int len)
void TextFieldTTF::insertText(const char * text, size_t len)
{
std::string insert(text, len);

View File

@ -64,7 +64,7 @@ public:
/**
@brief If the sender doesn't want to insert the text, return true;
*/
virtual bool onTextFieldInsertText(TextFieldTTF * sender, const char * text, int nLen)
virtual bool onTextFieldInsertText(TextFieldTTF * sender, const char * text, size_t nLen)
{
CC_UNUSED_PARAM(sender);
CC_UNUSED_PARAM(text);
@ -181,7 +181,7 @@ protected:
virtual bool canAttachWithIME() override;
virtual bool canDetachWithIME() override;
virtual void insertText(const char * text, int len) override;
virtual void insertText(const char * text, size_t len) override;
virtual void deleteBackward() override;
virtual const std::string& getContentText() override;
private:

View File

@ -34,7 +34,7 @@ static id s_sharedDirectorCaller;
@interface NSObject(CADisplayLink)
+(id) displayLinkWithTarget: (id)arg1 selector:(SEL)arg2;
-(void) addToRunLoop: (id)arg1 forMode: (id)arg2;
-(void) setFrameInterval: (int)interval;
-(void) setFrameInterval: (NSInteger)interval;
-(void) invalidate;
@end

View File

@ -1,82 +0,0 @@
/****************************************************************************
Copyright (c) 2008 Otto Chrons at Seastringo Oy.
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#import <TargetConditionals.h>
// when compiling to ARM (iPhone device), hide everything and use system defaults
// if you wish to use simulation mode even on the device, remove the #if/#endif
#if !TARGET_CPU_ARM
#import <UIKit/UIKit.h>
// this is exactly the same as UIAcceleration, but we can modify the member variables
@interface UIAccelerationSimulation: NSObject
{
NSTimeInterval timestamp;
UIAccelerationValue x, y, z;
}
@property(nonatomic, readonly) NSTimeInterval timestamp;
@property(nonatomic, readonly) UIAccelerationValue x, y, z;
@end
// override UIAccelerometer behavior
@interface UIAccelerometer (Simulation)
+ (UIAccelerometer *)sharedAccelerometer;
@end
// our own version of the Accelerometer
@interface CCAccelerometerSimulation : UIAccelerometer <NSMachPortDelegate>
{
//CFSocketRef udpSocket;
int udpSocket;
NSThread *thread;
BOOL isExiting;
id<UIAccelerometerDelegate> accelDelegate;
UIAccelerationSimulation *accObject;
// Threaded notification support
NSMutableArray *notifications;
NSThread *notificationThread;
NSLock *notificationLock;
NSMachPort *notificationPort;
}
@property(nonatomic, assign) id<UIAccelerometerDelegate> delegate;
- (void) setUpThreadingSupport;
- (void) handleMachMessage:(void *) msg;
- (void) processNotification:(NSNotification *) notification;
+ (CCAccelerometerSimulation *)getAccelerometer;
- (CCAccelerometerSimulation *)initialize;
@end
#endif // !TARGET_CPU_ARM
#endif // CC_PLATFORM_IOS

View File

@ -1,270 +0,0 @@
/****************************************************************************
Copyright (c) 2008 Otto Chrons at Seastringo Oy.
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import "AccelerometerSimulation.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
// when compiling to ARM (iPhone device), hide everything and use system defaults
// if you wish to use simulation mode even on the device, remove the #if/#endif
#if !TARGET_CPU_ARM
#import <netdb.h>
#define kAccelerometerSimulationPort 10552
@implementation UIAccelerationSimulation
@synthesize timestamp;
@synthesize x;
@synthesize y;
@synthesize z;
-(UIAccelerationSimulation*)initWithTimestamp:(NSTimeInterval)aTimeStamp
X:(UIAccelerationValue)ax
Y:(UIAccelerationValue)ay
Z:(UIAccelerationValue)az
{
timestamp = aTimeStamp;
x = ax;
y = ay;
z = az;
return self;
}
@end
@implementation UIAccelerometer (Simulation)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
// override the static method and return our simulated version instead
+ (UIAccelerometer *)sharedAccelerometer
{
return [CCAccelerometerSimulation getAccelerometer];
}
#pragma clang diagnostic pop
@end
/*
// callback that never got called with CFSocket UDP...
void mySocketCallBack( CFSocketRef s,
CFSocketCallBackType callbackType,
CFDataRef address,
const void *data,
void *info)
{
AccelerometerSimulation *accSim = (AccelerometerSimulation*)info;
NSLog(@"Data %s received", (char*)data);
}
*/
// singleton
static CCAccelerometerSimulation *sharedAccelerometer = NULL;
@implementation CCAccelerometerSimulation
- (void) dealloc {
if (sharedAccelerometer) {
[sharedAccelerometer release];
sharedAccelerometer = NULL;
}
[super dealloc];
}
// this is straight from developer guide example for multi-threaded notifications
- (void) setUpThreadingSupport {
if ( notifications ) return;
notifications = [[NSMutableArray alloc] init];
notificationLock = [[NSLock alloc] init];
notificationThread = [[NSThread currentThread] retain];
notificationPort = [[NSMachPort alloc] init];
[notificationPort setDelegate:self];
[[NSRunLoop currentRunLoop] addPort:notificationPort
forMode:(NSString *) kCFRunLoopCommonModes];
}
// this is straight from developer guide example
- (void) processNotification:(NSNotification *) notification {
if( [NSThread currentThread] != notificationThread ) {
// Forward the notification to the correct thread, this is the socket thread
NSDate* date = [[NSDate alloc] init];
[notificationLock lock];
[notifications addObject:notification];
[notificationLock unlock];
[notificationPort sendBeforeDate:date
components:nil
from:nil
reserved:0];
[date release];
}
else {
// now we are in the main thread
// Process the notification here;
NSString *data = (NSString*)[notification object];
// parse the data, no error handling!
NSArray *components = [data componentsSeparatedByString:@","];
// create our own acceleration object
[accObject initWithTimestamp:[[components objectAtIndex:1] doubleValue]
X:[[components objectAtIndex:2] doubleValue]
Y:[[components objectAtIndex:3] doubleValue]
Z:[[components objectAtIndex:4] doubleValue]];
[accelDelegate accelerometer:self didAccelerate:(UIAcceleration*)accObject];
}
}
// this is straight from developer guide example
- (void) handleMachMessage:(void *) msg {
[notificationLock lock];
while ( [notifications count] ) {
NSNotification *notification = [[notifications objectAtIndex:0] retain];
[notifications removeObjectAtIndex:0];
[notificationLock unlock];
[self processNotification:notification];
[notification release];
[notificationLock lock];
};
[notificationLock unlock];
}
#ifndef __clang_analyzer__
+ (CCAccelerometerSimulation *)getAccelerometer
{
if( sharedAccelerometer == NULL )
sharedAccelerometer = [[CCAccelerometerSimulation alloc] initialize];
return sharedAccelerometer;
}
#endif
- (void)threadLoop:(id)object
{
char buffer[1024];
// we never exit...
while(1) {
int count = recv( udpSocket, buffer, sizeof(buffer), 0 );
if( count > 0 )
{
// got data, let's pass it on
buffer[count] = 0;
NSString *str = [[NSString alloc] initWithUTF8String:buffer];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ThreadAccelNotification" object:str];
[str release];
}
}
}
// initialize our version of the accelerometer
- (CCAccelerometerSimulation *)initialize
{
accObject = [UIAccelerationSimulation alloc];
isExiting = false;
// couldn't get the CFSocket version to work with UDP and runloop, so used Berkeley sockets and a thread instead
udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
// listen on all interfaces
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
sin.sin_port = htons(kAccelerometerSimulationPort);
bind(udpSocket, (const struct sockaddr*)&sin, sizeof(sin));
// create a separate thread for receiving UDP packets
thread = [[NSThread alloc] initWithTarget:self
selector:@selector(threadLoop:)
object:nil];
[thread start];
// cross-thread communication setup
[self setUpThreadingSupport];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(processNotification:)
name:@"ThreadAccelNotification"
object:nil];
/*
// create and initialize a socket
CFSocketContext ctx;
ctx.info = self;
ctx.version = 0;
ctx.retain = NULL;
ctx.release = NULL;
ctx.copyDescription = NULL;
udpSocket = CFSocketCreate(NULL, PF_INET, SOCK_DGRAM, IPPROTO_UDP, kCFSocketDataCallBack | 0xF, mySocketCallBack, NULL);
CFRunLoopSourceRef source;
CFDataRef addr;
CFSocketError theErr;
struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
sin.sin_port = htons(10552);
addr = CFDataCreate(NULL, (unsigned char *)&sin, sizeof(sin));
theErr = CFSocketConnectToAddress(udpSocket, addr, 0);
switch (theErr) {
case kCFSocketSuccess:
NSLog(@"UDP Logged in");
source = CFSocketCreateRunLoopSource(NULL, udpSocket, 0);
CFRunLoopAddSource(CFRunLoopGetMain(), source,
kCFRunLoopDefaultMode);
break;
case kCFSocketError:
NSLog(@"UDP Error");
break;
default:
NSLog(@"UDP Networking Error");
break;
}
*/
return self;
}
// we grab the delegate setting action
- (void)setDelegate:(id<UIAccelerometerDelegate>)delegate
{
accelDelegate = delegate;
}
- (id<UIAccelerometerDelegate>)delegate
{
return accelDelegate;
}
@end
#endif // !TARGET_CPU_ARM
#endif // CC_PLATFORM_IOS

View File

@ -58,7 +58,7 @@
#include "CCConfiguration.h"
#include "CCTextureCache.h"
#include "CCGLView.h"
#include "base64.h"
NS_CC_BEGIN
//TODO: these general utils should be in a seperate class
@ -252,8 +252,6 @@ Console::Console()
, _running(false)
, _endThread(false)
, _sendDebugStrings(false)
,_fileUploading(false)
,_uploadFileSize(0)
{
// VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'.
Command commands[] = {
@ -284,13 +282,13 @@ Console::Console()
{ "texture", "Flush or print the TextureCache info. Args: [flush | ] ", std::bind(&Console::commandTextures, this, std::placeholders::_1, std::placeholders::_2) },
{ "director", "director commands, type -h or [director help] to list supported directives", std::bind(&Console::commandDirector, this, std::placeholders::_1, std::placeholders::_2) },
{ "touch", "simulate touch event via console, type -h or [touch help] to list supported directives", std::bind(&Console::commandTouch, this, std::placeholders::_1, std::placeholders::_2) },
{ "upload", "upload file. Args: [filename filesize]", std::bind(&Console::commandUpload, this, std::placeholders::_1, std::placeholders::_2) },
{ "upload", "upload file. Args: [filename base64_encoded_data]", std::bind(&Console::commandUpload, this, std::placeholders::_1) },
};
;
for (int i = 0; i < sizeof(commands)/sizeof(commands[0]); ++i)
{
_commands.insert ( std::pair<std::string,Command>(commands[i].name,commands[i]) );
_commands[commands[i].name] = commands[i];
}
_writablePath = FileUtils::getInstance()->getWritablePath();
}
@ -300,10 +298,9 @@ Console::~Console()
stop();
}
bool Console::listenOnTCP(int port)
{
int listenfd, n;
int listenfd = -1, n;
const int on = 1;
struct addrinfo hints, *res, *ressave;
char serv[30];
@ -370,7 +367,6 @@ bool Console::listenOnTCP(int port)
freeaddrinfo(ressave);
return listenOnFileDescriptor(listenfd);
}
@ -642,7 +638,7 @@ void Console::commandTouch(int fd, const std::string& args)
float x = std::atof(argv[1].c_str());
float y = std::atof(argv[2].c_str());
srand (time(NULL));
srand ((unsigned)time(NULL));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();
sched->performFunctionInCocosThread( [&](){
@ -670,7 +666,7 @@ void Console::commandTouch(int fd, const std::string& args)
float x2 = std::atof(argv[3].c_str());
float y2 = std::atof(argv[4].c_str());
srand (time(NULL));
srand ((unsigned)time(NULL));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();
@ -757,33 +753,139 @@ void Console::commandTouch(int fd, const std::string& args)
}
}
void Console::commandUpload(int fd, const std::string& args)
void Console::commandUpload(int fd)
{
auto argv = split(args,' ');
if(argv.size() == 2)
ssize_t n, rc;
char buf[512], c;
char *ptr = buf;
//read file name
for( n = 0; n < sizeof(buf) - 1; n++ )
{
_uploadFileName = argv[0];
_uploadFileSize = std::atoi(argv[1].c_str());
_fileUploading = true;
}
else
{
const char msg[] = "upload: invalid arguments.\n";
send(fd, msg, sizeof(msg) - 1, 0);
if( (rc = recv(fd, &c, 1, 0)) ==1 )
{
*ptr++ = c;
if(c == ' ')
{
break;
}
}
else if( rc == 0 )
{
break;
}
else if( errno == EINTR )
{
continue;
}
else
{
break;
}
}
*ptr = 0;
std::string filepath = _writablePath + std::string(buf);
FILE* fp = fopen(filepath.c_str(), "wb");
if(!fp)
{
const char err[] = "can't create file!\n";
send(fd, err, sizeof(err),0);
return;
}
while (true)
{
char data[4];
for(int i = 0; i < 4; i++)
{
data[i] = '=';
}
bool more_data;
readBytes(fd, data, 4, &more_data);
if(!more_data)
{
break;
}
unsigned char *decode;
unsigned char *in = (unsigned char *)data;
int dt = base64Decode(in, 4, &decode);
for(int i = 0; i < dt; i++)
{
fwrite(decode+i, 1, 1, fp);
}
free(decode);
}
fclose(fp);
}
ssize_t Console::readBytes(int fd, char* buffer, size_t maxlen, bool* more)
{
ssize_t n, rc;
char c, *ptr = buffer;
*more = false;
for( n = 0; n < maxlen; n++ ) {
if( (rc = recv(fd, &c, 1, 0)) ==1 ) {
*ptr++ = c;
if(c == '\n') {
return n;
}
} else if( rc == 0 ) {
return 0;
} else if( errno == EINTR ) {
continue;
} else {
return -1;
}
}
*more = true;
return n;
}
bool Console::parseCommand(int fd)
{
char buf[512];
auto r = readline(fd, buf, sizeof(buf)-1);
if(r < 1)
bool more_data;
auto h = readBytes(fd, buf, 6, &more_data);
if( h < 0)
{
const char err[] = "Unknown error!\n";
sendPrompt(fd);
send(fd, err, sizeof(err),0);
return false;
}
if(strncmp(buf, "upload", 6) == 0)
{
char c = '\0';
recv(fd, &c, 1, 0);
if(c == ' ')
{
commandUpload(fd);
sendPrompt(fd);
return true;
}
else
{
const char err[] = "Unknown Command!\n";
sendPrompt(fd);
send(fd, err, sizeof(err),0);
return false;
}
}
if(!more_data)
{
buf[h] = 0;
}
else
{
char *pb = buf + 6;
auto r = readline(fd, pb, sizeof(buf)-6);
if(r < 0)
{
const char err[] = "Unknown error!\n";
sendPrompt(fd);
send(fd, err, sizeof(err),0);
return false;
}
}
std::string cmdLine;
std::vector<std::string> args;
@ -827,12 +929,12 @@ bool Console::parseCommand(int fd)
//
ssize_t Console::readline(int fd, char* ptr, int maxlen)
ssize_t Console::readline(int fd, char* ptr, size_t maxlen)
{
ssize_t n, rc;
char c;
for( n=1; n<maxlen-1; n++ ) {
for( n = 0; n < maxlen - 1; n++ ) {
if( (rc = recv(fd, &c, 1, 0)) ==1 ) {
*ptr++ = c;
if(c == '\n') {
@ -851,44 +953,6 @@ ssize_t Console::readline(int fd, char* ptr, int maxlen)
return n;
}
ssize_t Console::readfile(int fd, std::string& file_name, int file_size)
{
ssize_t n, rc;
char c;
std::string fileName = _writablePath+file_name;
FILE* fp = fopen(fileName.c_str(), "wb");
if(!fp)
{
const char err[] = "can't create file!\n";
send(fd, err, sizeof(err),0);
return 0;
}
// if (fp)
// {
// size_t ret = fwrite(szBuf, 1, strl6en(szBuf), fp);
// CCASSERT(ret != 0, "fwrite function returned zero value");
// fclose(fp);
// if (ret != 0)
// log("Writing file to writable path succeed.");
// }
for( n=0; n<file_size; n++ ) {
if( (rc = recv(fd, &c, 1, 0)) ==1 ) {
fwrite(&c, 1, 1, fp);
} else if( rc == 0 ) {
return 0;
} else if( errno == EINTR ) {
continue;
} else {
return -1;
}
}
fclose(fp);
return n;
}
void Console::addClient()
{
@ -921,7 +985,6 @@ void Console::log(const char* buf)
//
// Main Loop
//
void Console::loop()
{
fd_set copy_set;
@ -970,18 +1033,9 @@ void Console::loop()
for(const auto &fd: _fds) {
if(FD_ISSET(fd,&copy_set))
{
if(!_fileUploading)
if( ! parseCommand(fd) )
{
if( ! parseCommand(fd) )
{
to_remove.push_back(fd);
}
}
else
{
readfile(fd, _uploadFileName, _uploadFileSize);
_fileUploading = false;
to_remove.push_back(fd);
}
if(--nready <= 0)
break;

View File

@ -72,8 +72,8 @@ class CC_DLL Console
{
public:
struct Command {
const char *name;
const char *help;
const char* name;
const char* help;
std::function<void(int, const std::string&)> callback;
};
@ -99,8 +99,8 @@ public:
protected:
void loop();
ssize_t readline(int fd, char *buf, int maxlen);
ssize_t readfile(int fd, std::string &file_name, int file_size);
ssize_t readline(int fd, char *buf, size_t maxlen);
ssize_t readBytes(int fd, char* buffer, size_t maxlen, bool* more);
bool parseCommand(int fd);
void addClient();
@ -116,7 +116,7 @@ protected:
void commandProjection(int fd, const std::string &args);
void commandDirector(int fd, const std::string &args);
void commandTouch(int fd, const std::string &args);
void commandUpload(int fd, const std::string &args);
void commandUpload(int fd);
// file descriptor: socket, console, etc.
int _listenfd;
int _maxfd;
@ -128,9 +128,6 @@ protected:
bool _running;
bool _endThread;
bool _fileUploading;
ssize_t _uploadFileSize;
std::string _uploadFileName;
std::string _writablePath;
std::map<std::string, Command> _commands;

View File

@ -84,7 +84,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
bool bFound = false;
CCARRAY_FOREACH(extraPropsNames, pObj)
{
String* pStr = static_cast<String*>(pObj);
__String* pStr = static_cast<__String*>(pObj);
if (0 == pStr->compare(propertyName.c_str()))
{
bFound = true;
@ -96,7 +96,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
}
else if (isExtraProp && pNode == ccbReader->getAnimationManager()->getRootNode())
{
Array *extraPropsNames = static_cast<Array*>(pNode->getUserObject());
__Array *extraPropsNames = static_cast<__Array*>(pNode->getUserObject());
if (! extraPropsNames)
{
extraPropsNames = Array::create();

View File

@ -16,7 +16,7 @@
--------------------------------
-- @function [parent=#Label] getFontSize
-- @param self
-- @return int#int ret (return value: int)
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Label] getString
@ -137,7 +137,7 @@
--------------------------------
-- @function [parent=#Label] setFontSize
-- @param self
-- @param #int int
-- @param #float float
--------------------------------
-- @function [parent=#Label] getVerticalAlignment

View File

@ -1 +1 @@
ca34b88b0a2dc46e6f7951878c24ade1f929e502
863b8b6206bcb9c764421840a321a2b6f04ac48c

View File

@ -708,7 +708,7 @@
1551A336158F2AB200E66CFE /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0510;
ORGANIZATIONNAME = "";
};
buildConfigurationList = 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2d_lua_bindings" */;
@ -851,7 +851,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_BOOL_CONVERSION = YES;
@ -889,7 +888,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_BOOL_CONVERSION = YES;
@ -923,7 +921,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
GCC_PREPROCESSOR_DEFINITIONS = (
@ -948,7 +945,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
GCC_PREPROCESSOR_DEFINITIONS = (
@ -973,7 +969,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
GCC_PREPROCESSOR_DEFINITIONS = (
@ -993,7 +988,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "";
GCC_PREPROCESSOR_DEFINITIONS = (

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -184,7 +184,7 @@ void RichText::formatText()
if (_ignoreSize)
{
addNewLine();
for (int i=0; i<_richElements.size(); i++)
for (ssize_t i=0; i<_richElements.size(); i++)
{
RichElement* element = _richElements.at(i);
Node* elementRenderer = NULL;
@ -219,7 +219,7 @@ void RichText::formatText()
else
{
addNewLine();
for (int i=0; i<_richElements.size(); i++)
for (ssize_t i=0; i<_richElements.size(); i++)
{
RichElement* element = static_cast<RichElement*>(_richElements.at(i));
@ -262,7 +262,7 @@ void RichText::handleTextRenderer(const char *text, const char *fontName, float
{
float overstepPercent = (-_leftSpaceWidth) / textRendererWidth;
std::string curText = text;
int stringLength = curText.length();
size_t stringLength = curText.length();
int leftLength = stringLength * (1.0f - overstepPercent);
std::string leftWords = curText.substr(0, leftLength);
std::string cutWords = curText.substr(leftLength, curText.length()-1);
@ -322,12 +322,12 @@ void RichText::formarRenderers()
Vector<Node*>* row = (_elementRenders[0]);
float nextPosX = 0.0f;
for (int j=0; j<row->size(); j++)
for (ssize_t j=0; j<row->size(); j++)
{
Node* l = row->at(j);
l->setAnchorPoint(Point::ZERO);
l->setPosition(Point(nextPosX, 0.0f));
_elementRenderersContainer->addChild(l, 1, j);
_elementRenderersContainer->addChild(l, 1, (int)j);
Size iSize = l->getContentSize();
newContentSizeWidth += iSize.width;
newContentSizeHeight = MAX(newContentSizeHeight, iSize.height);
@ -340,11 +340,11 @@ void RichText::formarRenderers()
float newContentSizeHeight = 0.0f;
float *maxHeights = new float[_elementRenders.size()];
for (size_t i=0; i<_elementRenders.size(); i++)
for (ssize_t i=0; i<_elementRenders.size(); i++)
{
Vector<Node*>* row = (_elementRenders[i]);
float maxHeight = 0.0f;
for (int j=0; j<row->size(); j++)
for (ssize_t j=0; j<row->size(); j++)
{
Node* l = row->at(j);
maxHeight = MAX(l->getContentSize().height, maxHeight);
@ -355,18 +355,18 @@ void RichText::formarRenderers()
float nextPosY = _customSize.height;
for (size_t i=0; i<_elementRenders.size(); i++)
for (ssize_t i=0; i<_elementRenders.size(); i++)
{
Vector<Node*>* row = (_elementRenders[i]);
float nextPosX = 0.0f;
nextPosY -= (maxHeights[i] + _verticalSpace);
for (int j=0; j<row->size(); j++)
for (ssize_t j=0; j<row->size(); j++)
{
Node* l = row->at(j);
l->setAnchorPoint(Point::ZERO);
l->setPosition(Point(nextPosX, nextPosY));
_elementRenderersContainer->addChild(l, 1, i*10 + j);
_elementRenderersContainer->addChild(l, 1, (int)(i*10 + j));
nextPosX += l->getContentSize().width;
}
}
@ -375,7 +375,7 @@ void RichText::formarRenderers()
}
size_t length = _elementRenders.size();
for (size_t i = 0; i<length; i++)
for (ssize_t i = 0; i<length; i++)
{
Vector<Node*>* l = _elementRenders[i];
l->clear();

View File

@ -91,7 +91,7 @@ bool UICCTextField::onTextFieldAttachWithIME(TextFieldTTF *pSender)
return false;
}
bool UICCTextField::onTextFieldInsertText(TextFieldTTF *pSender, const char *text, int nLen)
bool UICCTextField::onTextFieldInsertText(TextFieldTTF *pSender, const char *text, size_t nLen)
{
if (nLen == 1 && strcmp(text, "\n") == 0)
{
@ -121,7 +121,7 @@ bool UICCTextField::onTextFieldDetachWithIME(TextFieldTTF *pSender)
return false;
}
void UICCTextField::insertText(const char * text, int len)
void UICCTextField::insertText(const char * text, size_t len)
{
std::string input_text = text;

View File

@ -49,10 +49,10 @@ public:
// CCTextFieldDelegate
virtual bool onTextFieldAttachWithIME(TextFieldTTF *pSender) override;
virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender) override;
virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen) override;
virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, size_t nLen) override;
virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen) override;
void insertText(const char* text, int len);
void insertText(const char* text, size_t len);
void deleteBackward();
void openIME();

View File

@ -1 +1 @@
4dfa7f46c2e06a4b3b95120bea3b8689f31ddad0
8268cc82237edfa69eff7e9ea70b629e18df071d

View File

@ -35,6 +35,7 @@
#include <io.h>
#include <WS2tcpip.h>
#endif
#include "base64.h"
//------------------------------------------------------------------
//
@ -261,51 +262,45 @@ void ConsoleUploadFile::uploadFile()
CCLOG("ConsoleUploadFile: could not open file %s", _src_file_path.c_str());
return;
}
//read file size
fseek(fp, 0, SEEK_END);
int size = ftell(fp);
fseek(fp, 0, SEEK_SET);
char sb[32];
sprintf(sb, "%d", size);
std::string tmp = "upload";
tmp += " ";
tmp += _target_file_name;
tmp += " ";
tmp += sb;
tmp += "\n";
char cmd[512];
strcpy(cmd, tmp.c_str());
send(sfd,cmd,strlen(cmd),0);
// allocate memory to contain the whole file:
char* buffer = (char*) malloc (sizeof(char)*size);
if (buffer == NULL)
while(true)
{
CCLOG("ConsoleUploadFile: memory allocate error!");
return;
char buffer[3], *out;
unsigned char *in;
in = (unsigned char *)buffer;
// copy the file into the buffer:
int ret = fread(buffer, 1, 3, fp);
if (ret > 0)
{
base64Encode(in, ret, &out);
send(sfd, out, 4, 0);
free(out);
if(ret < 3)
{
//eof
break;
}
}
else
{
//read error
break;
}
}
// copy the file into the buffer:
int ret = fread(buffer, 1, size, fp);
if (ret != size)
{
CCLOG("ConsoleUploadFile: read file: %s error!",_src_file_path.c_str());
return;
}
//send to console socket
for(int i = 0; i < size; i++)
{
send(sfd, &buffer[i], 1, 0);
}
char l = '\n';
send(sfd, &l, 1, 0);
// terminate
fclose (fp);
free (buffer);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
closesocket(sfd);
WSACleanup();

View File

@ -8,8 +8,6 @@
#import <UIKit/UIKit.h>
// Under iOS and the Simulator, we can use an alternate Accelerometer interface
#import "AccelerometerSimulation.h"
int main(int argc, char *argv[]) {

View File

@ -4,11 +4,26 @@
import os
import sys
import json
# get payload argvs
console_param = 'create'
# payload = ''
if os.environ.has_key('payload'):
payload_str = os.environ['payload']
payload = json.loads(payload_str)
if payload.has_key('console'):
console_param = payload['console']
print 'console_param:',console_param
console_param_arr = console_param.split(' ')
project_types = ['cpp', 'lua']
PROJ_SUFFIX = 'Proj'
phonePlats = ['mac','ios','android']
#need use console's position, perhaps should be set an env-param
cocos_console_dir = 'tools/cocos2d-console/bin/'
#now cocos2d-console suport different run on Platforms, e.g: only run android on win
@ -18,19 +33,6 @@ runSupport = {
'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'
@ -47,12 +49,10 @@ def clean_project():
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
cmd = './'+cocos_console_dir+'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():
@ -60,7 +60,7 @@ def build_run():
for proj in project_types:
idx = 0
for phone in phonePlats:
cmd = 'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX
cmd = './'+cocos_console_dir+'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX
print proj,'cmd:',cmd
if runSupport[curPlat][idx]:
info_run = os.system(cmd)
@ -68,10 +68,9 @@ def build_run():
idx += 1
def main():
if _will_create:
clean_project()
create_project()
if _will_run:
clean_project()
create_project()
if console_param_arr.count('run'):
build_run()
# -------------- main --------------

View File

@ -26,7 +26,11 @@ def main():
print comment_body
pattern = re.compile("\[ci(\s+)rebuild\]", re.I)
result = pattern.search(comment_body)
if result is None:
# will check console/console create
searchConsole = re.search('\[console.*\]', comment_body)
if result is None and searchConsole is None:
print 'skip build for pull request #' + str(pr_num)
return(0)
@ -75,7 +79,15 @@ def main():
except:
traceback.print_exc()
job_trigger_url = os.environ['JOB_TRIGGER_URL']
job_trigger_url = ''
if result:
job_trigger_url = os.environ['JOB_TRIGGER_URL']
if searchConsole:
consoleOper = searchConsole.group()
job_trigger_url = os.environ['JOB_CONSOLE_TEST_URL']
payload_forword['console'] = consoleOper
print 'job_trigger_url is: ', job_trigger_url
#send trigger and payload
post_data = {'payload':""}
post_data['payload']= json.dumps(payload_forword)