2012-06-13 02:59:49 +08:00
|
|
|
#include "CCNodeLoader.h"
|
|
|
|
#include "CCBSelectorResolver.h"
|
2012-06-14 05:19:13 +08:00
|
|
|
#include "CCBMemberVariableAssigner.h"
|
2012-09-17 14:27:17 +08:00
|
|
|
#include "CCBAnimationManager.h"
|
|
|
|
#include "CCData.h"
|
2012-09-18 17:04:10 +08:00
|
|
|
#include "CCNode+CCBRelativePositioning.h"
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
using namespace std;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2013-01-21 18:37:17 +08:00
|
|
|
CCNodeLoader::CCNodeLoader()
|
|
|
|
{
|
|
|
|
m_pCustomProperties = new CCDictionary();
|
|
|
|
}
|
|
|
|
|
|
|
|
CCNodeLoader::~CCNodeLoader()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(m_pCustomProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCDictionary* CCNodeLoader::getCustomProperties()
|
|
|
|
{
|
|
|
|
return m_pCustomProperties;
|
|
|
|
}
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
CCNode * ccNode = this->createCCNode(pParent, pCCBReader);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
//this->parseProperties(ccNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
return ccNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-09-17 14:27:17 +08:00
|
|
|
int numRegularProps = pCCBReader->readInt(false);
|
|
|
|
int numExturaProps = pCCBReader->readInt(false);
|
|
|
|
int propertyCount = numRegularProps + numExturaProps;
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
for(int i = 0; i < propertyCount; i++) {
|
2012-09-17 14:27:17 +08:00
|
|
|
bool isExtraProp = (i >= numRegularProps);
|
2012-05-31 02:28:50 +08:00
|
|
|
int type = pCCBReader->readInt(false);
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string propertyName = pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
// Check if the property can be set for this platform
|
|
|
|
bool setProp = false;
|
|
|
|
|
|
|
|
int platform = pCCBReader->readByte();
|
2012-09-17 14:27:17 +08:00
|
|
|
if(platform == kCCBPlatformAll)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
setProp = true;
|
|
|
|
}
|
2012-11-27 11:03:12 +08:00
|
|
|
// Cocos2d-x is using touch event callback for all platforms,
|
2012-11-27 11:05:52 +08:00
|
|
|
// it's different from cocos2d-iphone which uses mouse event for Mac port.
|
2012-11-27 11:03:12 +08:00
|
|
|
// So we just need to touch event by using kCCBPlatformIOS.
|
|
|
|
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
2012-11-22 15:15:30 +08:00
|
|
|
if(platform == kCCBPlatformIOS)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
setProp = true;
|
|
|
|
}
|
2012-11-27 11:03:12 +08:00
|
|
|
// #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
|
|
|
// if(platform == kCCBPlatformMac)
|
|
|
|
// {
|
|
|
|
// setProp = true;
|
|
|
|
// }
|
|
|
|
// #endif
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
// Forward properties for sub ccb files
|
|
|
|
if (dynamic_cast<CCBFile*>(pNode) != NULL)
|
|
|
|
{
|
|
|
|
CCBFile *ccbNode = (CCBFile*)pNode;
|
|
|
|
if (ccbNode->getCCBFileNode() && isExtraProp)
|
|
|
|
{
|
|
|
|
pNode = ccbNode->getCCBFileNode();
|
|
|
|
|
|
|
|
// Skip properties that doesn't have a value to override
|
|
|
|
CCArray *extraPropsNames = (CCArray*)pNode->getUserObject();
|
2012-11-26 21:51:05 +08:00
|
|
|
CCObject* pObj = NULL;
|
|
|
|
bool bFound = false;
|
|
|
|
CCARRAY_FOREACH(extraPropsNames, pObj)
|
|
|
|
{
|
|
|
|
CCString* pStr = (CCString*)pObj;
|
|
|
|
if (0 == pStr->compare(propertyName.c_str()))
|
|
|
|
{
|
|
|
|
bFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setProp &= bFound;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (isExtraProp && pNode == pCCBReader->getAnimationManager()->getRootNode())
|
|
|
|
{
|
|
|
|
CCArray *extraPropsNames = (CCArray*)pNode->getUserObject();
|
|
|
|
if (! extraPropsNames)
|
|
|
|
{
|
|
|
|
extraPropsNames = CCArray::create();
|
|
|
|
pNode->setUserObject(extraPropsNames);
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
extraPropsNames->addObject(CCString::create(propertyName));
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case kCCBPropTypePosition:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
CCPoint position = this->parsePropTypePosition(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if (setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypePosition(pNode, pParent, propertyName.c_str(), position, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypePoint:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
CCPoint point = this->parsePropTypePoint(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if (setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypePoint(pNode, pParent, propertyName.c_str(), point, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypePointLock:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
CCPoint pointLock = this->parsePropTypePointLock(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if (setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypePointLock(pNode, pParent, propertyName.c_str(), pointLock, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeSize: {
|
|
|
|
CCSize size = this->parsePropTypeSize(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeSize(pNode, pParent, propertyName.c_str(), size, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeScaleLock:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeScaleLock(pNode, pParent, propertyName.c_str(), scaleLock, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(scaleLock);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeFloat:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float f = this->parsePropTypeFloat(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFloat(pNode, pParent, propertyName.c_str(), f, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeDegrees:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
float degrees = this->parsePropTypeDegrees(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeDegrees(pNode, pParent, propertyName.c_str(), degrees, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeFloatScale:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float floatScale = this->parsePropTypeFloatScale(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFloatScale(pNode, pParent, propertyName.c_str(), floatScale, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeInteger:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
int integer = this->parsePropTypeInteger(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeInteger(pNode, pParent, propertyName.c_str(), integer, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeIntegerLabeled:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
int integerLabeled = this->parsePropTypeIntegerLabeled(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeIntegerLabeled(pNode, pParent, propertyName.c_str(), integerLabeled, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeFloatVar:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float * floatVar = this->parsePropTypeFloatVar(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFloatVar(pNode, pParent, propertyName.c_str(), floatVar, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(floatVar);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeCheck:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
bool check = this->parsePropTypeCheck(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeCheck(pNode, pParent, propertyName.c_str(), check, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeSpriteFrame: {
|
2012-11-26 21:51:05 +08:00
|
|
|
CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName.c_str(), ccSpriteFrame, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeAnimation:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
CCAnimation * ccAnimation = this->parsePropTypeAnimation(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeAnimation(pNode, pParent, propertyName.c_str(), ccAnimation, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeTexture:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
CCTexture2D * ccTexture2D = this->parsePropTypeTexture(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeTexture(pNode, pParent, propertyName.c_str(), ccTexture2D, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeByte:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
unsigned char byte = this->parsePropTypeByte(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeByte(pNode, pParent, propertyName.c_str(), byte, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeColor3:
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader, propertyName.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeColor3(pNode, pParent, propertyName.c_str(), color3B, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeColor4FVar:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
ccColor4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName.c_str(), color4FVar, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(color4FVar);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFlip: {
|
|
|
|
bool * flip = this->parsePropTypeFlip(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFlip(pNode, pParent, propertyName.c_str(), flip, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(flip);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeBlendmode:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
ccBlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName.c_str(), blendFunc, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBPropTypeFntFile:
|
|
|
|
{
|
2012-12-03 18:27:50 +08:00
|
|
|
std::string fntFile = pCCBReader->getCCBRootPath() + this->parsePropTypeFntFile(pNode, pParent, pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
if(setProp)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFntFile(pNode, pParent, propertyName.c_str(), fntFile.c_str(), pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-31 06:36:00 +08:00
|
|
|
case kCCBPropTypeFontTTF: {
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader);
|
2012-05-31 06:36:00 +08:00
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeFontTTF(pNode, pParent, propertyName.c_str(), fontTTF.c_str(), pCCBReader);
|
2012-05-31 06:36:00 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
case kCCBPropTypeString: {
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string string = this->parsePropTypeString(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeString(pNode, pParent, propertyName.c_str(), string.c_str(), pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeText: {
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string text = this->parsePropTypeText(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeText(pNode, pParent, propertyName.c_str(), text.c_str(), pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeBlock: {
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockData * blockData = this->parsePropTypeBlock(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeBlock(pNode, pParent, propertyName.c_str(), blockData, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE(blockData);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeBlockCCControl: {
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockCCControlData * blockCCControlData = this->parsePropTypeBlockCCControl(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp && blockCCControlData != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName.c_str(), blockCCControlData, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-19 02:43:46 +08:00
|
|
|
CC_SAFE_DELETE(blockCCControlData);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeCCBFile: {
|
2012-06-01 05:57:13 +08:00
|
|
|
CCNode * ccbFileNode = this->parsePropTypeCCBFile(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
2012-11-26 21:51:05 +08:00
|
|
|
this->onHandlePropTypeCCBFile(pNode, pParent, propertyName.c_str(), ccbFileNode, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type);
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
2012-05-31 02:28:50 +08:00
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
CCPoint pt = getAbsolutePosition(ccp(x,y), type, containerSize, pPropertyName);
|
|
|
|
pNode->setPosition(getAbsolutePosition(pt, type, containerSize, pPropertyName));;
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCArray *baseValue = CCArray::create(CCBValue::create(x),
|
|
|
|
CCBValue::create(y),
|
|
|
|
CCBValue::create(type),
|
|
|
|
NULL);
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
return pt;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
return CCPoint(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCPoint CCNodeLoader::parsePropTypePointLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
return CCPoint(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCSize CCNodeLoader::parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float width = pCCBReader->readFloat();
|
|
|
|
float height = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCSize containerSize = pCCBReader->getAnimationManager()->getContainerSize(pParent);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case kCCBSizeTypeAbsolute:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
/* Nothing. */
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBSizeTypeRelativeContainer:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
width = containerSize.width - width;
|
|
|
|
height = containerSize.height - height;
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBSizeTypePercent:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
width = (int)(containerSize.width * width / 100.0f);
|
|
|
|
height = (int)(containerSize.height * height / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBSizeTypeHorizontalPercent:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
width = (int)(containerSize.width * width / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBSizeTypeVerticalPercent:
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
height = (int)(containerSize.height * height / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
case kCCBSizeTypeMultiplyResolution:
|
|
|
|
{
|
|
|
|
float resolutionScale = CCBReader::getResolutionScale();
|
|
|
|
|
|
|
|
width *= resolutionScale;
|
|
|
|
height *= resolutionScale;
|
2013-01-21 18:37:17 +08:00
|
|
|
break;
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
default:
|
2013-01-21 18:37:17 +08:00
|
|
|
{
|
|
|
|
CCLog("Unknown CCB type.");
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CCSize(width, height);
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
2012-05-31 02:28:50 +08:00
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-09-18 17:55:03 +08:00
|
|
|
setRelativeScale(pNode, x, y, type, pPropertyName);
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCArray *baseValue = CCArray::create(CCBValue::create(x),
|
|
|
|
CCBValue::create(y),
|
|
|
|
CCBValue::create(type),
|
|
|
|
NULL);
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName);
|
|
|
|
}
|
2012-09-18 17:55:03 +08:00
|
|
|
|
|
|
|
if (type == kCCBScaleTypeMultiplyResolution)
|
|
|
|
{
|
|
|
|
x *= pCCBReader->getResolutionScale();
|
|
|
|
y *= pCCBReader->getResolutionScale();
|
|
|
|
}
|
|
|
|
|
|
|
|
float * scaleLock = new float[2];
|
|
|
|
scaleLock[0] = x;
|
|
|
|
scaleLock[1] = y;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
return scaleLock;
|
|
|
|
}
|
|
|
|
|
|
|
|
float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readFloat();
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
|
|
|
float ret = pCCBReader->readFloat();
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCBValue *value = CCBValue::create(ret);
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float f = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
if(type == kCCBScaleTypeMultiplyResolution)
|
|
|
|
{
|
2012-06-05 07:16:42 +08:00
|
|
|
f *= pCCBReader->getResolutionScale();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 07:16:42 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
int CCNodeLoader::parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
return pCCBReader->readInt(true);
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
int CCNodeLoader::parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
return pCCBReader->readInt(true);
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
float f = pCCBReader->readFloat();
|
|
|
|
float fVar = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
float * arr = new float[2];
|
|
|
|
arr[0] = f;
|
|
|
|
arr[1] = fVar;
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName)
|
|
|
|
{
|
|
|
|
bool ret = pCCBReader->readBool();
|
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
CCBValue *value = CCBValue::create(ret);
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName)
|
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string spriteSheet = pCCBReader->readCachedString();
|
|
|
|
std::string spriteFile = pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
CCSpriteFrame *spriteFrame = NULL;
|
2012-11-26 21:51:05 +08:00
|
|
|
if (spriteFile.length() != 0)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
if (spriteSheet.length() == 0)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-12-03 18:27:50 +08:00
|
|
|
spriteFile = pCCBReader->getCCBRootPath() + spriteFile;
|
2012-11-26 21:51:05 +08:00
|
|
|
CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height);
|
|
|
|
spriteFrame = CCSpriteFrame::createWithTexture(texture, bounds);
|
2012-06-02 06:13:16 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
|
2012-12-03 18:27:50 +08:00
|
|
|
spriteSheet = pCCBReader->getCCBRootPath() + spriteSheet;
|
2012-09-17 14:27:17 +08:00
|
|
|
// Load the sprite sheet only if it is not loaded
|
2012-11-26 21:51:05 +08:00
|
|
|
if (pCCBReader->getLoadedSpriteSheet().find(spriteSheet) == pCCBReader->getLoadedSpriteSheet().end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
frameCache->addSpriteFramesWithFile(spriteSheet.c_str());
|
|
|
|
pCCBReader->getLoadedSpriteSheet().insert(spriteSheet);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
spriteFrame = frameCache->spriteFrameByName(spriteFile.c_str());
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(spriteFrame, pNode, pPropertyName);
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
return spriteFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-12-03 18:27:50 +08:00
|
|
|
std::string animationFile = pCCBReader->getCCBRootPath() + pCCBReader->readCachedString();
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string animation = pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
CCAnimation * ccAnimation = NULL;
|
|
|
|
|
|
|
|
// Support for stripping relative file paths, since ios doesn't currently
|
|
|
|
// know what to do with them, since its pulling from bundle.
|
|
|
|
// Eventually this should be handled by a client side asset manager
|
|
|
|
// interface which figured out what resources to load.
|
|
|
|
// TODO Does this problem exist in C++?
|
2012-11-26 21:51:05 +08:00
|
|
|
animation = CCBReader::lastPathComponent(animation.c_str());
|
|
|
|
animationFile = CCBReader::lastPathComponent(animationFile.c_str());
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
if (animation.length() > 0)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache();
|
2012-11-26 21:51:05 +08:00
|
|
|
animationCache->addAnimationsWithFile(animationFile.c_str());
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
ccAnimation = animationCache->animationByName(animation.c_str());
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
return ccAnimation;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-12-03 18:27:50 +08:00
|
|
|
std::string spriteFile = pCCBReader->getCCBRootPath() + pCCBReader->readCachedString();
|
2012-09-17 14:27:17 +08:00
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
if (spriteFile.length() > 0)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
2012-11-26 21:51:05 +08:00
|
|
|
return CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str());
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName)
|
|
|
|
{
|
|
|
|
unsigned char ret = pCCBReader->readByte();
|
|
|
|
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(CCBValue::create(ret), pNode, pPropertyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
2012-05-31 02:28:50 +08:00
|
|
|
unsigned char red = pCCBReader->readByte();
|
|
|
|
unsigned char green = pCCBReader->readByte();
|
|
|
|
unsigned char blue = pCCBReader->readByte();
|
|
|
|
|
|
|
|
ccColor3B color = { red, green, blue };
|
2012-09-18 17:04:10 +08:00
|
|
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
ccColor3BWapper *value = ccColor3BWapper::create(color);
|
|
|
|
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccColor4F * CCNodeLoader::parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float red = pCCBReader->readFloat();
|
|
|
|
float green = pCCBReader->readFloat();
|
|
|
|
float blue = pCCBReader->readFloat();
|
|
|
|
float alpha = pCCBReader->readFloat();
|
|
|
|
float redVar = pCCBReader->readFloat();
|
|
|
|
float greenVar = pCCBReader->readFloat();
|
|
|
|
float blueVar = pCCBReader->readFloat();
|
|
|
|
float alphaVar = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
ccColor4F * colors = new ccColor4F[2];
|
|
|
|
colors[0].r = red;
|
|
|
|
colors[0].g = green;
|
|
|
|
colors[0].b = blue;
|
|
|
|
colors[0].a = alpha;
|
|
|
|
|
|
|
|
colors[1].r = redVar;
|
|
|
|
colors[1].g = greenVar;
|
|
|
|
colors[1].b = blueVar;
|
|
|
|
colors[1].a = alphaVar;
|
|
|
|
|
|
|
|
return colors;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool * CCNodeLoader::parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
bool flipX = pCCBReader->readBool();
|
|
|
|
bool flipY = pCCBReader->readBool();
|
|
|
|
|
|
|
|
bool * arr = new bool[2];
|
|
|
|
arr[0] = flipX;
|
|
|
|
arr[1] = flipY;
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
|
|
|
{
|
2012-05-31 02:28:50 +08:00
|
|
|
int source = pCCBReader->readInt(false);
|
|
|
|
int destination = pCCBReader->readInt(false);
|
|
|
|
|
|
|
|
ccBlendFunc blendFunc;
|
|
|
|
blendFunc.src = source;
|
|
|
|
blendFunc.dst = destination;
|
|
|
|
|
|
|
|
return blendFunc;
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader)
|
2012-09-17 14:27:17 +08:00
|
|
|
{
|
|
|
|
return pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-14 15:01:01 +08:00
|
|
|
return pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-14 15:01:01 +08:00
|
|
|
return pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
std::string fontTTF = pCCBReader->readCachedString();
|
2012-06-16 07:06:54 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
// CCString * ttfEnding = CCString::create(".ttf");
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 18:49:05 +08:00
|
|
|
// TODO Fix me if it is wrong
|
2012-06-16 07:06:54 +08:00
|
|
|
/* If the fontTTF comes with the ".ttf" extension, prepend the absolute path.
|
|
|
|
* System fonts come without the ".ttf" extension and do not need the path prepended. */
|
2012-09-17 14:27:17 +08:00
|
|
|
/*
|
2012-06-16 05:01:57 +08:00
|
|
|
if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){
|
|
|
|
fontTTF = CCBReader::concat(pCCBReader->getCCBRootPath(), fontTTF);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-09-17 14:27:17 +08:00
|
|
|
*/
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-16 05:01:57 +08:00
|
|
|
return fontTTF;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string selectorName = pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
int selectorTarget = pCCBReader->readInt(false);
|
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
if(selectorTarget != kCCBTargetTypeNone) {
|
|
|
|
CCObject * target = NULL;
|
2012-11-02 08:52:07 +08:00
|
|
|
if(!pCCBReader->isJSControlled()) {
|
2012-09-19 08:38:33 +08:00
|
|
|
|
2012-11-02 08:52:07 +08:00
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
target = pCCBReader->getAnimationManager()->getRootNode();
|
|
|
|
} else if(selectorTarget == kCCBTargetTypeOwner) {
|
|
|
|
target = pCCBReader->getOwner();
|
2012-09-19 08:38:33 +08:00
|
|
|
}
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
if(target != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(selectorName.length() > 0) {
|
2012-11-02 08:52:07 +08:00
|
|
|
SEL_MenuHandler selMenuHandler = 0;
|
|
|
|
|
|
|
|
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
|
|
|
|
|
|
|
if(targetAsCCBSelectorResolver != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
if(selMenuHandler == 0) {
|
|
|
|
CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver();
|
|
|
|
if(ccbSelectorResolver != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(selMenuHandler == 0) {
|
2012-11-26 21:51:05 +08:00
|
|
|
CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
} else {
|
|
|
|
BlockData * blockData = new BlockData();
|
|
|
|
blockData->mSELMenuHandler = selMenuHandler;
|
|
|
|
|
|
|
|
blockData->mTarget = target;
|
|
|
|
|
|
|
|
return blockData;
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
CCLOG("Unexpected empty selector.");
|
2012-06-05 06:52:49 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
CCLOG("Unexpected NULL target for selector.");
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
pCCBReader->addDocumentCallbackNode(pNode);
|
2012-11-26 21:51:05 +08:00
|
|
|
pCCBReader->addDocumentCallbackName(selectorName);
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
pCCBReader->addOwnerCallbackNode(pNode);
|
2012-11-26 21:51:05 +08:00
|
|
|
pCCBReader->addOwnerCallbackName(selectorName);
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string selectorName = pCCBReader->readCachedString();
|
2012-05-31 02:28:50 +08:00
|
|
|
int selectorTarget = pCCBReader->readInt(false);
|
2012-06-05 06:52:49 +08:00
|
|
|
int controlEvents = pCCBReader->readInt(false);
|
|
|
|
|
|
|
|
if(selectorTarget != kCCBTargetTypeNone) {
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
if(!pCCBReader->isJSControlled()) {
|
|
|
|
CCObject * target = NULL;
|
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
target = pCCBReader->getAnimationManager()->getRootNode();
|
|
|
|
} else if(selectorTarget == kCCBTargetTypeOwner) {
|
|
|
|
target = pCCBReader->getOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(target != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(selectorName.length() > 0) {
|
2012-11-02 08:52:07 +08:00
|
|
|
SEL_CCControlHandler selCCControlHandler = 0;
|
|
|
|
|
|
|
|
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
|
|
|
|
|
|
|
if(targetAsCCBSelectorResolver != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
selCCControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
if(selCCControlHandler == 0) {
|
|
|
|
CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver();
|
|
|
|
if(ccbSelectorResolver != NULL) {
|
2012-11-26 21:51:05 +08:00
|
|
|
selCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(selCCControlHandler == 0) {
|
2012-11-26 21:51:05 +08:00
|
|
|
CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str());
|
2012-11-02 08:52:07 +08:00
|
|
|
} else {
|
|
|
|
BlockCCControlData * blockCCControlData = new BlockCCControlData();
|
|
|
|
blockCCControlData->mSELCCControlHandler = selCCControlHandler;
|
|
|
|
|
|
|
|
blockCCControlData->mTarget = target;
|
|
|
|
blockCCControlData->mControlEvents = controlEvents;
|
|
|
|
|
|
|
|
return blockCCControlData;
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
CCLOG("Unexpected empty selector.");
|
2012-06-05 06:52:49 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
CCLOG("Unexpected NULL target for selector.");
|
2012-06-05 06:52:49 +08:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-02 08:52:07 +08:00
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
pCCBReader->addDocumentCallbackNode(pNode);
|
2012-11-26 21:51:05 +08:00
|
|
|
pCCBReader->addDocumentCallbackName(selectorName);
|
2012-11-02 08:52:07 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
pCCBReader->addOwnerCallbackNode(pNode);
|
2012-11-26 21:51:05 +08:00
|
|
|
pCCBReader->addOwnerCallbackName(selectorName);
|
2012-11-02 08:52:07 +08:00
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-01 05:57:13 +08:00
|
|
|
CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-12-03 18:27:50 +08:00
|
|
|
std::string ccbFileName = pCCBReader->getCCBRootPath() + pCCBReader->readCachedString();
|
2012-06-01 05:57:13 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
/* Change path extension to .ccbi. */
|
2012-11-26 21:51:05 +08:00
|
|
|
std::string ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName.c_str());
|
|
|
|
ccbFileName = ccbFileWithoutPathExtension + ".ccbi";
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
// Load sub file
|
2012-11-26 21:51:05 +08:00
|
|
|
const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFileName.c_str());
|
|
|
|
unsigned long size = 0;
|
|
|
|
unsigned char * pBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size);
|
|
|
|
|
2012-06-01 05:57:13 +08:00
|
|
|
CCBReader * ccbReader = new CCBReader(pCCBReader);
|
2012-06-06 08:15:28 +08:00
|
|
|
ccbReader->autorelease();
|
2012-11-26 21:51:05 +08:00
|
|
|
ccbReader->getAnimationManager()->setRootContainerSize(pParent->getContentSize());
|
2012-09-17 14:27:17 +08:00
|
|
|
|
|
|
|
CCData *data = new CCData(pBytes, size);
|
2012-11-27 10:26:40 +08:00
|
|
|
CC_SAFE_DELETE_ARRAY(pBytes);
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
data->retain();
|
|
|
|
ccbReader->mData = data;
|
|
|
|
ccbReader->mBytes = data->getBytes();
|
|
|
|
ccbReader->mCurrentByte = 0;
|
|
|
|
ccbReader->mCurrentBit = 0;
|
2012-11-27 10:26:40 +08:00
|
|
|
CC_SAFE_RETAIN(pCCBReader->mOwner);
|
2012-11-26 21:51:05 +08:00
|
|
|
ccbReader->mOwner = pCCBReader->mOwner;
|
|
|
|
|
2013-01-21 14:40:29 +08:00
|
|
|
// The assignments below are done in the CCBReader constructor.
|
|
|
|
// ccbReader->mOwnerOutletNames = pCCBReader->mOwnerOutletNames;
|
|
|
|
// ccbReader->mOwnerOutletNodes = pCCBReader->mOwnerOutletNodes;
|
|
|
|
// ccbReader->mOwnerOutletNodes->retain();
|
|
|
|
// ccbReader->mOwnerCallbackNames = pCCBReader->mOwnerCallbackNames;
|
|
|
|
// ccbReader->mOwnerCallbackNodes = pCCBReader->mOwnerCallbackNodes;
|
|
|
|
// ccbReader->mOwnerCallbackNodes->retain();
|
2012-11-26 21:51:05 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
data->release();
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
CCNode * ccbFileNode = ccbReader->readFileWithCleanUp(false, pCCBReader->getAnimationManagers());
|
2012-10-25 02:32:42 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
if (ccbFileNode && ccbReader->getAnimationManager()->getAutoPlaySequenceId() != -1)
|
|
|
|
{
|
|
|
|
// Auto play animations
|
2012-11-29 18:04:33 +08:00
|
|
|
ccbReader->getAnimationManager()->runAnimationsForSequenceIdTweenDuration(ccbReader->getAnimationManager()->getAutoPlaySequenceId(), 0);
|
2012-09-17 14:27:17 +08:00
|
|
|
}
|
|
|
|
|
2012-06-01 05:57:13 +08:00
|
|
|
return ccbFileNode;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setPosition(pPosition);
|
|
|
|
} else {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setAnchorPoint(pPoint);
|
|
|
|
} else {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setContentSize(pSize);
|
2012-05-31 07:14:02 +08:00
|
|
|
} else {
|
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setScaleX(pScaleLock[0]);
|
2012-06-01 05:57:13 +08:00
|
|
|
pNode->setScaleY(pScaleLock[1]);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pFloat, CCBReader * pCCBReader) {
|
2013-01-21 18:37:17 +08:00
|
|
|
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
|
|
|
// It may be a custom property, add it to custom property dictionary.
|
|
|
|
m_pCustomProperties->setObject(CCBValue::create(pFloat), pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pDegrees, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setRotation(pDegrees);
|
|
|
|
} else {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char* pPropertyName, int pInteger, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_TAG) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setTag(pInteger);
|
|
|
|
} else {
|
2013-01-21 18:37:17 +08:00
|
|
|
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
|
|
|
// It may be a custom property, add it to custom property dictionary.
|
|
|
|
m_pCustomProperties->setObject(CCBValue::create(pInteger), pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char* pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float * pFloatVar, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char* pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) {
|
2012-06-15 15:10:40 +08:00
|
|
|
pNode->setVisible(pCheck);
|
2012-11-26 21:51:05 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) {
|
2012-06-15 15:10:40 +08:00
|
|
|
pNode->ignoreAnchorPointForPosition(pCheck);
|
2012-05-31 02:28:50 +08:00
|
|
|
} else {
|
2013-01-21 18:37:17 +08:00
|
|
|
//ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
|
|
|
// It may be a custom property, add it to custom property dictionary.
|
|
|
|
m_pCustomProperties->setObject(CCBValue::create(pCheck), pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char* pPropertyName, bool * pFlip, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char* pFntFile, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pString, CCBReader * pCCBReader) {
|
2013-01-21 18:37:17 +08:00
|
|
|
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
|
|
|
// It may be a custom property, add it to custom property dictionary.
|
|
|
|
m_pCustomProperties->setObject(CCBValue::create(pString), pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pText, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char* pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) {
|
2012-06-01 05:57:13 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
2012-09-20 11:32:37 +08:00
|
|
|
NS_CC_EXT_END
|