2012-05-31 07:51:33 +08:00
|
|
|
#include "CCBReader.h"
|
|
|
|
|
2012-06-14 06:25:59 +08:00
|
|
|
#include <algorithm>
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
#include "CCNodeLoader.h"
|
2012-06-06 08:15:28 +08:00
|
|
|
#include "CCNodeLoaderLibrary.h"
|
2012-06-13 02:59:49 +08:00
|
|
|
#include "CCNodeLoaderListener.h"
|
|
|
|
#include "CCBMemberVariableAssigner.h"
|
|
|
|
#include "CCBSelectorResolver.h"
|
2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBAnimationManager.h"
|
|
|
|
#include "CCBSequenceProperty.h"
|
|
|
|
#include "CCBKeyframe.h"
|
|
|
|
#include "CCBValue.h"
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-08-18 05:45:21 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
using namespace std;
|
2013-10-15 18:00:03 +08:00
|
|
|
using namespace cocos2d;
|
|
|
|
using namespace cocos2d::extension;
|
2012-09-24 11:47:33 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocosbuilder {;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
/*************************************************************************
|
|
|
|
Implementation of CCBFile
|
|
|
|
*************************************************************************/
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
CCBFile::CCBFile():_CCBFileNode(NULL) {}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBFile* CCBFile::create()
|
|
|
|
{
|
|
|
|
CCBFile *ret = new CCBFile();
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBFile::getCCBFileNode()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _CCBFileNode;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void CCBFile::setCCBFileNode(Node *pNode)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
CC_SAFE_RELEASE(_CCBFileNode);
|
|
|
|
_CCBFileNode = pNode;
|
|
|
|
CC_SAFE_RETAIN(_CCBFileNode);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Implementation of CCBReader
|
|
|
|
*************************************************************************/
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, NodeLoaderListener * pNodeLoaderListener)
|
2013-07-27 22:31:57 +08:00
|
|
|
: _data(NULL)
|
|
|
|
, _bytes(NULL)
|
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
|
|
|
, _owner(NULL)
|
|
|
|
, _actionManager(NULL)
|
|
|
|
, _actionManagers(NULL)
|
|
|
|
, _animatedProps(NULL)
|
|
|
|
, _ownerOutletNodes(NULL)
|
|
|
|
, _nodesWithAnimationManagers(NULL)
|
|
|
|
, _animationManagersForNodes(NULL)
|
|
|
|
, _ownerCallbackNodes(NULL)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_nodeLoaderLibrary = pNodeLoaderLibrary;
|
|
|
|
this->_nodeLoaderLibrary->retain();
|
|
|
|
this->_CCBMemberVariableAssigner = pCCBMemberVariableAssigner;
|
|
|
|
this->_CCBSelectorResolver = pCCBSelectorResolver;
|
|
|
|
this->_nodeLoaderListener = pNodeLoaderListener;
|
2012-11-26 21:51:05 +08:00
|
|
|
init();
|
2012-06-01 05:57:13 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
CCBReader::CCBReader(CCBReader * ccbReader)
|
2013-07-27 22:31:57 +08:00
|
|
|
: _data(NULL)
|
|
|
|
, _bytes(NULL)
|
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
|
|
|
, _owner(NULL)
|
|
|
|
, _actionManager(NULL)
|
|
|
|
, _actionManagers(NULL)
|
|
|
|
, _animatedProps(NULL)
|
|
|
|
, _ownerOutletNodes(NULL)
|
|
|
|
, _nodesWithAnimationManagers(NULL)
|
|
|
|
, _animationManagersForNodes(NULL)
|
|
|
|
, _ownerCallbackNodes(NULL)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets;
|
|
|
|
this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary;
|
|
|
|
this->_nodeLoaderLibrary->retain();
|
|
|
|
|
|
|
|
this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner;
|
|
|
|
this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver;
|
|
|
|
this->_nodeLoaderListener = ccbReader->_nodeLoaderListener;
|
2013-06-27 09:41:38 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_CCBRootPath = ccbReader->getCCBRootPath();
|
2013-06-27 09:41:38 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
init();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCBReader::CCBReader()
|
2013-07-27 22:31:57 +08:00
|
|
|
: _data(NULL)
|
|
|
|
, _bytes(NULL)
|
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
|
|
|
, _owner(NULL)
|
|
|
|
, _actionManager(NULL)
|
|
|
|
, _actionManagers(NULL)
|
|
|
|
, _nodeLoaderLibrary(NULL)
|
|
|
|
, _nodeLoaderListener(NULL)
|
|
|
|
, _CCBMemberVariableAssigner(NULL)
|
|
|
|
, _CCBSelectorResolver(NULL)
|
|
|
|
, _nodesWithAnimationManagers(NULL)
|
|
|
|
, _animationManagersForNodes(NULL)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
CCBReader::~CCBReader()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
CC_SAFE_RELEASE_NULL(_owner);
|
|
|
|
CC_SAFE_RELEASE_NULL(_data);
|
2012-06-14 15:01:01 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_nodeLoaderLibrary->release();
|
2012-06-14 15:01:01 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
CC_SAFE_RELEASE(_ownerOutletNodes);
|
|
|
|
_ownerOutletNames.clear();
|
|
|
|
CC_SAFE_RELEASE(_ownerCallbackNodes);
|
|
|
|
_ownerCallbackNames.clear();
|
2013-08-12 11:18:07 +08:00
|
|
|
CC_SAFE_RELEASE(_ownerOwnerCallbackControlEvents);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Clear string cache.
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_stringCache.clear();
|
|
|
|
CC_SAFE_RELEASE(_nodesWithAnimationManagers);
|
|
|
|
CC_SAFE_RELEASE(_animationManagersForNodes);
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
setAnimationManager(NULL);
|
2012-06-14 15:01:01 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
void CCBReader::setCCBRootPath(const char* ccbRootPath)
|
2012-12-03 18:27:50 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
CCASSERT(ccbRootPath != NULL, "");
|
|
|
|
_CCBRootPath = ccbRootPath;
|
2012-12-03 18:27:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& CCBReader::getCCBRootPath() const
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _CCBRootPath;
|
2012-12-03 18:27:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
bool CCBReader::init()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-08-12 11:18:07 +08:00
|
|
|
_ownerOutletNodes = new Array();
|
2013-08-22 10:15:47 +08:00
|
|
|
_ownerOutletNodes->init();
|
2013-08-12 11:18:07 +08:00
|
|
|
_ownerCallbackNodes = new Array();
|
2013-08-22 10:15:47 +08:00
|
|
|
_ownerCallbackNodes->init();
|
2013-08-12 11:18:07 +08:00
|
|
|
_ownerOwnerCallbackControlEvents = new Array();
|
2013-08-22 10:15:47 +08:00
|
|
|
_ownerOwnerCallbackControlEvents->init();
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Setup action manager
|
|
|
|
CCBAnimationManager *pActionManager = new CCBAnimationManager();
|
|
|
|
setAnimationManager(pActionManager);
|
|
|
|
pActionManager->release();
|
|
|
|
|
|
|
|
// Setup resolution scale and container size
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBAnimationManager* CCBReader::getAnimationManager()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _actionManager;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
CC_SAFE_RELEASE(_actionManager);
|
|
|
|
_actionManager = pAnimationManager;
|
|
|
|
CC_SAFE_RETAIN(_actionManager);
|
2012-06-12 09:31:11 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Dictionary* CCBReader::getAnimationManagers()
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _actionManagers;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void CCBReader::setAnimationManagers(Dictionary* x)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManagers = x;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() {
|
2013-07-27 22:31:57 +08:00
|
|
|
return this->_CCBMemberVariableAssigner;
|
2012-06-05 06:52:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCBSelectorResolver * CCBReader::getCCBSelectorResolver() {
|
2013-07-27 22:31:57 +08:00
|
|
|
return this->_CCBSelectorResolver;
|
2012-06-05 06:52:49 +08:00
|
|
|
}
|
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
set<string>* CCBReader::getAnimatedProperties()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _animatedProps;
|
2012-06-05 07:16:42 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
set<string>& CCBReader::getLoadedSpriteSheet()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _loadedSpriteSheets;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Object* CCBReader::getOwner()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _owner;
|
2012-06-14 15:01:01 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
return this->readNodeGraphFromFile(pCCBFileName, NULL);
|
2012-06-14 15:01:01 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, Object* pOwner)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
return this->readNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize());
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2012-06-12 09:31:11 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-30 14:16:38 +08:00
|
|
|
if (NULL == pCCBFileName || strlen(pCCBFileName) == 0)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string strCCBFileName(pCCBFileName);
|
|
|
|
std::string strSuffix(".ccbi");
|
|
|
|
// Add ccbi suffix
|
|
|
|
if (!CCBReader::endsWith(strCCBFileName.c_str(), strSuffix.c_str()))
|
|
|
|
{
|
|
|
|
strCCBFileName += strSuffix;
|
|
|
|
}
|
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
std::string strPath = FileUtils::getInstance()->fullPathForFilename(strCCBFileName.c_str());
|
2013-11-06 09:36:44 +08:00
|
|
|
long size = 0;
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
unsigned char * pBytes = FileUtils::getInstance()->getFileData(strPath.c_str(), "rb", &size);
|
2013-06-20 14:15:53 +08:00
|
|
|
Data *data = new Data(pBytes, size);
|
2012-11-27 10:26:40 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(pBytes);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *ret = this->readNodeGraphFromData(data, pOwner, parentSize);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
data->release();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-14 15:01:01 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &parentSize)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_data = pData;
|
|
|
|
CC_SAFE_RETAIN(_data);
|
|
|
|
_bytes =_data->getBytes();
|
|
|
|
_currentByte = 0;
|
|
|
|
_currentBit = 0;
|
|
|
|
_owner = pOwner;
|
|
|
|
CC_SAFE_RETAIN(_owner);
|
|
|
|
|
|
|
|
_actionManager->setRootContainerSize(parentSize);
|
|
|
|
_actionManager->_owner = _owner;
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Dictionary* animationManagers = Dictionary::create();
|
|
|
|
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-10-19 16:48:57 +08:00
|
|
|
if (pNodeGraph && _actionManager->getAutoPlaySequenceId() != -1)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
// Auto play animations
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
// Assign actionManagers to userObject
|
2013-08-12 11:18:07 +08:00
|
|
|
if(_jsControlled)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_nodesWithAnimationManagers = new Array();
|
2013-08-22 10:15:47 +08:00
|
|
|
_nodesWithAnimationManagers->init();
|
2013-07-27 22:31:57 +08:00
|
|
|
_animationManagersForNodes = new Array();
|
2013-08-22 10:15:47 +08:00
|
|
|
_animationManagersForNodes->init();
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
DictElement* pElement = NULL;
|
2012-11-26 21:51:05 +08:00
|
|
|
CCDICT_FOREACH(animationManagers, pElement)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* pNode = (Node*)pElement->getIntKey();
|
2013-07-09 14:40:43 +08:00
|
|
|
CCBAnimationManager* manager = static_cast<CCBAnimationManager*>(animationManagers->objectForKey((intptr_t)pNode));
|
2013-01-23 15:14:40 +08:00
|
|
|
pNode->setUserObject(manager);
|
2012-12-04 18:44:32 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if (_jsControlled)
|
2012-12-04 18:44:32 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_nodesWithAnimationManagers->addObject(pNode);
|
|
|
|
_animationManagersForNodes->addObject(manager);
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return pNodeGraph;
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
return createSceneWithNodeGraphFromFile(pCCBFileName, NULL);
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
return createSceneWithNodeGraphFromFile(pCCBFileName, pOwner, Director::getInstance()->getWinSize());
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Object *pOwner, const Size &parentSize)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *pNode = readNodeGraphFromFile(pCCBFileName, pOwner, parentSize);
|
|
|
|
Scene *pScene = Scene::create();
|
2012-09-17 14:27:17 +08:00
|
|
|
pScene->addChild(pNode);
|
|
|
|
|
|
|
|
return pScene;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void CCBReader::cleanUpNodeGraph(Node *pNode)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
pNode->setUserObject(NULL);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Object *pChild = NULL;
|
2012-09-17 14:27:17 +08:00
|
|
|
CCARRAY_FOREACH(pNode->getChildren(), pChild)
|
|
|
|
{
|
2013-07-09 14:29:51 +08:00
|
|
|
cleanUpNodeGraph(static_cast<Node*>(pChild));
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node* CCBReader::readFileWithCleanUp(bool bCleanUp, Dictionary* am)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
if (! readHeader())
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! readStringCache())
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! readSequences())
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-28 11:49:20 +08:00
|
|
|
setAnimationManagers(am);
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *pNode = readNodeGraph(NULL);
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManagers->setObject(_actionManager, intptr_t(pNode));
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
if (bCleanUp)
|
|
|
|
{
|
|
|
|
cleanUpNodeGraph(pNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pNode;
|
|
|
|
}
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
bool CCBReader::readStringCache() {
|
|
|
|
int numStrings = this->readInt(false);
|
|
|
|
|
|
|
|
for(int i = 0; i < numStrings; i++) {
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_stringCache.push_back(this->readUTF8());
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
bool CCBReader::readHeader()
|
|
|
|
{
|
|
|
|
/* If no bytes loaded, don't crash about it. */
|
2013-07-27 22:31:57 +08:00
|
|
|
if(this->_bytes == NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
return false;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
/* Read magic bytes */
|
2013-07-27 22:31:57 +08:00
|
|
|
int magicBytes = *((int*)(this->_bytes + this->_currentByte));
|
|
|
|
this->_currentByte += 4;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != 'ccbi') {
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
/* Read version. */
|
|
|
|
int version = this->readInt(false);
|
2013-07-27 21:44:49 +08:00
|
|
|
if(version != CCB_VERSION) {
|
|
|
|
log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, CCB_VERSION);
|
2012-11-26 21:51:05 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read JS check
|
2013-07-27 21:44:49 +08:00
|
|
|
_jsControlled = this->readBool();
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->_jsControlled = _jsControlled;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
return true;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
unsigned char CCBReader::readByte()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
unsigned char byte = this->_bytes[this->_currentByte];
|
|
|
|
this->_currentByte++;
|
2012-05-31 02:28:50 +08:00
|
|
|
return byte;
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
bool CCBReader::readBool()
|
|
|
|
{
|
2012-06-20 11:48:31 +08:00
|
|
|
return 0 == this->readByte() ? false : true;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-12-04 18:44:32 +08:00
|
|
|
std::string CCBReader::readUTF8()
|
|
|
|
{
|
|
|
|
std::string ret;
|
|
|
|
|
|
|
|
int b0 = this->readByte();
|
|
|
|
int b1 = this->readByte();
|
|
|
|
|
|
|
|
int numBytes = b0 << 8 | b1;
|
|
|
|
|
|
|
|
char* pStr = (char*)malloc(numBytes+1);
|
2013-07-27 22:31:57 +08:00
|
|
|
memcpy(pStr, _bytes+_currentByte, numBytes);
|
2012-12-04 18:44:32 +08:00
|
|
|
pStr[numBytes] = '\0';
|
|
|
|
ret = pStr;
|
|
|
|
free(pStr);
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
_currentByte += numBytes;
|
2012-12-04 18:44:32 +08:00
|
|
|
|
|
|
|
return ret;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCBReader::getBit() {
|
|
|
|
bool bit;
|
2013-07-27 22:31:57 +08:00
|
|
|
unsigned char byte = *(this->_bytes + this->_currentByte);
|
|
|
|
if(byte & (1 << this->_currentBit)) {
|
2012-11-26 21:51:05 +08:00
|
|
|
bit = true;
|
|
|
|
} else {
|
|
|
|
bit = false;
|
|
|
|
}
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_currentBit++;
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
if(this->_currentBit >= 8) {
|
|
|
|
this->_currentBit = 0;
|
|
|
|
this->_currentByte++;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return bit;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCBReader::alignBits() {
|
2013-07-27 22:31:57 +08:00
|
|
|
if(this->_currentBit) {
|
|
|
|
this->_currentBit = 0;
|
|
|
|
this->_currentByte++;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-19 03:03:06 +08:00
|
|
|
int CCBReader::readInt(bool pSigned) {
|
2012-11-26 21:51:05 +08:00
|
|
|
// Read encoded int
|
2012-05-31 02:28:50 +08:00
|
|
|
int numBits = 0;
|
|
|
|
while(!this->getBit()) {
|
|
|
|
numBits++;
|
|
|
|
}
|
|
|
|
|
|
|
|
long long current = 0;
|
|
|
|
for(int a = numBits - 1; a >= 0; a--) {
|
|
|
|
if(this->getBit()) {
|
2012-08-25 00:22:02 +08:00
|
|
|
current |= 1LL << a;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
2012-08-25 00:22:02 +08:00
|
|
|
current |= 1LL << numBits;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
int num;
|
2012-06-19 03:03:06 +08:00
|
|
|
if(pSigned) {
|
2012-05-31 02:28:50 +08:00
|
|
|
int s = current % 2;
|
|
|
|
if(s) {
|
|
|
|
num = (int)(current / 2);
|
|
|
|
} else {
|
|
|
|
num = (int)(-current / 2);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
num = current - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->alignBits();
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
float CCBReader::readFloat()
|
|
|
|
{
|
|
|
|
FloatType type = static_cast<FloatType>(this->readByte());
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case FloatType::_0:
|
2012-05-31 02:28:50 +08:00
|
|
|
return 0;
|
2013-07-27 21:44:49 +08:00
|
|
|
case FloatType::_1:
|
2012-05-31 02:28:50 +08:00
|
|
|
return 1;
|
2013-07-27 21:44:49 +08:00
|
|
|
case FloatType::MINUS1:
|
2012-05-31 02:28:50 +08:00
|
|
|
return -1;
|
2013-07-27 21:44:49 +08:00
|
|
|
case FloatType::_05:
|
2012-05-31 02:28:50 +08:00
|
|
|
return 0.5f;
|
2013-07-27 21:44:49 +08:00
|
|
|
case FloatType::INTEGER:
|
2012-06-20 11:48:31 +08:00
|
|
|
return (float)this->readInt(true);
|
2012-05-31 02:28:50 +08:00
|
|
|
default:
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
|
|
|
/* using a memcpy since the compiler isn't
|
|
|
|
* doing the float ptr math correctly on device.
|
|
|
|
* TODO still applies in C++ ? */
|
2013-07-27 22:31:57 +08:00
|
|
|
unsigned char* pF = (this->_bytes + this->_currentByte);
|
2012-11-26 21:51:05 +08:00
|
|
|
float f = 0;
|
2013-02-07 06:44:15 +08:00
|
|
|
|
|
|
|
// N.B - in order to avoid an unaligned memory access crash on 'memcpy()' the the (void*) casts of the source and
|
|
|
|
// destination pointers are EXTREMELY important for the ARM compiler.
|
|
|
|
//
|
|
|
|
// Without a (void*) cast, the ARM compiler makes the assumption that the float* pointer is naturally aligned
|
|
|
|
// according to it's type size (aligned along 4 byte boundaries) and thus tries to call a more optimized
|
|
|
|
// version of memcpy() which makes this alignment assumption also. When reading back from a file of course our pointers
|
|
|
|
// may not be aligned, hence we need to avoid the compiler making this assumption. The (void*) cast serves this purpose,
|
|
|
|
// and causes the ARM compiler to choose the slower, more generalized (unaligned) version of memcpy()
|
|
|
|
//
|
|
|
|
// For more about this compiler behavior, see:
|
|
|
|
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3934.html
|
|
|
|
memcpy((void*) &f, (const void*) pF, sizeof(float));
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_currentByte += sizeof(float);
|
2012-11-26 21:51:05 +08:00
|
|
|
return f;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
std::string CCBReader::readCachedString()
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
int n = this->readInt(false);
|
2013-07-27 22:31:57 +08:00
|
|
|
return this->_stringCache[n];
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
Node * CCBReader::readNodeGraph(Node * pParent)
|
|
|
|
{
|
2012-06-05 06:52:49 +08:00
|
|
|
/* Read class name. */
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string className = this->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
std::string _jsControlledName;
|
2012-11-02 08:52:07 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if(_jsControlled) {
|
|
|
|
_jsControlledName = this->readCachedString();
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Read assignment type and name
|
2013-07-27 21:44:49 +08:00
|
|
|
TargetType memberVarAssignmentType = static_cast<TargetType>(this->readInt(false));
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string memberVarAssignmentName;
|
2013-07-27 21:44:49 +08:00
|
|
|
if(memberVarAssignmentType != TargetType::NONE)
|
|
|
|
{
|
2012-06-14 15:01:01 +08:00
|
|
|
memberVarAssignmentName = this->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2013-06-05 15:17:00 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
NodeLoader *ccNodeLoader = this->_nodeLoaderLibrary->getNodeLoader(className.c_str());
|
2013-06-05 15:17:00 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
if (! ccNodeLoader)
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("no corresponding node loader for %s", className.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *node = ccNodeLoader->loadNode(pParent, this);
|
2012-06-05 06:52:49 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Set root node
|
2013-07-27 22:31:57 +08:00
|
|
|
if (! _actionManager->getRootNode())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->setRootNode(node);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
// Assign controller
|
2013-07-27 22:31:57 +08:00
|
|
|
if(_jsControlled && node == _actionManager->getRootNode())
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->setDocumentControllerName(_jsControlledName);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
2012-11-02 08:52:07 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Read animated properties
|
2013-06-20 14:15:53 +08:00
|
|
|
Dictionary *seqs = Dictionary::create();
|
2013-07-27 22:31:57 +08:00
|
|
|
_animatedProps = new set<string>();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numSequence = readInt(false);
|
|
|
|
for (int i = 0; i < numSequence; ++i)
|
|
|
|
{
|
|
|
|
int seqId = readInt(false);
|
2013-06-20 14:15:53 +08:00
|
|
|
Dictionary *seqNodeProps = Dictionary::create();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numProps = readInt(false);
|
|
|
|
|
|
|
|
for (int j = 0; j < numProps; ++j)
|
|
|
|
{
|
|
|
|
CCBSequenceProperty *seqProp = new CCBSequenceProperty();
|
|
|
|
seqProp->autorelease();
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
seqProp->setName(readCachedString().c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
seqProp->setType(readInt(false));
|
2013-07-27 22:31:57 +08:00
|
|
|
_animatedProps->insert(seqProp->getName());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numKeyframes = readInt(false);
|
|
|
|
|
|
|
|
for (int k = 0; k < numKeyframes; ++k)
|
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
CCBKeyframe *keyframe = readKeyframe(static_cast<PropertyType>(seqProp->getType()));
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
seqProp->getKeyframes()->addObject(keyframe);
|
|
|
|
}
|
|
|
|
|
|
|
|
seqNodeProps->setObject(seqProp, seqProp->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
seqs->setObject(seqNodeProps, seqId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seqs->count() > 0)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->addNode(node, seqs);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read properties
|
|
|
|
ccNodeLoader->parseProperties(node, pParent, this);
|
|
|
|
|
2013-06-07 12:50:02 +08:00
|
|
|
bool isCCBFileNode = (NULL == dynamic_cast<CCBFile*>(node)) ? false : true;
|
2012-09-17 14:27:17 +08:00
|
|
|
// Handle sub ccb files (remove middle node)
|
2013-04-15 10:39:44 +08:00
|
|
|
if (isCCBFileNode)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCBFile *ccbFileNode = (CCBFile*)node;
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node *embeddedNode = ccbFileNode->getCCBFileNode();
|
2012-09-17 14:27:17 +08:00
|
|
|
embeddedNode->setPosition(ccbFileNode->getPosition());
|
|
|
|
embeddedNode->setRotation(ccbFileNode->getRotation());
|
2013-04-15 10:18:35 +08:00
|
|
|
embeddedNode->setScaleX(ccbFileNode->getScaleX());
|
|
|
|
embeddedNode->setScaleY(ccbFileNode->getScaleY());
|
2012-09-17 14:27:17 +08:00
|
|
|
embeddedNode->setTag(ccbFileNode->getTag());
|
|
|
|
embeddedNode->setVisible(true);
|
2013-05-08 05:51:21 +08:00
|
|
|
//embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
ccbFileNode->setCCBFileNode(NULL);
|
|
|
|
|
|
|
|
node = embeddedNode;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
#ifdef CCB_ENABLE_JAVASCRIPT
|
|
|
|
/*
|
|
|
|
if (memberVarAssignmentType && memberVarAssignmentName && ![memberVarAssignmentName isEqualToString:@""])
|
|
|
|
{
|
|
|
|
[[JSCocoa sharedController] setObject:node withName:memberVarAssignmentName];
|
|
|
|
}*/
|
|
|
|
#else
|
2013-07-27 21:44:49 +08:00
|
|
|
if (memberVarAssignmentType != TargetType::NONE)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
if(!_jsControlled)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Object * target = NULL;
|
2013-07-27 21:44:49 +08:00
|
|
|
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
target = _actionManager->getRootNode();
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if(memberVarAssignmentType == TargetType::OWNER)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
target = this->_owner;
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
2013-01-21 18:37:17 +08:00
|
|
|
|
|
|
|
if(target != NULL)
|
|
|
|
{
|
|
|
|
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
|
|
|
|
|
|
|
bool assigned = false;
|
2013-07-27 21:44:49 +08:00
|
|
|
if (memberVarAssignmentType != TargetType::NONE)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
if(targetAsCCBMemberVariableAssigner != NULL)
|
|
|
|
{
|
2013-01-21 18:37:17 +08:00
|
|
|
assigned = targetAsCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
|
|
|
}
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
if(!assigned && this->_CCBMemberVariableAssigner != NULL)
|
2013-07-27 21:44:49 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
assigned = this->_CCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
2013-01-21 18:37:17 +08:00
|
|
|
else
|
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->addDocumentOutletName(memberVarAssignmentName);
|
|
|
|
_actionManager->addDocumentOutletNode(node);
|
2013-07-27 21:44:49 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerOutletNames.push_back(memberVarAssignmentName);
|
|
|
|
_ownerOutletNodes->addObject(node);
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2013-01-21 18:37:17 +08:00
|
|
|
|
|
|
|
// Assign custom properties.
|
2013-07-27 21:44:49 +08:00
|
|
|
if (ccNodeLoader->getCustomProperties()->count() > 0)
|
|
|
|
{
|
2013-01-21 18:37:17 +08:00
|
|
|
bool customAssigned = false;
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if(!_jsControlled)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Object * target = node;
|
2013-01-21 18:37:17 +08:00
|
|
|
if(target != NULL)
|
|
|
|
{
|
|
|
|
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
2013-08-12 11:18:07 +08:00
|
|
|
if(targetAsCCBMemberVariableAssigner != NULL)
|
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Dictionary* pCustomPropeties = ccNodeLoader->getCustomProperties();
|
|
|
|
DictElement* pElement;
|
2013-01-21 18:37:17 +08:00
|
|
|
CCDICT_FOREACH(pCustomPropeties, pElement)
|
|
|
|
{
|
2013-07-09 14:40:43 +08:00
|
|
|
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
2013-01-21 18:37:17 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
if(!customAssigned && this->_CCBMemberVariableAssigner != NULL)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
#endif // CCB_ENABLE_JAVASCRIPT
|
2012-09-18 17:04:10 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
delete _animatedProps;
|
|
|
|
_animatedProps = NULL;
|
2012-06-05 06:52:49 +08:00
|
|
|
|
|
|
|
/* Read and add children. */
|
2012-05-31 02:28:50 +08:00
|
|
|
int numChildren = this->readInt(false);
|
2013-08-12 11:18:07 +08:00
|
|
|
for(int i = 0; i < numChildren; i++)
|
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
Node * child = this->readNodeGraph(node);
|
2012-05-31 02:28:50 +08:00
|
|
|
node->addChild(child);
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-04-15 10:39:44 +08:00
|
|
|
// FIX ISSUE #1860: "onNodeLoaded will be called twice if ccb was added as a CCBFile".
|
2013-06-20 14:15:53 +08:00
|
|
|
// If it's a sub-ccb node, skip notification to NodeLoaderListener since it will be
|
|
|
|
// notified at LINE #734: Node * child = this->readNodeGraph(node);
|
2013-08-12 11:18:07 +08:00
|
|
|
if (!isCCBFileNode)
|
|
|
|
{
|
2013-04-15 10:39:44 +08:00
|
|
|
// Call onNodeLoaded
|
2013-06-20 14:15:53 +08:00
|
|
|
NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast<NodeLoaderListener *>(node);
|
2013-08-12 11:18:07 +08:00
|
|
|
if(nodeAsNodeLoaderListener != NULL)
|
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
2013-08-12 11:18:07 +08:00
|
|
|
}
|
|
|
|
else if(this->_nodeLoaderListener != NULL)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_nodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
2013-04-15 10:39:44 +08:00
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCBKeyframe *keyframe = new CCBKeyframe();
|
|
|
|
keyframe->autorelease();
|
|
|
|
|
|
|
|
keyframe->setTime(readFloat());
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
CCBKeyframe::EasingType easingType = static_cast<CCBKeyframe::EasingType>(readInt(false));
|
2012-09-17 14:27:17 +08:00
|
|
|
float easingOpt = 0;
|
2013-06-20 14:15:53 +08:00
|
|
|
Object *value = NULL;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if (easingType == CCBKeyframe::EasingType::CUBIC_IN
|
|
|
|
|| easingType == CCBKeyframe::EasingType::CUBIC_OUT
|
|
|
|
|| easingType == CCBKeyframe::EasingType::CUBIC_INOUT
|
|
|
|
|| easingType == CCBKeyframe::EasingType::ELASTIC_IN
|
|
|
|
|| easingType == CCBKeyframe::EasingType::ELASTIC_OUT
|
|
|
|
|| easingType == CCBKeyframe::EasingType::ELASTIC_INOUT)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
easingOpt = readFloat();
|
|
|
|
}
|
|
|
|
keyframe->setEasingType(easingType);
|
|
|
|
keyframe->setEasingOpt(easingOpt);
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if (type == PropertyType::CHECK)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
value = CCBValue::create(readBool());
|
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::BYTE)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
value = CCBValue::create(readByte());
|
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::COLOR3)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
int r = readByte();
|
|
|
|
int g = readByte();
|
|
|
|
int b = readByte();
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3B c = Color3B(r,g,b);
|
|
|
|
value = Color3BWapper::create(c);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::DEGREES)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
value = CCBValue::create(readFloat());
|
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::SCALE_LOCK || type == PropertyType::POSITION
|
|
|
|
|| type == PropertyType::FLOAT_XY)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
float a = readFloat();
|
|
|
|
float b = readFloat();
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
value = Array::create(CCBValue::create(a),
|
2012-09-17 14:27:17 +08:00
|
|
|
CCBValue::create(b),
|
|
|
|
NULL);
|
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::SPRITEFRAME)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string spriteSheet = readCachedString();
|
|
|
|
std::string spriteFile = readCachedString();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
SpriteFrame* spriteFrame;
|
2012-11-26 21:51:05 +08:00
|
|
|
|
|
|
|
if (spriteSheet.length() == 0)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
spriteFile = _CCBRootPath + spriteFile;
|
2013-07-12 18:04:32 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Texture2D *texture = TextureCache::getInstance()->addImage(spriteFile.c_str());
|
2013-07-12 14:30:26 +08:00
|
|
|
Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height);
|
2013-07-12 18:04:32 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
spriteFrame = SpriteFrame::createWithTexture(texture, bounds);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
spriteSheet = _CCBRootPath + spriteSheet;
|
2013-07-12 06:24:23 +08:00
|
|
|
SpriteFrameCache* frameCache = SpriteFrameCache::getInstance();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
// Load the sprite sheet only if it is not loaded
|
2013-07-27 22:31:57 +08:00
|
|
|
if (_loadedSpriteSheets.find(spriteSheet) == _loadedSpriteSheets.end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
frameCache->addSpriteFramesWithFile(spriteSheet.c_str());
|
2013-07-27 22:31:57 +08:00
|
|
|
_loadedSpriteSheets.insert(spriteSheet);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
spriteFrame = frameCache->getSpriteFrameByName(spriteFile.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
value = spriteFrame;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
keyframe->setValue(value);
|
|
|
|
|
|
|
|
return keyframe;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq)
|
|
|
|
{
|
2013-03-15 08:43:56 +08:00
|
|
|
int numKeyframes = readInt(false);
|
|
|
|
if(!numKeyframes) return true;
|
|
|
|
|
|
|
|
CCBSequenceProperty* channel = new CCBSequenceProperty();
|
2013-03-19 16:33:23 +08:00
|
|
|
channel->autorelease();
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
for(int i = 0; i < numKeyframes; ++i) {
|
|
|
|
|
|
|
|
float time = readFloat();
|
|
|
|
std::string callbackName = readCachedString();
|
|
|
|
|
|
|
|
int callbackType = readInt(false);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Array* value = Array::create();
|
|
|
|
value->addObject(String::create(callbackName));
|
|
|
|
value->addObject(String::createWithFormat("%d", callbackType));
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
CCBKeyframe* keyframe = new CCBKeyframe();
|
2013-03-19 16:33:23 +08:00
|
|
|
keyframe->autorelease();
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
keyframe->setTime(time);
|
|
|
|
keyframe->setValue(value);
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if(_jsControlled) {
|
2013-03-15 08:43:56 +08:00
|
|
|
string callbackIdentifier;
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->getKeyframeCallbacks()->addObject(String::createWithFormat("%d:%s",callbackType, callbackName.c_str()));
|
2013-03-15 08:43:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
channel->getKeyframes()->addObject(keyframe);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq->setCallbackChannel(channel);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) {
|
|
|
|
int numKeyframes = readInt(false);
|
|
|
|
if(!numKeyframes) return true;
|
|
|
|
|
|
|
|
CCBSequenceProperty* channel = new CCBSequenceProperty();
|
2013-03-21 09:00:55 +08:00
|
|
|
channel->autorelease();
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
for(int i = 0; i < numKeyframes; ++i) {
|
|
|
|
|
|
|
|
float time = readFloat();
|
|
|
|
std::string soundFile = readCachedString();
|
|
|
|
float pitch = readFloat();
|
|
|
|
float pan = readFloat();
|
|
|
|
float gain = readFloat();
|
2013-03-19 14:15:36 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Array* value = Array::create();
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
value->addObject(String::create(soundFile));
|
|
|
|
value->addObject(String::createWithFormat("%f", pitch));
|
|
|
|
value->addObject(String::createWithFormat("%f", pan));
|
|
|
|
value->addObject(String::createWithFormat("%f", gain));
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
CCBKeyframe* keyframe = new CCBKeyframe();
|
|
|
|
keyframe->setTime(time);
|
|
|
|
keyframe->setValue(value);
|
|
|
|
channel->getKeyframes()->addObject(keyframe);
|
2013-03-21 09:00:55 +08:00
|
|
|
keyframe->release();
|
2013-03-15 08:43:56 +08:00
|
|
|
}
|
|
|
|
|
2013-03-19 14:15:36 +08:00
|
|
|
seq->setSoundChannel(channel);
|
2013-03-15 08:43:56 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Node * CCBReader::readNodeGraph() {
|
2012-09-17 14:27:17 +08:00
|
|
|
return this->readNodeGraph(NULL);
|
2012-06-05 08:45:25 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
bool CCBReader::readSequences()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
Array *sequences = _actionManager->getSequences();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numSeqs = readInt(false);
|
|
|
|
|
|
|
|
for (int i = 0; i < numSeqs; i++)
|
|
|
|
{
|
|
|
|
CCBSequence *seq = new CCBSequence();
|
|
|
|
seq->autorelease();
|
|
|
|
|
|
|
|
seq->setDuration(readFloat());
|
2012-11-26 21:51:05 +08:00
|
|
|
seq->setName(readCachedString().c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
seq->setSequenceId(readInt(false));
|
|
|
|
seq->setChainedSequenceId(readInt(true));
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
if(!readCallbackKeyframesForSeq(seq)) return false;
|
|
|
|
if(!readSoundKeyframesForSeq(seq)) return false;
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
sequences->addObject(seq);
|
|
|
|
}
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->setAutoPlaySequenceId(readInt(true));
|
2012-09-17 14:27:17 +08:00
|
|
|
return true;
|
2012-06-05 08:45:25 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCBReader::lastPathComponent(const char* pPath) {
|
|
|
|
std::string path(pPath);
|
2013-03-03 10:32:09 +08:00
|
|
|
size_t slashPos = path.find_last_of("/");
|
2012-06-06 08:15:28 +08:00
|
|
|
if(slashPos != std::string::npos) {
|
2012-11-26 21:51:05 +08:00
|
|
|
return path.substr(slashPos + 1, path.length() - slashPos);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-11-26 21:51:05 +08:00
|
|
|
return path;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCBReader::deletePathExtension(const char* pPath) {
|
|
|
|
std::string path(pPath);
|
2013-03-03 10:32:09 +08:00
|
|
|
size_t dotPos = path.find_last_of(".");
|
2012-06-06 08:15:28 +08:00
|
|
|
if(dotPos != std::string::npos) {
|
2012-11-26 21:51:05 +08:00
|
|
|
return path.substr(0, dotPos);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-11-26 21:51:05 +08:00
|
|
|
return path;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCBReader::toLowerCase(const char* pString) {
|
|
|
|
std::string copy(pString);
|
2012-05-31 02:28:50 +08:00
|
|
|
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
|
2012-11-26 21:51:05 +08:00
|
|
|
return copy;
|
2012-06-12 09:31:11 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
bool CCBReader::endsWith(const char* pString, const char* pEnding) {
|
|
|
|
std::string string(pString);
|
|
|
|
std::string ending(pEnding);
|
2012-06-06 08:15:28 +08:00
|
|
|
if(string.length() >= ending.length()) {
|
2012-06-05 08:45:25 +08:00
|
|
|
return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
bool CCBReader::isJSControlled()
|
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
return _jsControlled;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addOwnerCallbackName(const std::string& name)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerCallbackNames.push_back(name);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addOwnerCallbackNode(Node *node)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerCallbackNodes->addObject(node);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addOwnerCallbackControlEvents(Control::EventType type)
|
|
|
|
{
|
|
|
|
_ownerOwnerCallbackControlEvents->addObject(Integer::create((int)type));
|
|
|
|
}
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackName(const std::string& name)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->addDocumentCallbackName(name);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackNode(Node *node)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_actionManager->addDocumentCallbackNode(node);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackControlEvents(Control::EventType eventType)
|
|
|
|
{
|
|
|
|
_actionManager->addDocumentCallbackControlEvents(eventType);
|
|
|
|
}
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getOwnerCallbackNames()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
Array* pRet = Array::createWithCapacity(_ownerCallbackNames.size());
|
|
|
|
std::vector<std::string>::iterator it = _ownerCallbackNames.begin();
|
|
|
|
for (; it != _ownerCallbackNames.end(); ++it)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
pRet->addObject(String::create(*it));
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return pRet;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getOwnerCallbackNodes()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _ownerCallbackNodes;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getOwnerCallbackControlEvents()
|
|
|
|
{
|
|
|
|
return _ownerOwnerCallbackControlEvents;
|
|
|
|
}
|
|
|
|
|
|
|
|
Array* CCBReader::getOwnerOutletNames()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
Array* pRet = Array::createWithCapacity(_ownerOutletNames.size());
|
|
|
|
std::vector<std::string>::iterator it = _ownerOutletNames.begin();
|
|
|
|
for (; it != _ownerOutletNames.end(); ++it)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
pRet->addObject(String::create(*it));
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
return pRet;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getOwnerOutletNodes()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _ownerOutletNodes;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getNodesWithAnimationManagers()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _nodesWithAnimationManagers;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
Array* CCBReader::getAnimationManagersForNodes()
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _animationManagersForNodes;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-06-05 15:17:00 +08:00
|
|
|
void CCBReader::addOwnerOutletName(std::string name)
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerOutletNames.push_back(name);
|
2013-06-05 15:17:00 +08:00
|
|
|
}
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
void CCBReader::addOwnerOutletNode(Node *node)
|
2013-06-05 15:17:00 +08:00
|
|
|
{
|
2013-08-12 11:19:21 +08:00
|
|
|
if (NULL == node)
|
2013-06-05 15:17:00 +08:00
|
|
|
return;
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerOutletNodes->addObject(node);
|
2013-06-05 15:17:00 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
/************************************************************************
|
|
|
|
Static functions
|
|
|
|
************************************************************************/
|
|
|
|
|
2013-04-23 10:34:16 +08:00
|
|
|
static float __ccbResolutionScale = 1.0f;
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
float CCBReader::getResolutionScale()
|
|
|
|
{
|
2013-04-23 10:34:16 +08:00
|
|
|
return __ccbResolutionScale;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCBReader::setResolutionScale(float scale)
|
|
|
|
{
|
|
|
|
__ccbResolutionScale = scale;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
};
|