Remove cocos studio limitation for new functions

This commit is contained in:
XiaoFeng 2015-11-16 11:08:20 +08:00
parent 140eaf7b6c
commit d47a79c0e4
25 changed files with 24 additions and 109 deletions

View File

@ -481,11 +481,9 @@ void Camera::setBackgroundBrush(CameraBackgroundBrush* clearBrush)
_clearBrush = clearBrush;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool Camera::isBrushValid()
{
return _clearBrush != nullptr && _clearBrush->isValid();
}
#endif
NS_CC_END

View File

@ -58,12 +58,12 @@ enum class CameraFlag
USER6 = 1 << 6,
USER7 = 1 << 7,
USER8 = 1 << 8,
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
// Use in cocos studio for edit 3d relate component
SkyBox = 1 << 10,
DEFAULTCAMERA = DEFAULT | SkyBox,
PIXEL = 1 << 13,
FRONT = 1 << 14,
#endif
};
/**
* Defines a camera .
@ -278,9 +278,7 @@ public:
virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool isBrushValid();
#endif
CC_CONSTRUCTOR_ACCESS:
Camera();

View File

@ -232,10 +232,8 @@ CameraBackgroundSkyBoxBrush::CameraBackgroundSkyBoxBrush()
, _vertexBuffer(0)
, _indexBuffer(0)
, _texture(nullptr)
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
, _actived(false)
, _textureValid(false)
#endif
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
_backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
@ -300,10 +298,8 @@ CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create()
void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera)
{
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (!_actived)
return;
#endif
Mat4 cameraModelMat = camera->getNodeToWorldTransform();
@ -436,7 +432,6 @@ void CameraBackgroundSkyBoxBrush::setTexture(TextureCube* texture)
_glProgramState->setUniformTexture("u_Env", _texture);
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool CameraBackgroundSkyBoxBrush::isActived() const
{
return _actived;
@ -455,6 +450,5 @@ bool CameraBackgroundSkyBoxBrush::isValid()
{
return _actived;
}
#endif
NS_CC_END

View File

@ -104,9 +104,7 @@ public:
*/
virtual void drawBackground(Camera* camera) {}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
virtual bool isValid() { return true; }
#endif
CC_CONSTRUCTOR_ACCESS :
CameraBackgroundBrush();
@ -241,12 +239,10 @@ public:
*/
virtual void drawBackground(Camera* camera) override;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool isActived() const;
void setActived(bool actived);
virtual void setTextureValid(bool valid);
virtual bool isValid()override;
#endif
CC_CONSTRUCTOR_ACCESS :
CameraBackgroundSkyBoxBrush();
@ -270,11 +266,9 @@ protected:
EventListenerCustom* _backToForegroundListener;
#endif
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
private:
bool _actived;
bool _textureValid;
#endif
};
NS_CC_END

View File

@ -53,17 +53,10 @@ void ClippingRectangleNode::onBeforeVisitScissor()
const Point pos = convertToWorldSpace(Point(_clippingRegion.origin.x, _clippingRegion.origin.y));
GLView* glView = Director::getInstance()->getOpenGLView();
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
glView->setScissorInPoints(pos.x * scaleX,
pos.y * scaleY,
_clippingRegion.size.width * scaleX,
_clippingRegion.size.height * scaleY);
#else
glView->setScissorInPoints(pos.x,
pos.y,
_clippingRegion.size.width * scaleX,
_clippingRegion.size.height * scaleY);
#endif
}
}

View File

@ -130,9 +130,7 @@ DrawNode::DrawNode()
, _dirtyGLPoint(false)
, _dirtyGLLine(false)
, _lineWidth(DEFAULT_LINE_WIDTH)
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
, _lineSmoothEnable(false)
#endif
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
}
@ -405,13 +403,13 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
// texcood
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (this->_lineSmoothEnable == false)
{
glDisable(GL_MULTISAMPLE);
glDisable(GL_LINE_SMOOTH);
}
#endif
glLineWidth(_lineWidth);
glDrawArrays(GL_LINES, 0, _bufferCountGLLine);
@ -423,10 +421,8 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLLine);
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (this->_lineSmoothEnable == true)
glEnable(GL_MULTISAMPLE);
#endif
CHECK_GL_ERROR_DEBUG();
}
@ -965,7 +961,6 @@ void DrawNode::setLineWidth(int lineWidth)
_lineWidth = lineWidth;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void DrawNode::setLineSmooth(bool enable)
{
this->_lineSmoothEnable = enable;
@ -980,6 +975,5 @@ float DrawNode::getLineWidth()
{
return this->_lineWidth;
}
#endif
NS_CC_END

View File

@ -313,7 +313,6 @@ public:
void setLineWidth(int lineWidth);
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
// Set enable or disable multisampling effect on CocosStudio guide lines.
void setLineSmooth(bool enable);
@ -322,7 +321,6 @@ public:
// Get CocosStudio guide lines width.
float getLineWidth();
#endif
CC_CONSTRUCTOR_ACCESS:
DrawNode();
@ -366,9 +364,7 @@ protected:
int _lineWidth;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool _lineSmoothEnable;
#endif
private:
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode);

View File

@ -238,7 +238,6 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
return false;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void FontAtlasCache::reloadFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset/* = Vec2::ZERO*/)
{
std::string atlasName = generateFontName(fontFileName, 0, false);
@ -276,6 +275,5 @@ void FontAtlasCache::unloadFontAtlasTTF(const std::string& fontFileName)
item++;
}
}
#endif
NS_CC_END

View File

@ -54,10 +54,8 @@ public:
*/
static void purgeCachedData();
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
static void reloadFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset = Vec2::ZERO);
static void unloadFontAtlasTTF(const std::string& fontFileName);
#endif
private:
static std::string generateFontName(const std::string& fontFileName, float size, bool useDistanceField);

View File

@ -783,7 +783,6 @@ FontAtlas * FontFNT::createFontAtlas()
return tempAtlas;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void FontFNT::reloadBMFontResource(const std::string& fntFilePath)
{
if (s_configurations == nullptr)
@ -804,6 +803,5 @@ void FontFNT::reloadBMFontResource(const std::string& fntFilePath)
}
}
#endif
NS_CC_END

View File

@ -47,9 +47,7 @@ public:
virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override;
virtual FontAtlas *createFontAtlas() override;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
static void reloadBMFontResource(const std::string& fntFilePath);
#endif
protected:

View File

@ -634,7 +634,6 @@ const char* FontFreeType::getGlyphCollection() const
return glyphCollection;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void FontFreeType::releaseFont(const std::string &fontName)
{
auto item = s_cacheFontData.begin();
@ -646,6 +645,5 @@ void FontFreeType::releaseFont(const std::string &fontName)
item++;
}
}
#endif
NS_CC_END

View File

@ -75,9 +75,7 @@ public:
virtual FontAtlas* createFontAtlas() override;
virtual int getFontMaxHeight() const override { return _lineHeight; }
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
static void releaseFont(const std::string &fontName);
#endif
private:
static const char* _glyphASCII;

View File

@ -38,10 +38,6 @@
#include "2d/CCComponentContainer.h"
#include "2d/CCComponent.h"
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
#include "CocosStudioExtension.h"
#endif
NS_CC_BEGIN
class GridBase;

View File

@ -54,6 +54,7 @@ THE SOFTWARE.
#include "renderer/CCTextureCache.h"
#include "deprecated/CCString.h"
#include "platform/CCFileUtils.h"
#include "2d/CocosStudioExtension.h"
using namespace std;
@ -1332,14 +1333,12 @@ void ParticleSystem::setScaleY(float newScaleY)
Node::setScaleY(newScaleY);
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
ResouceData ParticleSystem::csGetRenderFile()
ResouceData ParticleSystem::getRenderFile()
{
ResouceData rData;
rData.type = 0;
rData.file = _plistFile;
return rData;
}
#endif
NS_CC_END

View File

@ -33,6 +33,8 @@ THE SOFTWARE.
NS_CC_BEGIN
struct CC_DLL ResouceData;
/**
* @addtogroup _2d
* @{
@ -761,9 +763,7 @@ public:
*/
virtual const BlendFunc &getBlendFunc() const override;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
ResouceData csGetRenderFile();
#endif
ResouceData getRenderFile();
CC_CONSTRUCTOR_ACCESS:
/**

View File

@ -109,11 +109,7 @@ public:
* @param renderer The renderer use to render the scene.
* @js NA
*/
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
virtual void render(Renderer* renderer);
#else
void render(Renderer* renderer);
#endif
/** override function */
virtual void removeAllChildren() override;

View File

@ -38,6 +38,7 @@ THE SOFTWARE.
#include "renderer/CCRenderer.h"
#include "base/CCDirector.h"
#include "2d/CCCamera.h"
#include "2d/CocosStudioExtension.h"
#include "deprecated/CCString.h"
@ -166,7 +167,10 @@ bool Sprite::initWithFile(const std::string& filename)
{
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (filename.empty())
{
CCLOG("Call Sprite::initWithFile with blank resource filename.");
return false;
}
_fileName = filename;
_fileType = 0;
@ -1163,19 +1167,17 @@ void Sprite::setPolygonInfo(const PolygonInfo& info)
_polyInfo = info;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void Sprite::setOffsetPosFromCenter(Vec2 offsetFromCenter)
{
_unflippedOffsetPositionFromCenter = offsetFromCenter;
}
ResouceData Sprite::csGetRenderFile()
ResouceData Sprite::getRenderFile()
{
ResouceData rData;
rData.type = (int)_fileType;
rData.file = _fileName;
return rData;
}
#endif
NS_CC_END

View File

@ -46,6 +46,7 @@ class Rect;
class Size;
class Texture2D;
struct transformValues_;
struct CC_DLL ResouceData;
#ifdef SPRITE_RENDER_IN_SUBPIXEL
#undef SPRITE_RENDER_IN_SUBPIXEL
@ -461,10 +462,8 @@ public:
virtual bool isOpacityModifyRGB() const override;
/// @}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
ResouceData csGetRenderFile();
ResouceData getRenderFile();
void setOffsetPosFromCenter(Vec2 offsetFromCenter);
#endif
CC_CONSTRUCTOR_ACCESS :
/**
@ -640,10 +639,8 @@ protected:
bool _insideBounds; /// whether or not the sprite was inside bounds the previous frame
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
std::string _fileName;
int _fileType;
#endif
private:
CC_DISALLOW_COPY_AND_ASSIGN(Sprite);

View File

@ -150,10 +150,8 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
Version 3 with TexturePacker 4.0 polygon mesh packing
*/
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (dictionary["frames"].getType() != cocos2d::Value::Type::MAP)
return;
#endif
ValueMap& framesDict = dictionary["frames"].asValueMap();
int format = 0;
@ -497,10 +495,8 @@ void SpriteFrameCache::removeSpriteFramesFromFileContent(const std::string& plis
void SpriteFrameCache::removeSpriteFramesFromDictionary(ValueMap& dictionary)
{
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
if (dictionary["frames"].getType() != cocos2d::Value::Type::MAP)
return;
#endif
ValueMap framesDict = dictionary["frames"].asValueMap();
std::vector<std::string> keysToRemove;
@ -552,7 +548,6 @@ SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name)
return frame;
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D *texture)
{
ValueMap& framesDict = dictionary["frames"].asValueMap();
@ -725,6 +720,5 @@ bool SpriteFrameCache::reloadTexture(const std::string& plist)
}
return true;
}
#endif
NS_CC_END

View File

@ -236,9 +236,7 @@ public:
/** @deprecated use getSpriteFrameByName() instead */
CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const std::string&name) { return getSpriteFrameByName(name); }
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
bool reloadTexture(const std::string& plist);
#endif
protected:
// MARMALADE: Made this protected not private, as deriving from this class is pretty useful
@ -264,9 +262,7 @@ protected:
const std::vector<int> &triangleIndices,
PolygonInfo &polygonInfo);
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
void reloadSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D *texture);
#endif
Map<std::string, SpriteFrame*> _spriteFrames;
ValueMap _spriteFramesAliases;

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include "2d/CCTMXLayer.h"
#include "2d/CCSprite.h"
#include "deprecated/CCString.h" // For StringUtils::format
#include "2d/CocosStudioExtension.h"
NS_CC_BEGIN
@ -62,9 +63,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
{
CCASSERT(tmxFile.size()>0, "TMXTiledMap: tmx file should not be empty");
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
_tmxFile = tmxFile;
#endif
setContentSize(Size::ZERO);
@ -82,9 +81,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile)
bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath)
{
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
_tmxFile = tmxString;
#endif
setContentSize(Size::ZERO);
@ -99,10 +96,8 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r
TMXTiledMap::TMXTiledMap()
:_mapSize(Size::ZERO)
,_tileSize(Size::ZERO)
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
,_tmxFile("")
, _tmxLayerNum(0)
#endif
{
}
@ -208,9 +203,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
idx++;
}
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
_tmxLayerNum = idx;
#endif
}
// public
@ -286,19 +279,17 @@ std::string TMXTiledMap::getDescription() const
return StringUtils::format("<TMXTiledMap | Tag = %d, Layers = %d", _tag, static_cast<int>(_children.size()));
}
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
int TMXTiledMap::getLayerNum()
{
return _tmxLayerNum;
}
ResouceData TMXTiledMap::csGetRenderFile()
ResouceData TMXTiledMap::getRenderFile()
{
ResouceData rData;
rData.type = 0;
rData.file = _tmxFile;
return rData;
}
#endif
NS_CC_END

View File

@ -37,6 +37,7 @@ class TMXLayer;
class TMXLayerInfo;
class TMXTilesetInfo;
class TMXMapInfo;
struct CC_DLL ResouceData;
/**
* @addtogroup _2d
@ -252,10 +253,8 @@ public:
*/
virtual std::string getDescription() const override;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
ResouceData csGetRenderFile();
ResouceData getRenderFile();
int getLayerNum();
#endif
CC_CONSTRUCTOR_ACCESS:
/**
@ -293,10 +292,8 @@ protected:
//! tile properties
ValueMapIntKey _tileProperties;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
std::string _tmxFile;
int _tmxLayerNum;
#endif
static const int TMXLayerTag = 32768;

View File

@ -266,9 +266,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
std::string externalTilesetFilename = attributeDict["source"].asString();
if (externalTilesetFilename != "")
{
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
_externalTilesetFilename = externalTilesetFilename;
#endif
// Tileset file will be relative to the map file. So we need to convert it to an absolute path
if (_TMXFileName.find_last_of("/") != string::npos)
{
@ -391,9 +390,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
// build full path
std::string imagename = attributeDict["source"].asString();
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
tileset->_originSourceImage = imagename;
#endif
if (_TMXFileName.find_last_of("/") != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);

View File

@ -139,10 +139,8 @@ public:
std::string _sourceImage;
//! size in pixels of the image
Size _imageSize;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
std::string _sourceImage;
std::string _originSourceImage;
#endif
public:
/**
* @js ctor
@ -283,9 +281,7 @@ public:
inline void setCurrentString(const std::string& currentString){ _currentString = currentString; }
inline const std::string& getTMXFileName() const { return _TMXFileName; }
inline void setTMXFileName(const std::string& fileName){ _TMXFileName = fileName; }
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
inline const std::string& getExternalTilesetFileName(){ return _externalTilesetFilename; }
#endif
inline const std::string& getExternalTilesetFileName() const { return _externalTilesetFilename; }
protected:
void internalInit(const std::string& tmxFileName, const std::string& resourcePath);
@ -325,9 +321,7 @@ protected:
ValueMapIntKey _tileProperties;
int _currentFirstGID;
bool _recordFirstGID;
#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only
std::string _externalTilesetFilename;
#endif
};
// end of tilemap_parallax_nodes group