2014-01-17 13:35:58 +08:00
|
|
|
#include <ctype.h>
|
2012-06-14 06:25:59 +08:00
|
|
|
#include <algorithm>
|
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCDirector.h"
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "platform/CCFileUtils.h"
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCScene.h"
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCSpriteFrameCache.h"
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "renderer/CCTextureCache.h"
|
2014-01-17 13:35:58 +08:00
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "editor-support/cocosbuilder/CCBReader.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCNodeLoader.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCNodeLoaderLibrary.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCNodeLoaderListener.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCBMemberVariableAssigner.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCBSelectorResolver.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCBAnimationManager.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCBSequenceProperty.h"
|
|
|
|
#include "editor-support/cocosbuilder/CCBKeyframe.h"
|
2014-04-09 22:46:41 +08:00
|
|
|
#include <sstream>
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
using namespace cocos2d;
|
|
|
|
using namespace cocos2d::extension;
|
2012-09-24 11:47:33 +08:00
|
|
|
|
2014-04-09 22:46:41 +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-12-08 22:17:54 +08:00
|
|
|
CCBFile::CCBFile():_CCBFileNode(nullptr) {}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCBFile* CCBFile::create()
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBFile *ret = new (std::nothrow) CCBFile();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
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-12-08 22:17:54 +08:00
|
|
|
: _data(nullptr)
|
|
|
|
, _bytes(nullptr)
|
2013-07-27 22:31:57 +08:00
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _owner(nullptr)
|
2013-12-10 13:45:15 +08:00
|
|
|
, _animationManager(nullptr)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _animatedProps(nullptr)
|
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-12-08 22:17:54 +08:00
|
|
|
: _data(nullptr)
|
|
|
|
, _bytes(nullptr)
|
2013-07-27 22:31:57 +08:00
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _owner(nullptr)
|
2013-12-10 13:45:15 +08:00
|
|
|
, _animationManager(nullptr)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _animatedProps(nullptr)
|
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-12-08 22:17:54 +08:00
|
|
|
: _data(nullptr)
|
|
|
|
, _bytes(nullptr)
|
2013-07-27 22:31:57 +08:00
|
|
|
, _currentByte(-1)
|
|
|
|
, _currentBit(-1)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _owner(nullptr)
|
2013-12-10 13:45:15 +08:00
|
|
|
, _animationManager(nullptr)
|
2013-12-08 22:17:54 +08:00
|
|
|
, _nodeLoaderLibrary(nullptr)
|
|
|
|
, _nodeLoaderListener(nullptr)
|
|
|
|
, _CCBMemberVariableAssigner(nullptr)
|
|
|
|
, _CCBSelectorResolver(nullptr)
|
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);
|
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
|
|
|
_ownerOutletNames.clear();
|
|
|
|
_ownerCallbackNames.clear();
|
2013-08-12 11:18:07 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// Clear string cache.
|
2013-07-27 22:31:57 +08:00
|
|
|
this->_stringCache.clear();
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
setAnimationManager(nullptr);
|
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
|
|
|
{
|
2015-07-14 15:28:36 +08:00
|
|
|
CCASSERT(ccbRootPath != nullptr, "ccbRootPath can't be nullptr!");
|
2013-07-27 22:31:57 +08:00
|
|
|
_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
|
|
|
{
|
|
|
|
// Setup action manager
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBAnimationManager *pActionManager = new (std::nothrow) CCBAnimationManager();
|
2012-09-17 14:27:17 +08:00
|
|
|
setAnimationManager(pActionManager);
|
|
|
|
pActionManager->release();
|
|
|
|
|
|
|
|
// Setup resolution scale and container size
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBAnimationManager* CCBReader::getAnimationManager()
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
return _animationManager;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager)
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
CC_SAFE_RELEASE(_animationManager);
|
|
|
|
_animationManager = pAnimationManager;
|
|
|
|
CC_SAFE_RETAIN(_animationManager);
|
2012-06-12 09:31:11 +08:00
|
|
|
}
|
|
|
|
|
2013-12-10 13:42:55 +08:00
|
|
|
CCBReader::CCBAnimationManagerMapPtr CCBReader::getAnimationManagers()
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
return _animationManagers;
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
2013-12-10 13:42:55 +08:00
|
|
|
void CCBReader::setAnimationManagers(CCBAnimationManagerMapPtr x)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManagers = 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
|
|
|
}
|
|
|
|
|
2014-04-09 22:46:41 +08:00
|
|
|
std::set<std::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
|
|
|
}
|
|
|
|
|
2014-04-09 22:46:41 +08:00
|
|
|
std::set<std::string>& CCBReader::getLoadedSpriteSheet()
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _loadedSpriteSheets;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* 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
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return this->readNodeGraphFromFile(pCCBFileName, nullptr);
|
2012-06-14 15:01:01 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromFile(const char* pCCBFileName, Ref* 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
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Ref *pOwner, const Size &parentSize)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
if (nullptr == pCCBFileName || strlen(pCCBFileName) == 0)
|
2012-11-30 14:16:38 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return nullptr;
|
2012-11-30 14:16:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string strCCBFileName(pCCBFileName);
|
|
|
|
std::string strSuffix(".ccbi");
|
|
|
|
// Add ccbi suffix
|
|
|
|
if (!CCBReader::endsWith(strCCBFileName.c_str(), strSuffix.c_str()))
|
|
|
|
{
|
|
|
|
strCCBFileName += strSuffix;
|
|
|
|
}
|
|
|
|
|
2016-02-03 23:12:37 +08:00
|
|
|
std::string strPath = FileUtils::getInstance()->fullPathForFilename(strCCBFileName);
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-12-18 14:58:17 +08:00
|
|
|
auto dataPtr = std::make_shared<Data>(FileUtils::getInstance()->getDataFromFile(strPath));
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-12-18 14:58:17 +08:00
|
|
|
Node *ret = this->readNodeGraphFromData(dataPtr, pOwner, parentSize);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-14 15:01:01 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Node* CCBReader::readNodeGraphFromData(std::shared_ptr<cocos2d::Data> data, Ref *pOwner, const Size &parentSize)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-18 14:58:17 +08:00
|
|
|
_data = data;
|
2013-07-27 22:31:57 +08:00
|
|
|
_bytes =_data->getBytes();
|
|
|
|
_currentByte = 0;
|
|
|
|
_currentBit = 0;
|
|
|
|
_owner = pOwner;
|
|
|
|
CC_SAFE_RETAIN(_owner);
|
|
|
|
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->setRootContainerSize(parentSize);
|
|
|
|
_animationManager->_owner = _owner;
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-12-10 13:42:55 +08:00
|
|
|
Node *pNodeGraph = readFileWithCleanUp(true, std::make_shared<CCBAnimationManagerMap>());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-12-10 13:45:15 +08:00
|
|
|
if (pNodeGraph && _animationManager->getAutoPlaySequenceId() != -1)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
// Auto play animations
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->runAnimationsForSequenceIdTweenDuration(_animationManager->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-12-10 13:45:15 +08:00
|
|
|
for (auto iter = _animationManagers->begin(); iter != _animationManagers->end(); ++iter)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-10 13:42:55 +08:00
|
|
|
Node* pNode = iter->first;
|
|
|
|
CCBAnimationManager* manager = iter->second;
|
|
|
|
|
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-12-08 22:17:54 +08:00
|
|
|
_nodesWithAnimationManagers.pushBack(pNode);
|
|
|
|
_animationManagersForNodes.pushBack(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
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return createSceneWithNodeGraphFromFile(pCCBFileName, nullptr);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Ref *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
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
Scene* CCBReader::createSceneWithNodeGraphFromFile(const char *pCCBFileName, Ref *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-11-28 16:02:03 +08:00
|
|
|
void CCBReader::cleanUpNodeGraph(Node *node)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-11-28 16:02:03 +08:00
|
|
|
node->setUserObject(nullptr);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-12-17 17:45:29 +08:00
|
|
|
auto& children = node->getChildren();
|
2013-12-20 05:34:41 +08:00
|
|
|
for(const auto &obj : children) {
|
2013-11-28 16:02:03 +08:00
|
|
|
cleanUpNodeGraph(obj);
|
2013-12-20 05:34:41 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-12-10 13:42:55 +08:00
|
|
|
Node* CCBReader::readFileWithCleanUp(bool bCleanUp, CCBAnimationManagerMapPtr am)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
if (! readHeader())
|
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return nullptr;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! readStringCache())
|
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return nullptr;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! readSequences())
|
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
return nullptr;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2012-11-28 11:49:20 +08:00
|
|
|
setAnimationManagers(am);
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
Node *pNode = readNodeGraph(nullptr);
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManagers->insert(pNode, _animationManager);
|
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-12-08 22:17:54 +08:00
|
|
|
if(this->_bytes == nullptr) {
|
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
|
|
|
|
2013-11-15 15:41:43 +08:00
|
|
|
if(CC_SWAP_INT32_BIG_TO_HOST(magicBytes) != (*reinterpret_cast<const int*>("ccbi"))) {
|
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 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-12-10 13:45:15 +08:00
|
|
|
_animationManager->_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) {
|
2013-11-11 12:49:38 +08:00
|
|
|
num = static_cast<int>(current / 2);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-11-11 12:49:38 +08:00
|
|
|
num = static_cast<int>(-current / 2);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
} else {
|
2013-11-11 12:49:38 +08:00
|
|
|
num = static_cast<int>(current - 1);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2014-08-30 03:54:24 +08:00
|
|
|
* 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());
|
2013-12-08 22:17:54 +08:00
|
|
|
return nullptr;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
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-12-10 13:45:15 +08:00
|
|
|
if (! _animationManager->getRootNode())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->setRootNode(node);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
// Assign controller
|
2013-12-10 13:45:15 +08:00
|
|
|
if(_jsControlled && node == _animationManager->getRootNode())
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->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-12-09 17:45:24 +08:00
|
|
|
std::unordered_map<int, Map<std::string, CCBSequenceProperty*>> seqs;
|
2014-04-09 22:46:41 +08:00
|
|
|
_animatedProps = new std::set<std::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-12-09 17:45:24 +08:00
|
|
|
Map<std::string, CCBSequenceProperty*> seqNodeProps;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numProps = readInt(false);
|
|
|
|
|
|
|
|
for (int j = 0; j < numProps; ++j)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBSequenceProperty *seqProp = new (std::nothrow) CCBSequenceProperty();
|
2012-09-17 14:27:17 +08:00
|
|
|
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
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
seqProp->getKeyframes().pushBack(keyframe);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-12-09 17:45:24 +08:00
|
|
|
seqNodeProps.insert(seqProp->getName(), seqProp);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-12-09 17:45:24 +08:00
|
|
|
seqs[seqId] = seqNodeProps;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-12-09 17:45:24 +08:00
|
|
|
if (!seqs.empty())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->addNode(node, seqs);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read properties
|
|
|
|
ccNodeLoader->parseProperties(node, pParent, this);
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
bool isCCBFileNode = (nullptr == 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-12-10 13:45:15 +08:00
|
|
|
_animationManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
ccbFileNode->setCCBFileNode(nullptr);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
node = embeddedNode;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* target = nullptr;
|
2013-07-27 21:44:49 +08:00
|
|
|
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
target = _animationManager->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
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
if(target != nullptr)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
|
|
|
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-12-08 22:17:54 +08:00
|
|
|
if(targetAsCCBMemberVariableAssigner != nullptr)
|
2013-07-27 21:44:49 +08:00
|
|
|
{
|
2013-01-21 18:37:17 +08:00
|
|
|
assigned = targetAsCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName.c_str(), node);
|
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
if(!assigned && this->_CCBMemberVariableAssigner != nullptr)
|
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-12-10 13:45:15 +08:00
|
|
|
_animationManager->addDocumentOutletName(memberVarAssignmentName);
|
|
|
|
_animationManager->addDocumentOutletNode(node);
|
2013-07-27 21:44:49 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
_ownerOutletNames.push_back(memberVarAssignmentName);
|
2013-12-08 22:17:54 +08:00
|
|
|
_ownerOutletNodes.pushBack(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-12-09 17:45:24 +08:00
|
|
|
if (!ccNodeLoader->getCustomProperties().empty())
|
2013-07-27 21:44:49 +08:00
|
|
|
{
|
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
|
|
|
{
|
2014-02-20 10:53:49 +08:00
|
|
|
Ref* target = node;
|
2013-12-08 22:17:54 +08:00
|
|
|
if(target != nullptr)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
|
|
|
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
2013-12-08 22:17:54 +08:00
|
|
|
if(targetAsCCBMemberVariableAssigner != nullptr)
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
auto& customPropeties = ccNodeLoader->getCustomProperties();
|
|
|
|
|
|
|
|
for (auto iter = customPropeties.begin(); iter != customPropeties.end(); ++iter)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second);
|
2013-01-21 18:37:17 +08:00
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
if(!customAssigned && this->_CCBMemberVariableAssigner != nullptr)
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second);
|
2013-01-21 18:37:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-18 17:04:10 +08:00
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
delete _animatedProps;
|
2013-12-08 22:17:54 +08:00
|
|
|
_animatedProps = nullptr;
|
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-12-08 22:17:54 +08:00
|
|
|
if(nodeAsNodeLoaderListener != nullptr)
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-06-20 14:15:53 +08:00
|
|
|
nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
2013-08-12 11:18:07 +08:00
|
|
|
}
|
2013-12-08 22:17:54 +08:00
|
|
|
else if(this->_nodeLoaderListener != nullptr)
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
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
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBKeyframe *keyframe = new (std::nothrow) CCBKeyframe();
|
2012-09-17 14:27:17 +08:00
|
|
|
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-12-09 17:45:24 +08:00
|
|
|
Value value;
|
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
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
value = readBool();
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::BYTE)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
value = readByte();
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2013-07-27 21:44:49 +08:00
|
|
|
else if (type == PropertyType::COLOR3)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
unsigned char r = readByte();
|
|
|
|
unsigned char g = readByte();
|
|
|
|
unsigned char b = readByte();
|
|
|
|
|
|
|
|
ValueMap colorMap;
|
|
|
|
colorMap["r"] = r;
|
|
|
|
colorMap["g"] = g;
|
|
|
|
colorMap["b"] = b;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-12-09 17:45:24 +08:00
|
|
|
value = colorMap;
|
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
|
|
|
{
|
2013-12-09 17:45:24 +08:00
|
|
|
value = readFloat();
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
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-12-09 17:45:24 +08:00
|
|
|
ValueVector ab;
|
|
|
|
ab.push_back(Value(a));
|
|
|
|
ab.push_back(Value(b));
|
|
|
|
|
|
|
|
value = ab;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
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
|
|
|
|
2015-09-01 11:26:09 +08:00
|
|
|
if (spriteSheet.empty())
|
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
|
|
|
|
2016-02-03 23:12:37 +08:00
|
|
|
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(spriteFile);
|
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
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
frameCache->addSpriteFramesWithFile(spriteSheet);
|
2013-07-27 22:31:57 +08:00
|
|
|
_loadedSpriteSheets.insert(spriteSheet);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2016-02-03 23:12:37 +08:00
|
|
|
spriteFrame = frameCache->getSpriteFrameByName(spriteFile);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2013-12-09 17:45:24 +08:00
|
|
|
|
|
|
|
keyframe->setObject(spriteFrame);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2013-12-09 17:45:24 +08:00
|
|
|
if (!value.isNull())
|
|
|
|
keyframe->setValue(value);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBSequenceProperty* channel = new (std::nothrow) 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-12-09 17:45:24 +08:00
|
|
|
ValueVector valueVector;
|
|
|
|
valueVector.push_back(Value(callbackName));
|
|
|
|
valueVector.push_back(Value(callbackType));
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBKeyframe* keyframe = new (std::nothrow) CCBKeyframe();
|
2013-03-19 16:33:23 +08:00
|
|
|
keyframe->autorelease();
|
|
|
|
|
2013-03-15 08:43:56 +08:00
|
|
|
keyframe->setTime(time);
|
2013-12-09 17:45:24 +08:00
|
|
|
keyframe->setValue(Value(valueVector));
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
if(_jsControlled) {
|
2013-12-09 11:46:20 +08:00
|
|
|
std::stringstream callbackIdentifier;
|
|
|
|
callbackIdentifier << callbackType;
|
|
|
|
callbackIdentifier << ":" + callbackName;
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->getKeyframeCallbacks().push_back(Value(callbackIdentifier.str()));
|
2013-03-15 08:43:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
channel->getKeyframes().pushBack(keyframe);
|
2013-03-15 08:43:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
seq->setCallbackChannel(channel);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) {
|
|
|
|
int numKeyframes = readInt(false);
|
|
|
|
if(!numKeyframes) return true;
|
|
|
|
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBSequenceProperty* channel = new (std::nothrow) 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-12-09 17:45:24 +08:00
|
|
|
ValueVector vec;
|
|
|
|
vec.push_back(Value(soundFile));
|
|
|
|
vec.push_back(Value(pitch));
|
|
|
|
vec.push_back(Value(pan));
|
|
|
|
vec.push_back(Value(gain));
|
2013-03-15 08:43:56 +08:00
|
|
|
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBKeyframe* keyframe = new (std::nothrow) CCBKeyframe();
|
2013-03-15 08:43:56 +08:00
|
|
|
keyframe->setTime(time);
|
2013-12-09 17:45:24 +08:00
|
|
|
keyframe->setValue(Value(vec));
|
2013-12-08 22:17:54 +08:00
|
|
|
channel->getKeyframes().pushBack(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() {
|
2013-12-08 22:17:54 +08:00
|
|
|
return this->readNodeGraph(nullptr);
|
2012-06-05 08:45:25 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
bool CCBReader::readSequences()
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
auto& sequences = _animationManager->getSequences();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
int numSeqs = readInt(false);
|
|
|
|
|
|
|
|
for (int i = 0; i < numSeqs; i++)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
CCBSequence *seq = new (std::nothrow) CCBSequence();
|
2012-09-17 14:27:17 +08:00
|
|
|
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;
|
|
|
|
|
2013-12-09 11:46:20 +08:00
|
|
|
sequences.pushBack(seq);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->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-12-08 22:17:54 +08:00
|
|
|
_ownerCallbackNodes.pushBack(node);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addOwnerCallbackControlEvents(Control::EventType type)
|
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
_ownerOwnerCallbackControlEvents.push_back(Value((int)type));
|
2013-08-12 11:18:07 +08:00
|
|
|
}
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackName(const std::string& name)
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->addDocumentCallbackName(name);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackNode(Node *node)
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->addDocumentCallbackNode(node);
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-12 11:18:07 +08:00
|
|
|
void CCBReader::addDocumentCallbackControlEvents(Control::EventType eventType)
|
|
|
|
{
|
2013-12-10 13:45:15 +08:00
|
|
|
_animationManager->addDocumentCallbackControlEvents(eventType);
|
2013-08-12 11:18:07 +08:00
|
|
|
}
|
2012-11-01 02:06:56 +08:00
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
ValueVector CCBReader::getOwnerCallbackNames()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
ValueVector ret;
|
|
|
|
ret.reserve(_ownerCallbackNames.size());
|
|
|
|
|
2013-07-27 22:31:57 +08:00
|
|
|
std::vector<std::string>::iterator it = _ownerCallbackNames.begin();
|
|
|
|
for (; it != _ownerCallbackNames.end(); ++it)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
ret.push_back(Value(*it));
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
|
|
|
|
2013-12-10 16:06:05 +08:00
|
|
|
return ret;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
Vector<Node*>& CCBReader::getOwnerCallbackNodes()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _ownerCallbackNodes;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
ValueVector& CCBReader::getOwnerCallbackControlEvents()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
|
|
|
return _ownerOwnerCallbackControlEvents;
|
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
ValueVector CCBReader::getOwnerOutletNames()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
ValueVector ret;
|
|
|
|
ret.reserve(_ownerOutletNames.size());
|
2013-07-27 22:31:57 +08:00
|
|
|
std::vector<std::string>::iterator it = _ownerOutletNames.begin();
|
|
|
|
for (; it != _ownerOutletNames.end(); ++it)
|
2012-11-26 21:51:05 +08:00
|
|
|
{
|
2013-12-08 22:17:54 +08:00
|
|
|
ret.push_back(Value(*it));
|
2012-11-26 21:51:05 +08:00
|
|
|
}
|
2013-12-10 16:06:05 +08:00
|
|
|
return ret;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
Vector<Node*>& CCBReader::getOwnerOutletNodes()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _ownerOutletNodes;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
Vector<Node*>& CCBReader::getNodesWithAnimationManagers()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
2013-07-27 22:31:57 +08:00
|
|
|
return _nodesWithAnimationManagers;
|
2012-11-01 02:06:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
Vector<CCBAnimationManager*>& CCBReader::getAnimationManagersForNodes()
|
2013-08-12 11:18:07 +08:00
|
|
|
{
|
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-12-08 22:17:54 +08:00
|
|
|
if (nullptr == node)
|
2013-06-05 15:17:00 +08:00
|
|
|
return;
|
|
|
|
|
2013-12-08 22:17:54 +08:00
|
|
|
_ownerOutletNodes.pushBack(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
|
|
|
};
|