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-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
#define PROPERTY_POSITION "position"
|
|
|
|
#define PROPERTY_CONTENTSIZE "contentSize"
|
|
|
|
#define PROPERTY_ANCHORPOINT "anchorPoint"
|
|
|
|
#define PROPERTY_SCALE "scale"
|
|
|
|
#define PROPERTY_ROTATION "rotation"
|
|
|
|
#define PROPERTY_TAG "tag"
|
|
|
|
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
|
|
|
#define PROPERTY_VISIBLE "visible"
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY); assert(false)
|
2012-05-31 07:14:02 +08:00
|
|
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
USING_NS_CC_EXT;
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
CCNode * ccNode = this->createCCNode(pParent, pCCBReader);
|
|
|
|
|
|
|
|
this->parseProperties(ccNode, pParent, pCCBReader);
|
|
|
|
|
|
|
|
return ccNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCNode * CCNodeLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return CCNode::node();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
int propertyCount = pCCBReader->readInt(false);
|
|
|
|
for(int i = 0; i < propertyCount; i++) {
|
|
|
|
int type = pCCBReader->readInt(false);
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * propertyName = pCCBReader->readCachedString().c_str();
|
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();
|
|
|
|
if(platform == kCCBPlatformAll) {
|
|
|
|
setProp = true;
|
|
|
|
}
|
|
|
|
#ifdef __CC_PLATFORM_IOS
|
|
|
|
if(platform == kCCBPlatformIOS) {
|
|
|
|
setProp = true;
|
|
|
|
}
|
|
|
|
#elif defined(__CC_PLATFORM_MAC)
|
|
|
|
if(platform == kCCBPlatformMac) {
|
|
|
|
setProp = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case kCCBPropTypePosition: {
|
|
|
|
CCPoint position = this->parsePropTypePosition(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypePosition(pNode, pParent, propertyName, position, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypePoint: {
|
|
|
|
CCPoint point = this->parsePropTypePoint(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypePoint(pNode, pParent, propertyName, point, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypePointLock: {
|
|
|
|
CCPoint pointLock = this->parsePropTypePointLock(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypePointLock(pNode, pParent, propertyName, pointLock, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeSize: {
|
|
|
|
CCSize size = this->parsePropTypeSize(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeSize(pNode, pParent, propertyName, size, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeScaleLock: {
|
|
|
|
float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader);
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
delete scaleLock;
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFloat: {
|
|
|
|
float f = this->parsePropTypeFloat(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFloat(pNode, pParent, propertyName, f, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeDegrees: {
|
|
|
|
float degrees = this->parsePropTypeDegrees(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeDegrees(pNode, pParent, propertyName, degrees, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFloatScale: {
|
|
|
|
float floatScale = this->parsePropTypeFloatScale(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFloatScale(pNode, pParent, propertyName, floatScale, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeInteger: {
|
|
|
|
int integer = this->parsePropTypeInteger(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeInteger(pNode, pParent, propertyName, integer, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeIntegerLabeled: {
|
|
|
|
int integerLabeled = this->parsePropTypeIntegerLabeled(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeIntegerLabeled(pNode, pParent, propertyName, integerLabeled, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFloatVar: {
|
|
|
|
float * floatVar = this->parsePropTypeFloatVar(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader);
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
delete floatVar;
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeCheck: {
|
|
|
|
bool check = this->parsePropTypeCheck(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeCheck(pNode, pParent, propertyName, check, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeSpriteFrame: {
|
2012-06-01 03:38:00 +08:00
|
|
|
CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
2012-06-01 03:38:00 +08:00
|
|
|
this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, ccSpriteFrame, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeAnimation: {
|
|
|
|
CCAnimation * ccAnimation = this->parsePropTypeAnimation(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeAnimation(pNode, pParent, propertyName, ccAnimation, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeTexture: {
|
|
|
|
CCTexture2D * ccTexture2D = this->parsePropTypeTexture(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeByte: {
|
|
|
|
unsigned char byte = this->parsePropTypeByte(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeByte(pNode, pParent, propertyName, byte, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeColor3: {
|
|
|
|
ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeColor3(pNode, pParent, propertyName, color3B, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeColor4FVar: {
|
|
|
|
ccColor4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader);
|
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
delete color4FVar;
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFlip: {
|
|
|
|
bool * flip = this->parsePropTypeFlip(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFlip(pNode, pParent, propertyName, flip, pCCBReader);
|
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
delete flip;
|
2012-05-31 02:28:50 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeBlendFunc: {
|
|
|
|
ccBlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader);
|
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName, blendFunc, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeFntFile: {
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-31 06:36:00 +08:00
|
|
|
case kCCBPropTypeFontTTF: {
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader);
|
2012-05-31 06:36:00 +08:00
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-05-31 02:28:50 +08:00
|
|
|
case kCCBPropTypeString: {
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * string = this->parsePropTypeString(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPropTypeText: {
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * text = this->parsePropTypeText(pNode, pParent, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
if(setProp) {
|
|
|
|
this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader);
|
|
|
|
}
|
|
|
|
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-06-05 06:52:49 +08:00
|
|
|
this->onHandlePropTypeBlock(pNode, pParent, propertyName, blockData, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 07:03:45 +08:00
|
|
|
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) {
|
|
|
|
this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName, blockCCControlData, pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
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-06-01 05:57:13 +08:00
|
|
|
this->onHandlePropTypeCCBFile(pNode, pParent, propertyName, 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
|
|
|
CCSize containerSize = pCCBReader->getContainerSize(pParent);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case kCCBPositionTypeRelativeBottomLeft: {
|
|
|
|
/* Nothing. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPositionTypeRelativeTopLeft: {
|
|
|
|
y = containerSize.height - y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPositionTypeRelativeTopRight: {
|
|
|
|
x = containerSize.width - x;
|
|
|
|
y = containerSize.height - y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPositionTypeRelativeBottomRight: {
|
|
|
|
x = containerSize.width - x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBPositionTypePercent: {
|
|
|
|
x = (int)(containerSize.width * x / 100.0f);
|
|
|
|
y = (int)(containerSize.height * y / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CCPoint(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
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);
|
|
|
|
|
|
|
|
CCSize containerSize = pCCBReader->getContainerSize(pParent);
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case kCCBSizeTypeAbsolute: {
|
|
|
|
/* Nothing. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBSizeTypeRelativeContainer: {
|
|
|
|
width = containerSize.width - width;
|
|
|
|
height = containerSize.height - height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBSizeTypePercent: {
|
|
|
|
width = (int)(containerSize.width * width / 100.0f);
|
|
|
|
height = (int)(containerSize.height * height / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBSizeTypeHorizontalPercent: {
|
|
|
|
width = (int)(containerSize.width * width / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kCCBSzieTypeVerticalPercent: {
|
|
|
|
height = (int)(containerSize.height * height / 100.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CCSize(width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float x = pCCBReader->readFloat();
|
|
|
|
float y = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
if(type == kCCBScaleTypeMultiplyResolution) {
|
2012-06-05 07:16:42 +08:00
|
|
|
x *= pCCBReader->getResolutionScale();
|
|
|
|
y *= pCCBReader->getResolutionScale();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float * scaleLock = new float[2];
|
|
|
|
scaleLock[0] = x;
|
|
|
|
scaleLock[1] = y;
|
|
|
|
|
|
|
|
return scaleLock;
|
|
|
|
}
|
|
|
|
|
|
|
|
float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readFloat();
|
|
|
|
}
|
|
|
|
|
|
|
|
float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readFloat();
|
|
|
|
}
|
|
|
|
|
|
|
|
float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float f = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
int type = pCCBReader->readInt(false);
|
|
|
|
|
2012-06-05 08:45:25 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CCNodeLoader::parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readInt(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CCNodeLoader::parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readInt(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
float f = pCCBReader->readFloat();
|
|
|
|
float fVar = pCCBReader->readFloat();
|
|
|
|
|
|
|
|
float * arr = new float[2];
|
|
|
|
arr[0] = f;
|
|
|
|
arr[1] = fVar;
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * spriteSheet = pCCBReader->readCachedString().c_str();
|
|
|
|
const char * spriteFile = pCCBReader->readCachedString().c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
CCSpriteFrame * spriteFrame;
|
2012-06-05 08:45:25 +08:00
|
|
|
if(strcmp(spriteSheet, "") == 0) {
|
|
|
|
if(strcmp(spriteFile, "") == 0) {
|
2012-06-02 06:13:16 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-06-12 09:31:11 +08:00
|
|
|
|
|
|
|
const char * spriteFilePath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteFile).c_str();
|
|
|
|
|
|
|
|
CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath);
|
2012-05-31 02:28:50 +08:00
|
|
|
CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height);
|
|
|
|
spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds);
|
|
|
|
} else {
|
|
|
|
CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
|
2012-06-12 09:31:11 +08:00
|
|
|
|
|
|
|
const char * spriteSheetPath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteSheet).c_str();
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
/* Load the sprite sheet only if it is not loaded. */
|
2012-06-12 09:31:11 +08:00
|
|
|
if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) {
|
|
|
|
frameCache->addSpriteFramesWithFile(spriteSheetPath);
|
|
|
|
pCCBReader->addLoadedSpriteSheet(spriteSheetPath);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
spriteFrame = frameCache->spriteFrameByName(spriteFile);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
return spriteFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * animationFile = pCCBReader->readCachedString().c_str();
|
|
|
|
const char * animation = pCCBReader->readCachedString().c_str();
|
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-06-12 09:31:11 +08:00
|
|
|
animation = pCCBReader->lastPathComponent(animation).c_str();
|
|
|
|
animationFile = pCCBReader->lastPathComponent(animationFile).c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
if(strcmp(animation, "") != 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache();
|
2012-06-05 08:45:25 +08:00
|
|
|
animationCache->addAnimationsWithFile(animationFile);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
ccAnimation = animationCache->animationByName(animation);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
return ccAnimation;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * spriteFile = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pCCBReader->readCachedString().c_str()).c_str();
|
2012-06-02 07:45:30 +08:00
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
return CCTextureCache::sharedTextureCache()->addImage(spriteFile);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
return pCCBReader->readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
unsigned char red = pCCBReader->readByte();
|
|
|
|
unsigned char green = pCCBReader->readByte();
|
|
|
|
unsigned char blue = pCCBReader->readByte();
|
|
|
|
|
|
|
|
ccColor3B color = { red, green, blue };
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
|
|
|
int source = pCCBReader->readInt(false);
|
|
|
|
int destination = pCCBReader->readInt(false);
|
|
|
|
|
|
|
|
ccBlendFunc blendFunc;
|
|
|
|
blendFunc.src = source;
|
|
|
|
blendFunc.dst = destination;
|
|
|
|
|
|
|
|
return blendFunc;
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
return pCCBReader->readCachedString().c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
return pCCBReader->readCachedString().c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
return pCCBReader->readCachedString().c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * fnt = pCCBReader->readCachedString().c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-05 08:45:25 +08:00
|
|
|
const char * ttfEnding("ttf");
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-06-12 09:31:11 +08:00
|
|
|
if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt).c_str(), ttfEnding)){
|
|
|
|
fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt).c_str()).c_str();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return fnt;
|
|
|
|
}
|
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * selectorName = pCCBReader->readCachedString().c_str();
|
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;
|
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
target = pCCBReader->getRootNode();
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(selectorTarget == kCCBTargetTypeOwner) {
|
2012-06-05 06:52:49 +08:00
|
|
|
target = pCCBReader->getOwner();
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
|
|
|
|
if(target != NULL) {
|
2012-06-05 08:45:25 +08:00
|
|
|
if(strlen(selectorName) > 0) {
|
2012-06-14 06:25:59 +08:00
|
|
|
SEL_MenuHandler selMenuHandler = 0;
|
2012-06-14 05:19:13 +08:00
|
|
|
|
|
|
|
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
|
|
|
|
|
|
|
if(targetAsCCBSelectorResolver != NULL) {
|
|
|
|
selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName);
|
|
|
|
}
|
2012-06-14 06:25:59 +08:00
|
|
|
if(selMenuHandler == 0) {
|
2012-06-14 05:19:13 +08:00
|
|
|
CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver();
|
|
|
|
if(ccbSelectorResolver != NULL) {
|
|
|
|
selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 06:25:59 +08:00
|
|
|
if(selMenuHandler == 0) {
|
2012-06-14 05:19:13 +08:00
|
|
|
CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName);
|
|
|
|
} else {
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockData * blockData = new BlockData();
|
2012-06-14 05:19:13 +08:00
|
|
|
blockData->mSELMenuHandler = selMenuHandler;
|
2012-06-05 06:52:49 +08:00
|
|
|
|
|
|
|
blockData->mTarget = target;
|
|
|
|
|
|
|
|
return blockData;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CCLOG("Unexpected empty selector.");
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
2012-06-05 06:52:49 +08:00
|
|
|
} else {
|
|
|
|
CCLOG("Unexpected NULL target for selector.");
|
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-06-12 09:31:11 +08:00
|
|
|
const char * selectorName = pCCBReader->readCachedString().c_str();
|
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) {
|
|
|
|
CCObject * target = NULL;
|
|
|
|
if(selectorTarget == kCCBTargetTypeDocumentRoot) {
|
|
|
|
target = pCCBReader->getRootNode();
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(selectorTarget == kCCBTargetTypeOwner) {
|
2012-06-05 06:52:49 +08:00
|
|
|
target = pCCBReader->getOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(target != NULL) {
|
2012-06-05 08:45:25 +08:00
|
|
|
if(strlen(selectorName) > 0) {
|
2012-06-14 06:25:59 +08:00
|
|
|
SEL_CCControlHandler selCCControlHandler = 0;
|
2012-06-14 05:19:13 +08:00
|
|
|
|
|
|
|
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
|
|
|
|
|
|
|
|
if(targetAsCCBSelectorResolver != NULL) {
|
|
|
|
selCCControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName);
|
|
|
|
}
|
2012-06-14 06:25:59 +08:00
|
|
|
if(selCCControlHandler == 0) {
|
2012-06-14 05:19:13 +08:00
|
|
|
CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver();
|
|
|
|
if(ccbSelectorResolver != NULL) {
|
|
|
|
selCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 06:25:59 +08:00
|
|
|
if(selCCControlHandler == 0) {
|
2012-06-14 05:19:13 +08:00
|
|
|
CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName);
|
|
|
|
} else {
|
2012-06-05 06:52:49 +08:00
|
|
|
BlockCCControlData * blockCCControlData = new BlockCCControlData();
|
2012-06-14 05:19:13 +08:00
|
|
|
blockCCControlData->mSELCCControlHandler = selCCControlHandler;
|
2012-06-05 06:52:49 +08:00
|
|
|
|
|
|
|
blockCCControlData->mTarget = target;
|
|
|
|
blockCCControlData->mControlEvents = controlEvents;
|
|
|
|
|
|
|
|
return blockCCControlData;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CCLOG("Unexpected empty selector.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CCLOG("Unexpected NULL target for selector.");
|
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-06-12 09:31:11 +08:00
|
|
|
const char * ccbFileName = pCCBReader->readCachedString().c_str();
|
2012-06-01 05:57:13 +08:00
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
/* Change path extension to .ccbi. */
|
2012-06-12 09:31:11 +08:00
|
|
|
const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName).c_str();
|
|
|
|
const char * ccbiFileName = pCCBReader->concat(ccbFileWithoutPathExtension, ".ccbi").c_str();
|
2012-06-01 05:57:13 +08:00
|
|
|
|
|
|
|
CCBReader * ccbReader = new CCBReader(pCCBReader);
|
2012-06-06 08:15:28 +08:00
|
|
|
ccbReader->autorelease();
|
2012-06-01 05:57:13 +08:00
|
|
|
|
2012-06-12 09:31:11 +08:00
|
|
|
CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath().c_str(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize());
|
2012-06-01 05:57:13 +08:00
|
|
|
|
|
|
|
return ccbFileNode;
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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 {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) {
|
2012-05-31 02:28:50 +08:00
|
|
|
pNode->setIsVisible(pCheck);
|
2012-06-05 08:45:25 +08:00
|
|
|
} else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) {
|
2012-06-12 01:43:07 +08:00
|
|
|
pNode->setIgnoreAnchorPointForPosition(pCheck);
|
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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +08:00
|
|
|
void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) {
|
2012-05-31 07:14:02 +08:00
|
|
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
2012-05-31 02:28:50 +08:00
|
|
|
}
|
|
|
|
|
2012-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-06-05 08:45:25 +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-05-31 02:28:50 +08:00
|
|
|
}
|