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

This commit is contained in:
zhangbin 2014-04-11 11:37:50 +08:00
commit 76972e6304
252 changed files with 1164 additions and 1157 deletions

View File

@ -763,6 +763,7 @@ Developers:
wefiends
s3tc compressed textures with no mipmaps fail to be loaded.
Added createWithFullscreen overloaded method that sets video mode
floatinghotpot
Fixed a bug that no callback is invoked when websocket connection fails
@ -815,6 +816,13 @@ Developers:
iSevenDays
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
Fixed a potential memory leak in CCEditBoxImplIOS.mm
ololomax
Fixed a potential crash in SceneReader::createNodeWithSceneFile
gaoxiaosong
Fixed a warning in cpCollision.c
Retired Core Developers:
WenSheng Yang

View File

@ -1 +1 @@
334022fee8065e04cd3ba41672900023d8b45e35
3dec43835640892d3595d2063489624cf216dd73

View File

@ -141,6 +141,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/renderer
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform
${CMAKE_CURRENT_SOURCE_DIR}/cocos/base
${CMAKE_CURRENT_SOURCE_DIR}/cocos/deprecated
${CMAKE_CURRENT_SOURCE_DIR}/cocos/physics
${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support
${CMAKE_CURRENT_SOURCE_DIR}/cocos/math/kazmath

View File

@ -1 +1 @@
cf0dc94fe4553bcd4fc0066a938f41610b2617ea
b5b636c8bcca1ce239847cab19cfafedf83ca250

View File

@ -1 +1 @@
f884da8d42063a506285854e6309a5003507da3a
20d3130f1f163df349f4503d05a21797039f1b40

View File

@ -30,7 +30,6 @@ CCClippingNode.cpp \
CCComponent.cpp \
CCComponentContainer.cpp \
CCConfiguration.cpp \
CCDeprecated.cpp \
CCDirector.cpp \
CCDrawingPrimitives.cpp \
CCDrawNode.cpp \
@ -71,7 +70,6 @@ CCMenu.cpp \
CCMenuItem.cpp \
CCMotionStreak.cpp \
CCNode.cpp \
CCNotificationCenter.cpp \
CCParallaxNode.cpp \
CCParticleBatchNode.cpp \
CCParticleExamples.cpp \
@ -128,20 +126,22 @@ renderer/CCRenderer.cpp \
renderer/CCRenderMaterial.cpp \
../base/atitc.cpp \
../base/CCAffineTransform.cpp \
../base/CCArray.cpp \
../base/CCAutoreleasePool.cpp \
../base/CCConsole.cpp \
../base/CCData.cpp \
../base/CCDataVisitor.cpp \
../base/CCDictionary.cpp \
../base/CCGeometry.cpp \
../base/CCNS.cpp \
../base/CCRef.cpp \
../base/CCSet.cpp \
../base/CCString.cpp \
../base/CCValue.cpp \
../base/etc1.cpp \
../base/s3tc.cpp \
../deprecated/CCArray.cpp \
../deprecated/CCSet.cpp \
../deprecated/CCString.cpp \
../deprecated/CCDictionary.cpp \
../deprecated/CCDeprecated.cpp \
../deprecated/CCNotificationCenter.cpp \
../math/kazmath/kazmath/aabb.c \
../math/kazmath/kazmath/mat3.c \
../math/kazmath/kazmath/mat4.c \
@ -174,22 +174,26 @@ renderer/CCRenderMaterial.cpp \
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/.. \
$(LOCAL_PATH)/renderer \
$(LOCAL_PATH)/../math/kazmath \
platform/android \
$(LOCAL_PATH)/../physics \
$(LOCAL_PATH)/../base \
$(LOCAL_PATH)/../deprecated \
$(LOCAL_PATH)/../../external/tinyxml2 \
$(LOCAL_PATH)/../../external/unzip \
$(LOCAL_PATH)/../../external/chipmunk/include/chipmunk \
$(LOCAL_PATH)/../../external/xxhash
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/.. \
$(LOCAL_PATH)/renderer \
$(LOCAL_PATH)/../math/kazmath \
$(LOCAL_PATH)/platform/android \
$(LOCAL_PATH)/../physics \
$(LOCAL_PATH)/../base \
$(LOCAL_PATH)/../deprecated \
$(LOCAL_PATH)/../../external/tinyxml2 \
$(LOCAL_PATH)/../../external/unzip \
$(LOCAL_PATH)/../../external/chipmunk/include/chipmunk \

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include "CCActionInterval.h"
#include "CCNode.h"
#include "CCDirector.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN
//

View File

@ -131,7 +131,7 @@ void PointArray::insertControlPoint(Point &controlPoint, ssize_t index)
Point PointArray::getControlPointAtIndex(ssize_t index)
{
index = MIN(_controlPoints->size()-1, MAX(index, 0));
index = MIN(static_cast<ssize_t>(_controlPoints->size())-1, MAX(index, 0));
return *(_controlPoints->at(index));
}

View File

@ -32,7 +32,6 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "ccCArray.h"
#include "uthash.h"
#include "CCSet.h"
NS_CC_BEGIN
//

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
#include "CCPlatformConfig.h"
#include "CCRef.h"
#include "CCArray.h"
#include "CCValue.h"
#include "CCGeometry.h"
#include "CCSpriteFrame.h"

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include "CCAnimation.h"
#include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "platform/CCFileUtils.h"
using namespace std;

View File

@ -28,13 +28,8 @@ THE SOFTWARE.
#include <string.h>
#include "ccMacros.h"
#include "ccConfig.h"
#include "CCDictionary.h"
#include "CCInteger.h"
#include "CCBool.h"
#include "platform/CCFileUtils.h"
using namespace std;
NS_CC_BEGIN
extern const char* cocos2dVersion();
@ -179,7 +174,7 @@ void Configuration::purgeConfiguration()
}
bool Configuration::checkForGLExtension(const string &searchName) const
bool Configuration::checkForGLExtension(const std::string &searchName) const
{
return (_glExtensions && strstr(_glExtensions, searchName.c_str() ) ) ? true : false;
}

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
#include "CCRef.h"
#include "CCGL.h"
#include "CCString.h"
#include "CCValue.h"
#include <string>

View File

@ -35,7 +35,6 @@ THE SOFTWARE.
#include "CCDrawingPrimitives.h"
#include "CCNS.h"
#include "CCScene.h"
#include "CCArray.h"
#include "CCScheduler.h"
#include "ccMacros.h"
#include "CCTransition.h"

View File

@ -1371,6 +1371,13 @@ void EventDispatcher::setDirtyForNode(Node* node)
{
_dirtyNodes.insert(node);
}
// Also set the dirty flag for node's children
const auto& children = node->getChildren();
for (const auto& child : children)
{
setDirtyForNode(child);
}
}
void EventDispatcher::setDirty(const EventListener::ListenerID& listenerID, DirtyFlag flag)

View File

@ -29,7 +29,7 @@
#include "CCDirector.h"
#include "CCFontAtlas.h"
#include "CCMap.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "CCTextureCache.h"
#include "ccUTF8.h"
#include "platform/CCFileUtils.h"

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "platform/CCFileUtils.h"
#include "uthash.h"
#include "CCString.h"
#include "deprecated/CCString.h"
// extern
#include "kazmath/GL/matrix.h"
#include "kazmath/kazmath.h"

View File

@ -38,6 +38,7 @@
#include "CCEventType.h"
#include "CCEventCustom.h"
#include "platform/CCFileUtils.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN
@ -47,176 +48,142 @@ Label* Label::create()
{
auto ret = new Label();
if (!ret)
return nullptr;
ret->autorelease();
return ret;
}
Label* Label::createWithFontDefinition(const std::string& text, const FontDefinition &textDefinition)
{
auto ret = new Label();
if (ret)
{
ret->setFontDefinition(textDefinition);
ret->setString(text);
ret->autorelease();
}
return ret;
}
Label* Label::create(const std::string& text, const std::string& fontName, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
Label* Label::create(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
if (FileUtils::getInstance()->isFileExist(font))
{
return createWithTTF(text,font,fontSize,dimensions,hAlignment,vAlignment);
}
else
{
return createWithSystemFont(text,font,fontSize,dimensions,hAlignment,vAlignment);
}
}
Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
auto ret = new Label(nullptr,hAlignment,vAlignment);
if (ret)
{
do
{
if (FileUtils::getInstance()->isFileExist(fontName))
{
TTFConfig ttfConfig(fontName.c_str(),fontSize,GlyphCollection::DYNAMIC);
if (ret->setTTFConfig(ttfConfig))
{
break;
}
}
FontDefinition fontDef;
fontDef._fontName = fontName;
fontDef._fontSize = fontSize;
fontDef._dimensions = dimensions;
fontDef._alignment = hAlignment;
fontDef._vertAlignment = vAlignment;
ret->setFontDefinition(fontDef);
} while (0);
ret->setDimensions(dimensions.width,dimensions.height);
ret->setSystemFontName(font);
ret->setSystemFontSize(fontSize);
ret->setDimensions(dimensions.width, dimensions.height);
ret->setString(text);
ret->autorelease();
}
return ret;
}
delete ret;
return nullptr;
}
Label* Label::createWithTTF(const std::string& text, const std::string& fontFile, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
auto ret = new Label(nullptr,hAlignment,vAlignment);
if (ret && FileUtils::getInstance()->isFileExist(fontFile))
{
TTFConfig ttfConfig(fontFile.c_str(),fontSize,GlyphCollection::DYNAMIC);
if (ret->setTTFConfig(ttfConfig))
{
ret->setDimensions(dimensions.width,dimensions.height);
ret->setString(text);
ret->autorelease();
return ret;
}
}
delete ret;
return nullptr;
}
Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment /* = TextHAlignment::CENTER */, int maxLineWidth /* = 0 */)
{
auto ret = new Label(nullptr,alignment);
if (!ret)
if (ret && FileUtils::getInstance()->isFileExist(ttfConfig.fontFilePath) && ret->setTTFConfig(ttfConfig))
{
return nullptr;
}
do
{
if( FileUtils::getInstance()->isFileExist(ttfConfig.fontFilePath) && ret->setTTFConfig(ttfConfig))
{
break;
}
FontDefinition fontDef;
fontDef._fontName = ttfConfig.fontFilePath;
fontDef._fontSize = ttfConfig.fontSize;
fontDef._dimensions = Size::ZERO;
fontDef._alignment = alignment;
fontDef._vertAlignment = TextVAlignment::TOP;
ret->setFontDefinition(fontDef);
} while (0);
ret->setMaxLineWidth(maxLineWidth);
ret->setString(text);
ret->autorelease();
return ret;
}
}
Label* Label::createWithTTF(const std::string& text, const std::string& fontFilePath, int fontSize, int maxLineWidth /* = 0 */, TextHAlignment alignment /* = TextHAlignment::CENTER */, GlyphCollection glyphs /* = GlyphCollection::NEHE */, const char *customGlyphs /* = 0 */, bool useDistanceField /* = false */)
{
TTFConfig ttfConfig(fontFilePath.c_str(),fontSize,glyphs,customGlyphs,useDistanceField);
return createWithTTF(ttfConfig,text,alignment,maxLineWidth);
delete ret;
return nullptr;
}
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Point& imageOffset /* = Point::ZERO */)
{
auto ret = new Label(nullptr,alignment);
if (!ret)
return nullptr;
if (ret->setBMFontFilePath(bmfontFilePath,imageOffset))
if (ret && ret->setBMFontFilePath(bmfontFilePath,imageOffset))
{
ret->setMaxLineWidth(maxLineWidth);
ret->setString(text);
ret->autorelease();
return ret;
}
else
{
delete ret;
return nullptr;
}
}
Label* Label::createWithCharMap(const std::string& plistFile)
{
auto ret = new Label();
if (!ret)
return nullptr;
if (ret->setCharMap(plistFile))
if (ret && ret->setCharMap(plistFile))
{
ret->autorelease();
return ret;
}
else
{
delete ret;
return nullptr;
}
}
Label* Label::createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
{
auto ret = new Label();
if (!ret)
return nullptr;
if (ret->setCharMap(texture,itemWidth,itemHeight,startCharMap))
if (ret && ret->setCharMap(texture,itemWidth,itemHeight,startCharMap))
{
ret->autorelease();
return ret;
}
else
{
delete ret;
return nullptr;
}
}
Label* Label::createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
auto ret = new Label();
if (!ret)
return nullptr;
if (ret->setCharMap(charMapFile,itemWidth,itemHeight,startCharMap))
if (ret && ret->setCharMap(charMapFile,itemWidth,itemHeight,startCharMap))
{
ret->autorelease();
return ret;
}
else
{
delete ret;
return nullptr;
}
}
bool Label::setCharMap(const std::string& plistFile)
@ -296,11 +263,22 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
reset();
#if CC_ENABLE_CACHE_TEXTURE_DATA
auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(Label::listenToBackground, this));
auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF)
{
_batchNodes.clear();
_batchNodes.push_back(this);
Node::removeAllChildrenWithCleanup(true);
}
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this);
#endif
auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, CC_CALLBACK_1(Label::listenToFontAtlasPurge, this));
auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{
alignText();
}
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(purgeTextureListener, this);
}
@ -323,14 +301,9 @@ void Label::reset()
TTFConfig temp;
_fontConfig = temp;
_fontDefinition._fontName = "Helvetica";
_fontDefinition._fontSize = 12;
_fontDefinition._alignment = _hAlignment;
_fontDefinition._vertAlignment = _vAlignment;
_fontDirty = false;
_fontName = "Helvetica";
_fontSize = 12;
_systemFont = "Helvetica";
_systemFontSize = 12;
_batchNodes.clear();
_batchNodes.push_back(this);
@ -476,9 +449,6 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
}
}
_fontDefinition._shadow._shadowEnabled = false;
_fontDefinition._stroke._strokeEnabled = false;
return true;
}
@ -498,27 +468,6 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Point& im
return true;
}
void Label::setFontDefinition(const FontDefinition& textDefinition)
{
reset();
_fontDefinition = textDefinition;
_fontName = textDefinition._fontName;
_fontSize = textDefinition._fontSize;
_shadowEnabled = textDefinition._shadow._shadowEnabled;
if (_shadowEnabled)
{
enableShadow(Color4B::BLACK,_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur);
}
_textColor = Color4B(_fontDefinition._fontFillColor);
_textColorF.r = _textColor.r / 255.0f;
_textColorF.g = _textColor.g / 255.0f;
_textColorF.b = _textColor.b / 255.0f;
_textColorF.a = _textColor.a / 255.0f;
_contentDirty = true;
}
void Label::setString(const std::string& text)
{
_originalUTF8String = text;
@ -529,9 +478,6 @@ void Label::setAlignment(TextHAlignment hAlignment,TextVAlignment vAlignment)
{
if (hAlignment != _hAlignment || vAlignment != _vAlignment)
{
_fontDefinition._alignment = hAlignment;
_fontDefinition._vertAlignment = vAlignment;
_hAlignment = hAlignment;
_vAlignment = vAlignment;
@ -552,9 +498,6 @@ void Label::setDimensions(unsigned int width,unsigned int height)
{
if (height != _labelHeight || width != _labelWidth)
{
_fontDefinition._dimensions.width = width;
_fontDefinition._dimensions.height = height;
_labelWidth = width;
_labelHeight = height;
_labelDimensions.width = width;
@ -802,27 +745,6 @@ void Label::sortAllChildren()
// Label ignore sort children
}
void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor)
{
switch (effect)
{
case cocos2d::LabelEffect::NORMAL:
disableEffect();
break;
case cocos2d::LabelEffect::OUTLINE:
enableOutline(Color4B(effectColor));
break;
case cocos2d::LabelEffect::SHADOW:
enableShadow(Color4B(effectColor));
break;
case cocos2d::LabelEffect::GLOW:
enableGlow(Color4B(effectColor));
break;
default:
break;
}
}
void Label::enableGlow(const Color4B& glowColor)
{
if(! _useDistanceField)
@ -846,6 +768,7 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */
if (outlineSize > 0)
{
_outlineSize = outlineSize;
if (_currentLabelType == LabelType::TTF)
{
if (_fontConfig.outlineSize != outlineSize)
@ -856,9 +779,6 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */
updateShaderProgram();
}
}
_fontDefinition._stroke._strokeEnabled = true;
_fontDefinition._stroke._strokeSize = outlineSize;
_fontDefinition._stroke._strokeColor = Color3B(outlineColor.r,outlineColor.g,outlineColor.b);
_currLabelEffect = LabelEffect::OUTLINE;
_contentDirty = true;
@ -868,7 +788,6 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */
void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const Size &offset /* = Size(2 ,-2)*/, int blurRadius /* = 0 */)
{
_shadowEnabled = true;
_fontDefinition._shadow._shadowEnabled = false;
_shadowDirty = true;
_shadowColor.r = shadowColor.r;
@ -991,15 +910,8 @@ void Label::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpda
void Label::createSpriteWithFontDefinition()
{
_currentLabelType = LabelType::STRING_TEXTURE;
auto texture = new Texture2D;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
if (_fontDefinition._shadow._shadowEnabled || _fontDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Currently only supported on iOS and Android!");
}
_fontDefinition._shadow._shadowEnabled = false;
_fontDefinition._stroke._strokeEnabled = false;
#endif
texture->initWithString(_originalUTF8String.c_str(),_fontDefinition);
_textSprite = Sprite::createWithTexture(texture);
@ -1016,11 +928,29 @@ void Label::createSpriteWithFontDefinition()
_textSprite->updateDisplayedColor(_displayedColor);
}
void Label::setFontDefinition(const FontDefinition& textDefinition)
{
_fontDefinition = textDefinition;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
if (_fontDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Currently only supported on iOS and Android!");
}
_fontDefinition._stroke._strokeEnabled = false;
#endif
if (_fontDefinition._shadow._shadowEnabled)
{
_fontDefinition._shadow._shadowEnabled = false;
enableShadow(Color4B(0,0,0,255 * _fontDefinition._shadow._shadowOpacity),_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur);
}
}
void Label::updateContent()
{
auto utf16String = cc_utf8_to_utf16(_originalUTF8String.c_str());
setCurrentString(utf16String);
setOriginalString(utf16String);
if (_textSprite)
{
Node::removeChild(_textSprite,true);
@ -1031,16 +961,49 @@ void Label::updateContent()
_shadowNode = nullptr;
}
}
if (_fontAtlas)
{
alignText();
}
else
{
_fontDefinition._fontName = _systemFont;
_fontDefinition._fontSize = _systemFontSize;
_fontDefinition._alignment = _hAlignment;
_fontDefinition._vertAlignment = _vAlignment;
_fontDefinition._dimensions.width = _labelWidth;
_fontDefinition._dimensions.height = _labelHeight;
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
_fontDefinition._shadow._shadowEnabled = false;
if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0)
{
_fontDefinition._stroke._strokeEnabled = true;
_fontDefinition._stroke._strokeSize = _outlineSize;
_fontDefinition._stroke._strokeColor.r = _effectColor.r;
_fontDefinition._stroke._strokeColor.g = _effectColor.g;
_fontDefinition._stroke._strokeColor.b = _effectColor.b;
}
else
{
_fontDefinition._stroke._strokeEnabled = false;
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
if (_fontDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Currently only supported on iOS and Android!");
}
_fontDefinition._stroke._strokeEnabled = false;
#endif
createSpriteWithFontDefinition();
}
_contentDirty = false;
@ -1048,14 +1011,15 @@ void Label::updateContent()
void Label::updateFont()
{
if (FileUtils::getInstance()->isFileExist(_fontName))
if (_fontAtlas)
{
_fontConfig.fontFilePath = _fontName;
_fontConfig.fontSize = _fontSize;
setTTFConfig(_fontConfig);
_batchNodes.clear();
_batchNodes.push_back(this);
FontAtlasCache::releaseFontAtlas(_fontAtlas);
_fontAtlas = nullptr;
}
_fontDefinition._fontName = _fontName;
_fontDefinition._fontSize = _fontSize;
_contentDirty = true;
_fontDirty = false;
}
@ -1064,18 +1028,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
{
if (_fontDefinition._fontFillColor != _textColor)
{
Node::removeChild(_textSprite,true);
_textSprite = nullptr;
if (_shadowNode)
{
Node::removeChild(_shadowNode,true);
_shadowNode = nullptr;
}
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
createSpriteWithFontDefinition();
updateContent();
}
if (_shadowEnabled && _shadowNode == nullptr)
@ -1084,8 +1037,9 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
if (_shadowNode)
{
if (_blendFuncDirty)
{
_shadowNode->setBlendFunc(_blendFunc);
}
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
@ -1158,41 +1112,33 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
setOrderOfArrival(0);
}
void Label::setFontName(const std::string& fontName)
void Label::setSystemFontName(const std::string& systemFont)
{
if (fontName != _fontName)
if (systemFont != _systemFont)
{
_fontName = fontName;
_systemFont = systemFont;
_fontDirty = true;
}
}
const std::string& Label::getFontName() const
void Label::setSystemFontSize(float fontSize)
{
return _fontName;
}
void Label::setFontSize(float fontSize)
{
if (_fontSize != fontSize)
if (_systemFontSize != fontSize)
{
_fontSize = fontSize;
_systemFontSize = fontSize;
_fontDirty = true;
}
}
float Label::getFontSize() const
{
return _fontSize;
}
///// PROTOCOL STUFF
Sprite * Label::getLetter(int letterIndex)
{
if (_fontDirty)
{
updateFont();
return nullptr;
}
if (_contentDirty)
{
updateContent();
@ -1381,26 +1327,6 @@ Rect Label::getBoundingBox() const
return Node::getBoundingBox();
}
void Label::listenToBackground(EventCustom *event)
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
if (_fontAtlas && _currentLabelType == LabelType::TTF)
{
_batchNodes.clear();
_batchNodes.push_back(this);
Node::removeAllChildrenWithCleanup(true);
}
#endif
}
void Label::listenToFontAtlasPurge(EventCustom *event)
{
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{
alignText();
}
}
void Label::setBlendFunc(const BlendFunc &blendFunc)
{
_blendFunc = blendFunc;

View File

@ -82,18 +82,26 @@ public:
static Label* create();
/** creates a Label from a font name, horizontal alignment, dimension in points, and font size in points.
* @warning It will generate texture by the platform-dependent code if [fontName] not a font file.
/** Creates a label with an initial string,font[font name or font file],font size, dimension in points, horizontal alignment and vertical alignment.
* @warning It will generate texture by the platform-dependent code
*/
static Label * create(const std::string& text, const std::string& fontName, float fontSize,
static Label* createWithSystemFont(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
/** create a label with TTF configuration
* It will generate texture of character by freetype.
/** Creates a label with an initial string,font file,font size, dimension in points, horizontal alignment and vertical alignment.
* @warning Not support font name.
*/
static Label * createWithTTF(const std::string& text, const std::string& fontFile, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
/** Create a label with TTF configuration
* @warning Not support font name.
*/
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment = TextHAlignment::LEFT, int maxLineWidth = 0);
/* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/
static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,
const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0,
const Point& imageOffset = Point::ZERO);
@ -102,14 +110,9 @@ public:
static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
static Label * createWithCharMap(const std::string& plistFile);
/** create a lable with string and a font definition
* @warning It will generate texture by the platform-dependent code and create Sprite for show text.
* To obtain better performance use createWithTTF/createWithBMFont/createWithCharMap
*/
static Label * createWithFontDefinition(const std::string& text, const FontDefinition &textDefinition);
/** set TTF configuration for Label */
virtual bool setTTFConfig(const TTFConfig& ttfConfig);
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Point& imageOffset = Point::ZERO);
const std::string& getBMFontFilePath() const { return _bmFontPath;}
@ -118,13 +121,13 @@ public:
virtual bool setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
virtual bool setCharMap(const std::string& plistFile);
/** set the text definition used by this label
* It will create Sprite for show text if you haven't set up using TTF/BMFont/CharMap.
*/
virtual void setFontDefinition(const FontDefinition& textDefinition);
/* Sets the system font[font name or font file] of label*/
virtual void setSystemFontName(const std::string& systemFont);
virtual const std::string& getSystemFontName() const { return _systemFont;}
/** get the text definition used by this label */
const FontDefinition& getFontDefinition() const { return _fontDefinition; }
/* Sets the system font size of label.*/
virtual void setSystemFontSize(float fontSize);
virtual float getSystemFontSize() const { return _systemFontSize;}
/** changes the string to render
* @warning It is as expensive as changing the string if you haven't set up TTF/BMFont/CharMap for the label.
@ -190,12 +193,6 @@ public:
/** update content immediately.*/
virtual void updateContent();
virtual void setFontName(const std::string& fontName);
virtual const std::string& getFontName() const;
virtual void setFontSize(float fontSize);
virtual float getFontSize() const;
/** Sets the text color
*
*/
@ -243,22 +240,13 @@ public:
virtual void visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) override;
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
/** Listen "come to background" message
It only has effect on Android.
*/
void listenToBackground(EventCustom *event);
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
TextVAlignment vAlignment = TextVAlignment::TOP);
/** Listen "FontAtlas purge textures" message
*/
void listenToFontAtlasPurge(EventCustom *event);
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
CC_DEPRECATED_ATTRIBUTE static Label* createWithTTF(const std::string& label, const std::string& fontFilePath,
int fontSize, int maxLineWidth = 0, TextHAlignment alignment = TextHAlignment::LEFT,
GlyphCollection glyphs = GlyphCollection::DYNAMIC, const char *customGlyphs = 0, bool useDistanceField = false);
CC_DEPRECATED_ATTRIBUTE int getStringLenght() const { return getStringLength(); }
CC_DEPRECATED_ATTRIBUTE void setLabelEffect(LabelEffect effect,const Color3B& effectColor);
protected:
void onDraw(const kmMat4& transform, bool transformUpdated);
@ -322,9 +310,10 @@ protected:
bool _isOpacityModifyRGB;
bool _contentDirty;
bool _fontDirty;
std::string _fontName;
float _fontSize;
std::string _systemFont;
float _systemFontSize;
LabelType _currentLabelType;
std::vector<SpriteBatchNode*> _batchNodes;
@ -380,6 +369,8 @@ protected:
float _shadowOpacity;
Sprite* _shadowNode;
int _outlineSize;
Color4B _textColor;
Color4F _textColorF;

View File

@ -34,11 +34,10 @@ THE SOFTWARE.
#include "ccGLStateCache.h"
#include "CCDirector.h"
#include "TransformUtils.h"
#include "CCInteger.h"
#include "platform/CCFileUtils.h"
// external
#include "kazmath/GL/matrix.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -33,7 +33,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
#include "CCLabelBMFont.h"
#include "CCDrawingPrimitives.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "CCSprite.h"
using namespace std;

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
****************************************************************************/
#include "CCLabelTTF.h"
#include "CCLabel.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN
@ -97,10 +97,10 @@ bool LabelTTF::initWithString(const std::string& string, const std::string& font
TextVAlignment vAlignment)
{
_renderLabel->setString(string);
_renderLabel->setFontSize(fontSize);
_renderLabel->setSystemFontSize(fontSize);
_renderLabel->setDimensions(dimensions.width,dimensions.height);
_renderLabel->setAlignment(hAlignment,vAlignment);
_renderLabel->setFontName(fontName);
_renderLabel->setSystemFontName(fontName);
_contentDirty = true;
return true;
@ -128,7 +128,7 @@ const std::string& LabelTTF::getString() const
std::string LabelTTF::getDescription() const
{
return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %f, Label = '%s'>", _renderLabel->getFontName().c_str(), _renderLabel->getFontSize(), _renderLabel->getString().c_str());
return StringUtils::format("<LabelTTF | FontName = %s, FontSize = %f, Label = '%s'>", _renderLabel->getSystemFontName().c_str(), _renderLabel->getSystemFontSize(), _renderLabel->getString().c_str());
}
TextHAlignment LabelTTF::getHorizontalAlignment() const
@ -166,23 +166,23 @@ void LabelTTF::setDimensions(const Size &dim)
float LabelTTF::getFontSize() const
{
return _renderLabel->getFontSize();
return _renderLabel->getSystemFontSize();
}
void LabelTTF::setFontSize(float fontSize)
{
_renderLabel->setFontSize(fontSize);
_renderLabel->setSystemFontSize(fontSize);
_contentDirty = true;
}
const std::string& LabelTTF::getFontName() const
{
return _renderLabel->getFontName();
return _renderLabel->getSystemFontName();
}
void LabelTTF::setFontName(const std::string& fontName)
{
_renderLabel->setFontName(fontName);
_renderLabel->setSystemFontName(fontName);
_contentDirty = true;
}

View File

@ -46,7 +46,7 @@ THE SOFTWARE.
#include "CCScene.h"
#include "renderer/CCCustomCommand.h"
#include "renderer/CCRenderer.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -45,6 +45,7 @@ NS_CC_BEGIN
* @{
*/
class __Set;
class TouchScriptHandlerEntry;
class EventListenerTouch;

View File

@ -28,9 +28,8 @@ THE SOFTWARE.
#include "CCApplication.h"
#include "CCTouch.h"
#include "CCStdC.h"
#include "CCInteger.h"
#include "CCEventListenerTouch.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include <vector>
#include <stdarg.h>

View File

@ -31,6 +31,7 @@ THE SOFTWARE.
#include "CCLabelAtlas.h"
#include "CCLabel.h"
#include "CCScriptSupport.h"
#include "deprecated/CCString.h"
#include <stdarg.h>
#include <cstring>
@ -439,7 +440,7 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback
_fontName = _globalFontName;
_fontSize = _globalFontSize;
Label *label = Label::create(value, _fontName, _fontSize);
Label *label = Label::createWithSystemFont(value, _fontName, _fontSize);
if (MenuItemLabel::initWithLabel(label, callback))
{
// do something ?
@ -450,7 +451,7 @@ bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback
void MenuItemFont::setFontSizeObj(int s)
{
_fontSize = s;
dynamic_cast<Label*>(_label)->setFontSize(_fontSize);
dynamic_cast<Label*>(_label)->setSystemFontSize(_fontSize);
this->setContentSize(dynamic_cast<Label*>(_label)->getContentSize());
}
@ -462,7 +463,7 @@ int MenuItemFont::getFontSizeObj() const
void MenuItemFont::setFontNameObj(const std::string& name)
{
_fontName = name;
dynamic_cast<Label*>(_label)->setFontName(_fontName);
dynamic_cast<Label*>(_label)->setSystemFontName(_fontName);
this->setContentSize(dynamic_cast<Label*>(_label)->getContentSize());
}

View File

@ -34,7 +34,6 @@ THE SOFTWARE.
// cocos2d includes
#include "CCNode.h"
#include "CCProtocols.h"
#include "CCArray.h"
NS_CC_BEGIN

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include <algorithm>
#include "CCString.h"
#include "deprecated/CCString.h"
#include "ccCArray.h"
#include "TransformUtils.h"
#include "CCGrid.h"

View File

@ -31,7 +31,6 @@
#include "ccMacros.h"
#include "CCAffineTransform.h"
#include "CCArray.h"
#include "CCGL.h"
#include "ccGLStateCache.h"
#include "CCGLProgram.h"

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include "CCProtocols.h"
#include "CCNode.h"
#include "CCValue.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -31,6 +31,7 @@ THE SOFTWARE.
#include "CCSprite.h"
#include "CCSpriteBatchNode.h"
#include "CCPhysicsWorld.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "CCDirector.h"
#include "utlist.h"
#include "ccCArray.h"
#include "CCArray.h"
#include "CCScriptSupport.h"
NS_CC_BEGIN

View File

@ -33,7 +33,6 @@
#include "CCTouch.h"
#include "CCEventTouch.h"
#include "CCEventKeyboard.h"
#include "CCSet.h"
#include <map>
#include <string>
#include <list>

View File

@ -24,14 +24,11 @@ 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 "CCSprite.h"
#include "CCSpriteBatchNode.h"
#include <string.h>
#include <algorithm>
#include "CCAnimation.h"
#include "CCAnimationCache.h"
#include "ccConfig.h"
#include "CCSprite.h"
#include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h"
#include "CCTextureCache.h"
@ -52,9 +49,10 @@ THE SOFTWARE.
// external
#include "kazmath/GL/matrix.h"
#include "kazmath/kazmath.h"
#include "deprecated/CCString.h"
using namespace std;
#include <string.h>
#include <algorithm>
NS_CC_BEGIN

View File

@ -32,7 +32,6 @@ THE SOFTWARE.
#include "CCProtocols.h"
#include "CCTextureAtlas.h"
#include "ccTypes.h"
#include "CCDictionary.h"
#include <string>
#ifdef EMSCRIPTEN
#include "CCGLBufferedNode.h"

View File

@ -27,9 +27,6 @@ THE SOFTWARE.
****************************************************************************/
#include "CCSpriteBatchNode.h"
#include <algorithm>
#include "ccConfig.h"
#include "CCSprite.h"
#include "CCGrid.h"
@ -48,6 +45,10 @@ THE SOFTWARE.
// external
#include "kazmath/GL/matrix.h"
#include "deprecated/CCString.h" // For StringUtils::format
#include <algorithm>
NS_CC_BEGIN
/*

View File

@ -77,28 +77,7 @@ public:
The file will be loaded using the TextureMgr.
*/
static SpriteBatchNode* create(const std::string& fileImage, ssize_t capacity = DEFAULT_CAPACITY);
/**
* @js ctor
*/
SpriteBatchNode();
/**
* @js NA
* @lua NA
*/
virtual ~SpriteBatchNode();
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
bool initWithTexture(Texture2D *tex, ssize_t capacity);
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
* @js init
* @lua init
*/
bool initWithFile(const std::string& fileImage, ssize_t capacity);
bool init();
/** returns the TextureAtlas object */
inline TextureAtlas* getTextureAtlas(void) { return _textureAtlas; }
@ -176,6 +155,31 @@ public:
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
*/
SpriteBatchNode * addSpriteWithoutQuad(Sprite *child, int z, int aTag);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
SpriteBatchNode();
/**
* @js NA
* @lua NA
*/
virtual ~SpriteBatchNode();
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
*/
bool initWithTexture(Texture2D *tex, ssize_t capacity);
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
* @js init
* @lua init
*/
bool initWithFile(const std::string& fileImage, ssize_t capacity);
bool init();
protected:
/** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.

View File

@ -35,9 +35,7 @@ THE SOFTWARE.
#include "CCSprite.h"
#include "TransformUtils.h"
#include "platform/CCFileUtils.h"
#include "CCString.h"
#include "CCArray.h"
#include "CCDictionary.h"
#include "deprecated/CCString.h"
#include "CCDirector.h"
#include <vector>

View File

@ -34,6 +34,8 @@ THE SOFTWARE.
#include "ccCArray.h"
#include "CCDirector.h"
#include "deprecated/CCString.h" // For StringUtils::format
NS_CC_BEGIN

View File

@ -28,6 +28,8 @@ THE SOFTWARE.
#include "CCTMXXMLParser.h"
#include "CCTMXLayer.h"
#include "CCSprite.h"
#include "deprecated/CCString.h" // For StringUtils::format
#include <algorithm>
NS_CC_BEGIN

View File

@ -111,8 +111,8 @@ bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Siz
{
_placeHolder = placeholder;
setDimensions(dimensions.width,dimensions.height);
setFontName(fontName);
setFontSize(fontSize);
setSystemFontName(fontName);
setSystemFontSize(fontSize);
setAlignment(alignment,TextVAlignment::CENTER);
Label::setTextColor(_colorSpaceHolder);
Label::setString(_placeHolder);
@ -122,8 +122,8 @@ bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Siz
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
_placeHolder = std::string(placeholder);
setFontName(fontName);
setFontSize(fontSize);
setSystemFontName(fontName);
setSystemFontSize(fontSize);
Label::setTextColor(_colorSpaceHolder);
Label::setString(_placeHolder);

View File

@ -44,6 +44,7 @@ THE SOFTWARE.
#include "ccGLStateCache.h"
#include "CCShaderCache.h"
#include "platform/CCDevice.h"
#include "deprecated/CCString.h"
#if CC_ENABLE_CACHE_TEXTURE_DATA
#include "CCTextureCache.h"

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
// support
#include "CCTexture2D.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include <stdlib.h>
#include "CCEventDispatcher.h"
#include "CCEventListenerCustom.h"

View File

@ -37,7 +37,7 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h"
#include "ccUtils.h"
#include "CCScheduler.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#ifdef EMSCRIPTEN

View File

@ -29,9 +29,8 @@ THE SOFTWARE.
#include "CCTextureAtlas.h"
#include "TGAlib.h"
#include "ccConfig.h"
#include "CCInteger.h"
#include "CCDirector.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include <sstream>
NS_CC_BEGIN

View File

@ -42,12 +42,18 @@ NS_CC_BEGIN
const unsigned int kSceneFade = 0xFADEFADE;
TransitionScene::TransitionScene()
: _inScene(nullptr)
, _outScene(nullptr)
, _duration(0.0f)
, _isInSceneOnTop(false)
, _isSendCleanupToScene(false)
{
}
TransitionScene::~TransitionScene()
{
_inScene->release();
_outScene->release();
CC_SAFE_RELEASE(_inScene);
CC_SAFE_RELEASE(_outScene);
}
TransitionScene * TransitionScene::create(float t, Scene *scene)

View File

@ -103,7 +103,6 @@ set(COCOS2D_SRC
base64.cpp
ccUtils.cpp
CCVertex.cpp
CCNotificationCenter.cpp
TGAlib.cpp
ZipUtils.cpp
ccCArray.cpp
@ -130,13 +129,11 @@ set(COCOS2D_SRC
ccFPSImages.c
ccTypes.cpp
cocos2d.cpp
CCDeprecated.cpp
platform/CCSAXParser.cpp
platform/CCThread.cpp
platform/CCGLViewProtocol.cpp
platform/CCFileUtils.cpp
platform/CCImage.cpp
../../external/edtaa3func/edtaa3func.cpp
renderer/CCCustomCommand.cpp
renderer/CCFrustum.cpp
renderer/CCGroupCommand.cpp
@ -146,6 +143,9 @@ set(COCOS2D_SRC
renderer/CCRenderCommand.cpp
renderer/CCRenderer.cpp
renderer/CCRenderMaterial.cpp
../deprecated/CCDeprecated.cpp
../deprecated/CCNotificationCenter.cpp
../../external/edtaa3func/edtaa3func.cpp
)
include(../physics/CMakeLists.txt)

View File

@ -26,11 +26,10 @@ THE SOFTWARE.
#include "ccCArray.h"
#include "CCRef.h"
#include "ccTypes.h"
NS_CC_BEGIN
const ssize_t CC_INVALID_INDEX = -1;
/** Allocates and initializes a new array with specified capacity */
ccArray* ccArrayNew(ssize_t capacity)
{

View File

@ -52,8 +52,6 @@ THE SOFTWARE.
NS_CC_BEGIN
extern const ssize_t CC_INVALID_INDEX;
// Easy integration
#define CCARRAYDATA_FOREACH(__array__, __object__) \
__object__=__array__->arr[0]; for(ssize_t i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \

View File

@ -28,7 +28,9 @@ Copyright (c) 2013-2014 Chukong Technologies Inc.
#include "ccTypes.h"
NS_CC_BEGIN
const std::string STD_STRING_EMPTY("");
const ssize_t CC_INVALID_INDEX = -1;
/**
* Color3B

View File

@ -473,6 +473,7 @@ public:
};
extern const std::string STD_STRING_EMPTY;
extern const ssize_t CC_INVALID_INDEX;
NS_CC_END

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "3.0-rc1";
return "3.0";
}
NS_CC_END

View File

@ -59,19 +59,11 @@ THE SOFTWARE.
// cocoa
#include "CCAffineTransform.h"
#include "CCDictionary.h"
#include "CCRef.h"
#include "CCArray.h"
#include "CCVector.h"
#include "CCMap.h"
#include "CCGeometry.h"
#include "CCSet.h"
#include "CCAutoreleasePool.h"
#include "CCInteger.h"
#include "CCFloat.h"
#include "CCDouble.h"
#include "CCBool.h"
#include "CCString.h"
#include "CCNS.h"
#include "CCData.h"
#include "CCValue.h"
@ -96,6 +88,7 @@ THE SOFTWARE.
#include "CCLabelTTF.h"
#include "CCLabelBMFont.h"
#include "CCLabel.h"
#include "CCFontFNT.h"
// layers_scenes_transitions_nodes
#include "CCLayer.h"
@ -230,7 +223,6 @@ THE SOFTWARE.
// support
#include "ccUTF8.h"
#include "CCNotificationCenter.h"
#include "CCProfiling.h"
#include "CCConsole.h"
#include "CCUserDefault.h"
@ -277,7 +269,18 @@ THE SOFTWARE.
#include "CCComponentContainer.h"
// Deprecated include
#include "CCDeprecated.h"
#include "deprecated/CCDictionary.h"
#include "deprecated/CCArray.h"
#include "deprecated/CCSet.h"
#include "deprecated/CCInteger.h"
#include "deprecated/CCFloat.h"
#include "deprecated/CCDouble.h"
#include "deprecated/CCBool.h"
#include "deprecated/CCString.h"
#include "deprecated/CCNotificationCenter.h"
// CCDeprecated.h must be included at the end
#include "deprecated/CCDeprecated.h"
NS_CC_BEGIN

View File

@ -171,20 +171,22 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="..\..\external\xxhash\xxhash.c" />
<ClCompile Include="..\base\atitc.cpp" />
<ClCompile Include="..\base\CCAffineTransform.cpp" />
<ClCompile Include="..\base\CCArray.cpp" />
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
<ClCompile Include="..\base\CCConsole.cpp" />
<ClCompile Include="..\base\CCData.cpp" />
<ClCompile Include="..\base\CCDataVisitor.cpp" />
<ClCompile Include="..\base\CCDictionary.cpp" />
<ClCompile Include="..\base\CCGeometry.cpp" />
<ClCompile Include="..\base\CCNS.cpp" />
<ClCompile Include="..\base\CCRef.cpp" />
<ClCompile Include="..\base\CCSet.cpp" />
<ClCompile Include="..\base\CCString.cpp" />
<ClCompile Include="..\base\CCValue.cpp" />
<ClCompile Include="..\base\etc1.cpp" />
<ClCompile Include="..\base\s3tc.cpp" />
<ClCompile Include="..\deprecated\CCArray.cpp" />
<ClCompile Include="..\deprecated\CCDeprecated.cpp" />
<ClCompile Include="..\deprecated\CCDictionary.cpp" />
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp" />
<ClCompile Include="..\deprecated\CCSet.cpp" />
<ClCompile Include="..\deprecated\CCString.cpp" />
<ClCompile Include="..\math\kazmath\kazmath\aabb.c" />
<ClCompile Include="..\math\kazmath\kazmath\GL\mat4stack.c" />
<ClCompile Include="..\math\kazmath\kazmath\GL\matrix.c" />
@ -231,7 +233,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="CCComponent.cpp" />
<ClCompile Include="CCComponentContainer.cpp" />
<ClCompile Include="CCConfiguration.cpp" />
<ClCompile Include="CCDeprecated.cpp" />
<ClCompile Include="CCDirector.cpp" />
<ClCompile Include="CCDrawingPrimitives.cpp" />
<ClCompile Include="CCDrawNode.cpp" />
@ -271,7 +272,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="CCMenuItem.cpp" />
<ClCompile Include="CCMotionStreak.cpp" />
<ClCompile Include="CCNode.cpp" />
<ClCompile Include="CCNotificationCenter.cpp" />
<ClCompile Include="CCParallaxNode.cpp" />
<ClCompile Include="CCParticleBatchNode.cpp" />
<ClCompile Include="CCParticleExamples.cpp" />
@ -341,28 +341,30 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="..\..\external\xxhash\xxhash.h" />
<ClInclude Include="..\base\atitc.h" />
<ClInclude Include="..\base\CCAffineTransform.h" />
<ClInclude Include="..\base\CCArray.h" />
<ClInclude Include="..\base\CCAutoreleasePool.h" />
<ClInclude Include="..\base\CCBool.h" />
<ClInclude Include="..\base\CCConsole.h" />
<ClInclude Include="..\base\CCData.h" />
<ClInclude Include="..\base\CCDataVisitor.h" />
<ClInclude Include="..\base\CCDictionary.h" />
<ClInclude Include="..\base\CCDouble.h" />
<ClInclude Include="..\base\CCFloat.h" />
<ClInclude Include="..\base\CCGeometry.h" />
<ClInclude Include="..\base\CCInteger.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNS.h" />
<ClInclude Include="..\base\CCRef.h" />
<ClInclude Include="..\base\CCPlatformConfig.h" />
<ClInclude Include="..\base\CCPlatformMacros.h" />
<ClInclude Include="..\base\CCSet.h" />
<ClInclude Include="..\base\CCString.h" />
<ClInclude Include="..\base\CCValue.h" />
<ClInclude Include="..\base\CCVector.h" />
<ClInclude Include="..\base\etc1.h" />
<ClInclude Include="..\base\s3tc.h" />
<ClInclude Include="..\deprecated\CCArray.h" />
<ClInclude Include="..\deprecated\CCBool.h" />
<ClInclude Include="..\deprecated\CCDeprecated.h" />
<ClInclude Include="..\deprecated\CCDictionary.h" />
<ClInclude Include="..\deprecated\CCDouble.h" />
<ClInclude Include="..\deprecated\CCFloat.h" />
<ClInclude Include="..\deprecated\CCInteger.h" />
<ClInclude Include="..\deprecated\CCNotificationCenter.h" />
<ClInclude Include="..\deprecated\CCSet.h" />
<ClInclude Include="..\deprecated\CCString.h" />
<ClInclude Include="..\math\kazmath\kazmath\aabb.h" />
<ClInclude Include="..\math\kazmath\kazmath\GL\mat4stack.h" />
<ClInclude Include="..\math\kazmath\kazmath\GL\matrix.h" />
@ -455,7 +457,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClInclude Include="CCMenuItem.h" />
<ClInclude Include="CCMotionStreak.h" />
<ClInclude Include="CCNode.h" />
<ClInclude Include="CCNotificationCenter.h" />
<ClInclude Include="CCParallaxNode.h" />
<ClInclude Include="CCParticleBatchNode.h" />
<ClInclude Include="CCParticleExamples.h" />

View File

@ -106,6 +106,9 @@
<Filter Include="xxhash">
<UniqueIdentifier>{b4e2b1e5-2d79-44a3-af45-728d47b7bdb2}</UniqueIdentifier>
</Filter>
<Filter Include="deprecated">
<UniqueIdentifier>{0b1152b1-c732-4560-8629-87843b0fbd7c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
@ -394,7 +397,6 @@
<Filter>tilemap_parallax_nodes</Filter>
</ClCompile>
<ClCompile Include="CCConfiguration.cpp" />
<ClCompile Include="CCDeprecated.cpp" />
<ClCompile Include="CCDirector.cpp" />
<ClCompile Include="ccFPSImages.c" />
<ClCompile Include="CCScheduler.cpp" />
@ -403,9 +405,6 @@
<ClCompile Include="base64.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="CCNotificationCenter.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="CCProfiling.cpp">
<Filter>support</Filter>
</ClCompile>
@ -448,9 +447,6 @@
<ClCompile Include="..\base\CCAffineTransform.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCArray.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCAutoreleasePool.cpp">
<Filter>base</Filter>
</ClCompile>
@ -460,9 +456,6 @@
<ClCompile Include="..\base\CCDataVisitor.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCDictionary.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCGeometry.cpp">
<Filter>base</Filter>
</ClCompile>
@ -472,12 +465,6 @@
<ClCompile Include="..\base\CCRef.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCSet.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCString.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="ccUtils.cpp">
<Filter>support</Filter>
</ClCompile>
@ -596,6 +583,24 @@
<ClCompile Include="..\..\external\xxhash\xxhash.c">
<Filter>xxhash</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCArray.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCDeprecated.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCDictionary.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCSet.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCString.cpp">
<Filter>deprecated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -980,9 +985,6 @@
<ClInclude Include="base64.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="CCNotificationCenter.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="CCProfiling.h">
<Filter>support</Filter>
</ClInclude>
@ -1034,48 +1036,24 @@
<ClInclude Include="..\base\CCAffineTransform.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCArray.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCAutoreleasePool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCBool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCData.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDataVisitor.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDictionary.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDouble.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCFloat.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCGeometry.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCInteger.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCNS.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCRef.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCSet.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCString.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="CCEventListenerMouse.h">
<Filter>event_dispatcher</Filter>
</ClInclude>
@ -1203,6 +1181,36 @@
<ClInclude Include="..\..\external\xxhash\xxhash.h">
<Filter>xxhash</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCArray.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCBool.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDeprecated.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDictionary.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDouble.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCFloat.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCInteger.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCNotificationCenter.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCSet.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCString.h">
<Filter>deprecated</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\math\kazmath\kazmath\CMakeLists.txt">

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot)cocos;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_VARIADIC_MAX=10;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot)cocos;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -210,20 +210,22 @@
</ClCompile>
<ClCompile Include="..\base\atitc.cpp" />
<ClCompile Include="..\base\CCAffineTransform.cpp" />
<ClCompile Include="..\base\CCArray.cpp" />
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
<ClCompile Include="..\base\CCConsole.cpp" />
<ClCompile Include="..\base\CCData.cpp" />
<ClCompile Include="..\base\CCDataVisitor.cpp" />
<ClCompile Include="..\base\CCDictionary.cpp" />
<ClCompile Include="..\base\CCGeometry.cpp" />
<ClCompile Include="..\base\CCNS.cpp" />
<ClCompile Include="..\base\CCRef.cpp" />
<ClCompile Include="..\base\CCSet.cpp" />
<ClCompile Include="..\base\CCString.cpp" />
<ClCompile Include="..\base\CCValue.cpp" />
<ClCompile Include="..\base\etc1.cpp" />
<ClCompile Include="..\base\s3tc.cpp" />
<ClCompile Include="..\deprecated\CCArray.cpp" />
<ClCompile Include="..\deprecated\CCDeprecated.cpp" />
<ClCompile Include="..\deprecated\CCDictionary.cpp" />
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp" />
<ClCompile Include="..\deprecated\CCSet.cpp" />
<ClCompile Include="..\deprecated\CCString.cpp" />
<ClCompile Include="..\math\kazmath\kazmath\aabb.c">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
@ -560,7 +562,6 @@
<ClCompile Include="CCComponent.cpp" />
<ClCompile Include="CCComponentContainer.cpp" />
<ClCompile Include="CCConfiguration.cpp" />
<ClCompile Include="CCDeprecated.cpp" />
<ClCompile Include="CCDirector.cpp" />
<ClCompile Include="CCDrawingPrimitives.cpp" />
<ClCompile Include="CCDrawNode.cpp" />
@ -617,7 +618,6 @@
<ClCompile Include="CCMenuItem.cpp" />
<ClCompile Include="CCMotionStreak.cpp" />
<ClCompile Include="CCNode.cpp" />
<ClCompile Include="CCNotificationCenter.cpp" />
<ClCompile Include="CCParallaxNode.cpp" />
<ClCompile Include="CCParticleBatchNode.cpp" />
<ClCompile Include="CCParticleExamples.cpp" />
@ -698,28 +698,30 @@
<ClInclude Include="..\..\external\xxhash\xxhash.h" />
<ClInclude Include="..\base\atitc.h" />
<ClInclude Include="..\base\CCAffineTransform.h" />
<ClInclude Include="..\base\CCArray.h" />
<ClInclude Include="..\base\CCAutoreleasePool.h" />
<ClInclude Include="..\base\CCBool.h" />
<ClInclude Include="..\base\CCConsole.h" />
<ClInclude Include="..\base\CCData.h" />
<ClInclude Include="..\base\CCDataVisitor.h" />
<ClInclude Include="..\base\CCDictionary.h" />
<ClInclude Include="..\base\CCDouble.h" />
<ClInclude Include="..\base\CCFloat.h" />
<ClInclude Include="..\base\CCGeometry.h" />
<ClInclude Include="..\base\CCInteger.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNS.h" />
<ClInclude Include="..\base\CCRef.h" />
<ClInclude Include="..\base\CCPlatformConfig.h" />
<ClInclude Include="..\base\CCPlatformMacros.h" />
<ClInclude Include="..\base\CCSet.h" />
<ClInclude Include="..\base\CCString.h" />
<ClInclude Include="..\base\CCValue.h" />
<ClInclude Include="..\base\CCVector.h" />
<ClInclude Include="..\base\etc1.h" />
<ClInclude Include="..\base\s3tc.h" />
<ClInclude Include="..\deprecated\CCArray.h" />
<ClInclude Include="..\deprecated\CCBool.h" />
<ClInclude Include="..\deprecated\CCDeprecated.h" />
<ClInclude Include="..\deprecated\CCDictionary.h" />
<ClInclude Include="..\deprecated\CCDouble.h" />
<ClInclude Include="..\deprecated\CCFloat.h" />
<ClInclude Include="..\deprecated\CCInteger.h" />
<ClInclude Include="..\deprecated\CCNotificationCenter.h" />
<ClInclude Include="..\deprecated\CCSet.h" />
<ClInclude Include="..\deprecated\CCString.h" />
<ClInclude Include="..\math\kazmath\kazmath\aabb.h" />
<ClInclude Include="..\math\kazmath\kazmath\GL\mat4stack.h" />
<ClInclude Include="..\math\kazmath\kazmath\GL\matrix.h" />
@ -769,7 +771,6 @@
<ClInclude Include="CCComponentContainer.h" />
<ClInclude Include="ccConfig.h" />
<ClInclude Include="CCConfiguration.h" />
<ClInclude Include="CCDeprecated.h" />
<ClInclude Include="CCDirector.h" />
<ClInclude Include="CCDrawingPrimitives.h" />
<ClInclude Include="CCDrawNode.h" />
@ -812,7 +813,6 @@
<ClInclude Include="CCMenuItem.h" />
<ClInclude Include="CCMotionStreak.h" />
<ClInclude Include="CCNode.h" />
<ClInclude Include="CCNotificationCenter.h" />
<ClInclude Include="CCParallaxNode.h" />
<ClInclude Include="CCParticleBatchNode.h" />
<ClInclude Include="CCParticleExamples.h" />

View File

@ -103,6 +103,9 @@
<Filter Include="xxhash">
<UniqueIdentifier>{a36c6808-a8d6-43f4-bfb0-e08ee2747a21}</UniqueIdentifier>
</Filter>
<Filter Include="deprecated">
<UniqueIdentifier>{5598fb0c-c012-45b6-8e43-447e7891b61d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
@ -376,7 +379,6 @@
<Filter>tilemap_parallax_nodes</Filter>
</ClCompile>
<ClCompile Include="CCConfiguration.cpp" />
<ClCompile Include="CCDeprecated.cpp" />
<ClCompile Include="CCDirector.cpp" />
<ClCompile Include="ccFPSImages.c" />
<ClCompile Include="CCScheduler.cpp" />
@ -385,9 +387,6 @@
<ClCompile Include="base64.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="CCNotificationCenter.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="CCProfiling.cpp">
<Filter>support</Filter>
</ClCompile>
@ -430,9 +429,6 @@
<ClCompile Include="..\base\CCAffineTransform.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCArray.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCAutoreleasePool.cpp">
<Filter>base</Filter>
</ClCompile>
@ -442,9 +438,6 @@
<ClCompile Include="..\base\CCDataVisitor.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCDictionary.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCGeometry.cpp">
<Filter>base</Filter>
</ClCompile>
@ -454,12 +447,6 @@
<ClCompile Include="..\base\CCRef.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCSet.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCString.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="ccUtils.cpp">
<Filter>support</Filter>
</ClCompile>
@ -611,6 +598,24 @@
<ClCompile Include="..\..\external\xxhash\xxhash.c">
<Filter>xxhash</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCArray.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCDeprecated.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCDictionary.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCSet.cpp">
<Filter>deprecated</Filter>
</ClCompile>
<ClCompile Include="..\deprecated\CCString.cpp">
<Filter>deprecated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -679,9 +684,6 @@
<ClInclude Include="ccConfig.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="CCDeprecated.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="CCEventType.h">
<Filter>include</Filter>
</ClInclude>
@ -980,9 +982,6 @@
<ClInclude Include="base64.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="CCNotificationCenter.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="CCProfiling.h">
<Filter>support</Filter>
</ClInclude>
@ -1034,48 +1033,24 @@
<ClInclude Include="..\base\CCAffineTransform.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCArray.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCAutoreleasePool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCBool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCData.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDataVisitor.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDictionary.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCDouble.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCFloat.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCGeometry.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCInteger.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCNS.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCRef.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCSet.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCString.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="CCEventListenerMouse.h">
<Filter>event_dispatcher</Filter>
</ClInclude>
@ -1239,5 +1214,35 @@
<ClInclude Include="..\..\external\xxhash\xxhash.h">
<Filter>xxhash</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCArray.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCBool.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDeprecated.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDictionary.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCDouble.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCFloat.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCInteger.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCNotificationCenter.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCSet.h">
<Filter>deprecated</Filter>
</ClInclude>
<ClInclude Include="..\deprecated\CCString.h">
<Filter>deprecated</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d\platform\wp8;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\gui;$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)cocos\math\kazmath\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d\platform\wp8;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\ui;$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\deprecated;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>

View File

@ -500,9 +500,10 @@ void FileUtils::purgeCachedEntries()
static Data getData(const std::string& filename, bool forString)
{
// getData is used indirectly in Image::initWithImageFileThreadSafe(), but CCASSERT is not thread-safe
// CCASSERT(!filename.empty(), "Invalid filename!");
assert(!(filename.empty()));
if (filename.empty())
{
return Data::Null;
}
Data ret;
unsigned char* buffer = nullptr;
@ -556,6 +557,7 @@ std::string FileUtils::getStringFromFile(const std::string& filename)
Data data = getData(filename, true);
if (data.isNull())
return "";
std::string ret((const char*)data.getBytes());
return ret;
}

View File

@ -26,10 +26,8 @@ THE SOFTWARE.
#include "CCGLViewProtocol.h"
#include "CCTouch.h"
#include "CCDirector.h"
#include "CCSet.h"
#include "CCEventDispatcher.h"
NS_CC_BEGIN
namespace {
@ -369,7 +367,7 @@ void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,
}
else
{
CCLOG("Ending touches with id: %ld error", id);
CCLOG("Ending touches with id: %ld error", static_cast<long>(id));
return;
}

View File

@ -26,6 +26,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../.. \
$(LOCAL_PATH)/../../.. \
$(LOCAL_PATH)/../../../base \
$(LOCAL_PATH)/../../../math/kazmath \
$(LOCAL_PATH)/../../../physics

View File

@ -70,7 +70,7 @@ class BitmapDC
public:
BitmapDC()
: _data(NULL)
: _data(nullptr)
, _width(0)
, _height(0)
{

View File

@ -243,6 +243,9 @@ Data FileUtilsAndroid::getData(const std::string& filename, bool forString)
std::string FileUtilsAndroid::getStringFromFile(const std::string& filename)
{
Data data = getData(filename, true);
if (data.isNull())
return "";
std::string ret((const char*)data.getBytes());
return ret;
}

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#include "CCGLView.h"
#include "CCSet.h"
#include "CCDirector.h"
#include "ccMacros.h"
#include "jni/IMEJni.h"

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include "JniHelper.h"
#include "CCFileUtilsAndroid.h"
#include "android/asset_manager_jni.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#define LOG_TAG "Java_org_cocos2dx_lib_Cocos2dxHelper.cpp"

View File

@ -21,7 +21,6 @@ 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 "CCSet.h"
#include "CCDirector.h"
#include "CCEventKeyboard.h"
#include "CCGLView.h"

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include <string>
#include <stack>
#include "CCString.h"
#include "deprecated/CCString.h"
#include "CCFileUtils.h"
#include "CCDirector.h"
#include "CCSAXParser.h"

View File

@ -24,17 +24,15 @@ THE SOFTWARE.
****************************************************************************/
#include "CCGLView.h"
#include <unordered_map>
#include "CCDirector.h"
#include "CCSet.h"
#include "CCTouch.h"
#include "CCEventDispatcher.h"
#include "CCEventKeyboard.h"
#include "CCEventMouse.h"
#include "CCIMEDispatcher.h"
#include <unordered_map>
NS_CC_BEGIN
// GLFWEventHandler
@ -260,7 +258,7 @@ GLView::GLView()
, _retinaFactor(1)
, _frameZoomFactor(1.0f)
, _mainWindow(nullptr)
, _primaryMonitor(nullptr)
, _monitor(nullptr)
, _mouseX(0.0f)
, _mouseY(0.0f)
{
@ -317,6 +315,18 @@ GLView* GLView::createWithFullScreen(const std::string& viewName)
return nullptr;
}
GLView* GLView::createWithFullScreen(const std::string& viewName, const GLFWvidmode &videoMode, GLFWmonitor *monitor)
{
auto ret = new GLView();
if(ret && ret->initWithFullscreen(viewName, videoMode, monitor)) {
ret->autorelease();
return ret;
}
return nullptr;
}
bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor)
{
setViewName(viewName);
@ -328,7 +338,7 @@ bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoo
_mainWindow = glfwCreateWindow(rect.size.width * _frameZoomFactor,
rect.size.height * _frameZoomFactor,
_viewName.c_str(),
_primaryMonitor,
_monitor,
nullptr);
glfwMakeContextCurrent(_mainWindow);
@ -366,14 +376,31 @@ bool GLView::initWithRect(const std::string& viewName, Rect rect, float frameZoo
bool GLView::initWithFullScreen(const std::string& viewName)
{
_primaryMonitor = glfwGetPrimaryMonitor();
if (nullptr == _primaryMonitor)
//Create fullscreen window on primary monitor at its current video mode.
_monitor = glfwGetPrimaryMonitor();
if (nullptr == _monitor)
return false;
const GLFWvidmode* videoMode = glfwGetVideoMode(_primaryMonitor);
const GLFWvidmode* videoMode = glfwGetVideoMode(_monitor);
return initWithRect(viewName, Rect(0, 0, videoMode->width, videoMode->height), 1.0f);
}
bool GLView::initWithFullscreen(const std::string &viewname, const GLFWvidmode &videoMode, GLFWmonitor *monitor)
{
//Create fullscreen on specified monitor at the specified video mode.
_monitor = monitor;
if (nullptr == _monitor)
return false;
//These are soft contraints. If the video mode is retrieved at runtime, the resulting window and context should match these exactly. If invalid attribs are passed (eg. from an outdated cache), window creation will NOT fail but the actual window/context may differ.
glfwWindowHint(GLFW_REFRESH_RATE, videoMode.refreshRate);
glfwWindowHint(GLFW_RED_BITS, videoMode.redBits);
glfwWindowHint(GLFW_BLUE_BITS, videoMode.blueBits);
glfwWindowHint(GLFW_GREEN_BITS, videoMode.greenBits);
return initWithRect(viewname, Rect(0, 0, videoMode.width, videoMode.height), 1.0f);
}
bool GLView::isOpenGLReady()
{
return nullptr != _mainWindow;

View File

@ -39,6 +39,7 @@ public:
static GLView* create(const std::string& viewName);
static GLView* createWithRect(const std::string& viewName, Rect size, float frameZoomFactor = 1.0f);
static GLView* createWithFullScreen(const std::string& viewName);
static GLView* createWithFullScreen(const std::string& viewName, const GLFWvidmode &videoMode, GLFWmonitor *monitor);
/*
*frameZoomFactor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
@ -82,6 +83,7 @@ protected:
bool initWithRect(const std::string& viewName, Rect rect, float frameZoomFactor);
bool initWithFullScreen(const std::string& viewName);
bool initWithFullscreen(const std::string& viewname, const GLFWvidmode &videoMode, GLFWmonitor *monitor);
bool initGlew();
@ -107,7 +109,7 @@ protected:
float _frameZoomFactor;
GLFWwindow* _mainWindow;
GLFWmonitor* _primaryMonitor;
GLFWmonitor* _monitor;
float _mouseX;
float _mouseY;

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include "platform/CCCommon.h"
#include "ccMacros.h"
#include "CCApplication.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>

View File

@ -31,11 +31,7 @@ THE SOFTWARE.
#include <string.h>
#if defined(_USRDLL)
#define CC_DLL __attribute__ ((visibility ("default")))
#else /* use a DLL library */
#define CC_DLL __attribute__ ((visibility ("default")))
#endif
#define CC_DLL
#include <assert.h>
#define CC_ASSERT(cond) assert(cond)

View File

@ -40,6 +40,7 @@ THE SOFTWARE.
#include <time.h>
#include <sys/time.h>
#include <stdint.h>
#include <limits.h>
#ifndef MIN
#define MIN(x,y) (((x) > (y)) ? (y) : (x))

View File

@ -43,10 +43,10 @@ NS_CC_BEGIN
Application * Application::sm_pSharedApplication = 0;
Application::Application()
: _instance(NULL)
, _accelTable(NULL)
: _instance(nullptr)
, _accelTable(nullptr)
{
_instance = GetModuleHandle(NULL);
_instance = GetModuleHandle(nullptr);
_animationInterval.QuadPart = 0;
CC_ASSERT(! sm_pSharedApplication);
sm_pSharedApplication = this;

View File

@ -56,10 +56,10 @@ class BitmapDC
{
public:
BitmapDC(HWND hWnd = NULL)
: _DC(NULL)
, _bmp(NULL)
: _DC(nullptr)
, _bmp(nullptr)
, _font((HFONT)GetStockObject(DEFAULT_GUI_FONT))
, _wnd(NULL)
, _wnd(nullptr)
{
_wnd = hWnd;
HDC hdc = GetDC(hWnd);

View File

@ -131,8 +131,13 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const
static Data getData(const std::string& filename, bool forString)
{
if (filename.empty())
{
return Data::Null;
}
unsigned char *buffer = nullptr;
CCASSERT(!filename.empty(), "Invalid parameters.");
size_t size = 0;
do
{
@ -195,6 +200,7 @@ std::string FileUtilsWin32::getStringFromFile(const std::string& filename)
{
return "";
}
std::string ret((const char*)data.getBytes());
return ret;
}

View File

@ -64,7 +64,7 @@ protected:
* @return Upon success, a pointer to the data is returned, otherwise NULL.
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
*/
CC_DEPRECATED_ATTRIBUTE virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override;
virtual unsigned char* getFileData(const std::string& filename, const char* mode, ssize_t * size) override;
/**
* Gets string from a file.

View File

@ -29,10 +29,11 @@ THE SOFTWARE.
#include "CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
//typedef SSIZE_T ssize_t;
// ssize_t was redefined as int in libwebsockets.h.
// Therefore, to avoid conflict, we needs the same definition.
typedef int ssize_t;
#include <BaseTsd.h>
#ifndef __SSIZE_T
#define __SSIZE_T
typedef SSIZE_T ssize_t;
#endif // __SSIZE_T
#include "CCPlatformMacros.h"
#include <float.h>

View File

@ -32,11 +32,12 @@ THE SOFTWARE.
#include "CCPlatformMacros.h"
#include <float.h>
#include <BaseTsd.h>
//typedef SSIZE_T ssize_t;
// ssize_t was redefined as int in libwebsockets.h.
// Therefore, to avoid conflict, we needs the same definition.
typedef int ssize_t;
#ifndef __SSIZE_T
#define __SSIZE_T
typedef SSIZE_T ssize_t;
#endif // __SSIZE_T
// for math.h on win32 platform

View File

@ -36,11 +36,12 @@ static void convertIntToByteArray(int value, int* output)
}
QuadCommand::QuadCommand()
:_textureID(0)
,_blendType(BlendFunc::DISABLE)
,_quadsCount(0)
:_materialID(0)
,_textureID(0)
,_shader(nullptr)
,_blendType(BlendFunc::DISABLE)
,_quads(nullptr)
,_quadsCount(0)
{
_type = RenderCommand::Type::QUAD_COMMAND;
}
@ -49,21 +50,18 @@ void QuadCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, B
{
_globalOrder = globalOrder;
_textureID = textureID;
_blendType = blendType;
_shader = shader;
_quadsCount = quadCount;
_quads = quad;
_mv = mv;
if( _textureID != _lastTextureID || _blendType.src != _lastBlendType.src || _blendType.dst != _lastBlendType.dst || _shader != _lastShader) {
generateMaterialID();
if( _textureID != textureID || _blendType.src != blendType.src || _blendType.dst != blendType.dst || _shader != shader) {
_lastShader = _shader;
_lastBlendType = _blendType;
_lastTextureID = _textureID;
_textureID = textureID;
_blendType = blendType;
_shader = shader;
generateMaterialID();
}
}

View File

@ -73,13 +73,10 @@ protected:
uint32_t _materialID;
GLuint _textureID;
GLuint _lastTextureID;
GLProgram* _shader;
GLProgram* _lastShader;
BlendFunc _blendType;
BlendFunc _lastBlendType;
V3F_C4B_T2F_Quad* _quads;
ssize_t _quadsCount;

View File

@ -68,17 +68,17 @@ void RenderQueue::sort()
RenderCommand* RenderQueue::operator[](ssize_t index) const
{
if(index < _queueNegZ.size())
if(index < static_cast<ssize_t>(_queueNegZ.size()))
return _queueNegZ[index];
index -= _queueNegZ.size();
if(index < _queue0.size())
if(index < static_cast<ssize_t>(_queue0.size()))
return _queue0[index];
index -= _queue0.size();
if(index < _queuePosZ.size())
if(index < static_cast<ssize_t>(_queuePosZ.size()))
return _queuePosZ[index];
CCASSERT(false, "invalid index");

View File

@ -12,6 +12,7 @@ LOCAL_SRC_FILES := cddSimpleAudioEngine.cpp \
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../.. \
$(LOCAL_PATH)/../../math/kazmath \
$(LOCAL_PATH)/../../2d \
$(LOCAL_PATH)/../../2d/platform/android \

View File

@ -48,6 +48,7 @@
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ioctl.h>
#endif
#include "CCDirector.h"
@ -650,7 +651,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 ((unsigned)time(NULL));
srand ((unsigned)time(nullptr));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();
sched->performFunctionInCocosThread( [&](){
@ -678,7 +679,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 ((unsigned)time(NULL));
srand ((unsigned)time(nullptr));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();
@ -844,7 +845,8 @@ void Console::commandUpload(int fd)
ssize_t Console::readBytes(int fd, char* buffer, size_t maxlen, bool* more)
{
ssize_t n, rc;
size_t n;
int rc;
char c, *ptr = buffer;
*more = false;
for( n = 0; n < maxlen; n++ ) {
@ -927,7 +929,7 @@ bool Console::parseCommand(int fd)
if(it != _commands.end())
{
std::string args2;
for(int i = 1; i < args.size(); ++i)
for(size_t i = 1; i < args.size(); ++i)
{
if(i > 1)
{
@ -954,7 +956,8 @@ bool Console::parseCommand(int fd)
ssize_t Console::readline(int fd, char* ptr, size_t maxlen)
{
ssize_t n, rc;
size_t n;
int rc;
char c;
for( n = 0; n < maxlen - 1; n++ ) {
@ -1056,6 +1059,19 @@ void Console::loop()
for(const auto &fd: _fds) {
if(FD_ISSET(fd,&copy_set))
{
//fix Bug #4302 Test case ConsoleTest--ConsoleUploadFile crashed on Linux
//On linux, if you send data to a closed socket, the sending process will
//receive a SIGPIPE, which will cause linux system shutdown the sending process.
//Add this ioctl code to check if the socket has been closed by peer.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
int n = 0;
ioctl(fd, FIONREAD, &n);
if(n == 0)
{
//no data received, or fd is closed
continue;
}
#endif
if( ! parseCommand(fd) )
{
to_remove.push_back(fd);

View File

@ -29,10 +29,12 @@
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <BaseTsd.h>
#include <WinSock2.h>
//typedef SSIZE_T ssize_t;
// ssize_t was redefined as int in libwebsockets.h.
// Therefore, to avoid conflict, we needs the same definition.
typedef int ssize_t;
#ifndef __SSIZE_T
#define __SSIZE_T
typedef SSIZE_T ssize_t;
#endif // __SSIZE_T
#else
#include <sys/select.h>
#endif

View File

@ -23,14 +23,14 @@
****************************************************************************/
#include "CCRef.h"
#include "CCBool.h"
#include "CCInteger.h"
#include "CCFloat.h"
#include "CCDouble.h"
#include "CCString.h"
#include "CCArray.h"
#include "CCDictionary.h"
#include "CCSet.h"
#include "deprecated/CCBool.h"
#include "deprecated/CCInteger.h"
#include "deprecated/CCFloat.h"
#include "deprecated/CCDouble.h"
#include "deprecated/CCString.h"
#include "deprecated/CCArray.h"
#include "deprecated/CCDictionary.h"
#include "deprecated/CCSet.h"
NS_CC_BEGIN

View File

@ -1,13 +1,13 @@
set(COCOS_BASE_SRC
../deprecated/CCSet.cpp
../deprecated/CCArray.cpp
../deprecated/CCDictionary.cpp
../deprecated/CCString.cpp
CCAffineTransform.cpp
CCAutoreleasePool.cpp
CCGeometry.cpp
CCNS.cpp
CCRef.cpp
CCSet.cpp
CCArray.cpp
CCDictionary.cpp
CCString.cpp
CCDataVisitor.cpp
CCData.cpp
CCValue.cpp

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
****************************************************************************/
#include "CCArray.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "platform/CCFileUtils.h"
NS_CC_BEGIN
@ -37,7 +37,7 @@ NS_CC_BEGIN
// ----------------------------------------------------------------------------------
__Array::__Array()
: data(NULL)
: data(nullptr)
{
init();
}

View File

@ -24,10 +24,10 @@
****************************************************************************/
#include "CCDictionary.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "CCInteger.h"
#include "platform/CCFileUtils.h"
#include "CCString.h"
#include "deprecated/CCString.h"
#include "CCBool.h"
#include "CCInteger.h"
#include "CCFloat.h"
@ -77,7 +77,7 @@ DictElement::~DictElement()
// __Dictionary
__Dictionary::__Dictionary()
: _elements(NULL)
: _elements(nullptr)
, _dictType(kDictUnknown)
{

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include "uthash.h"
#include "CCRef.h"
#include "CCArray.h"
#include "CCString.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
****************************************************************************/
#include "CCNotificationCenter.h"
#include "CCArray.h"
#include "deprecated/CCArray.h"
#include "CCScriptSupport.h"
#include <string>

View File

@ -28,12 +28,13 @@ THE SOFTWARE.
#define __CCNOTIFICATIONCENTER_H__
#include "CCRef.h"
#include "CCArray.h"
#include "ccTypes.h"
NS_CC_BEGIN
class __Array;
class ScriptHandlerMgr;
class CC_DLL __NotificationCenter : public Ref
{
friend class ScriptHandlerMgr;

Some files were not shown because too many files have changed in this diff Show More