Cleaned up CCNodeLoaders by using the Marco instead of having a boilerplate createCCNode method in all the cpp files.

This commit is contained in:
Nicolas Gramlich 2012-06-18 13:33:19 -07:00
parent aa83408ba7
commit 227683bfa4
32 changed files with 23 additions and 83 deletions

View File

@ -67,7 +67,6 @@ extensions/CCBReader/CCLabelTTFLoader.cpp \
extensions/CCBReader/CCLayerLoader.cpp \
extensions/CCBReader/CCLayerColorLoader.cpp \
extensions/CCBReader/CCLayerGradientLoader.cpp \
extensions/CCBReader/CCMenuLoader.cpp \
extensions/CCBReader/CCMenuItemLoader.cpp \
extensions/CCBReader/CCMenuItemImageLoader.cpp \
extensions/CCBReader/CCSpriteLoader.cpp \

View File

@ -5,10 +5,6 @@ USING_NS_CC_EXT;
#define PROPERTY_CCBFILE "ccbFile"
CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCNode::node();
}
void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_CCBFILE) == 0) {
pNode->addChild(pCCBFileNode);

View File

@ -14,7 +14,7 @@ class CC_DLL CCBFileLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader);
protected:
virtual CCNode * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode);
virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode *, CCBReader *);
};

View File

@ -22,10 +22,6 @@ USING_NS_CC_EXT;
#define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2"
#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3"
CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCControlButton::node();
}
void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) {
((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck);

View File

@ -14,7 +14,7 @@ class CC_DLL CCControlButtonLoader : public CCControlLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader);
protected:
virtual CCControl * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControlButton);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *);
virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);

View File

@ -13,7 +13,7 @@ class CC_DLL CCControlLoader : public CCNodeLoader {
virtual ~CCControlLoader() {};
protected:
virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0;
CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControl);
virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData *, CCBReader *);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *);

View File

@ -9,10 +9,6 @@ USING_NS_CC_EXT;
#define PROPERTY_FNTFILE "fntFile"
#define PROPERTY_STRING "string"
CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCLabelBMFont::node();
}
void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLabelBMFont *)pNode)->setColor(pCCColor3B);

View File

@ -14,7 +14,7 @@ class CC_DLL CCLabelBMFontLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader);
protected:
virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelBMFont);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -13,10 +13,6 @@ USING_NS_CC_EXT;
#define PROPERTY_STRING "string"
#define PROPERTY_DIMENSIONS "dimensions"
CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCLabelTTF::node();
}
void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLabelTTF *)pNode)->setColor(pCCColor3B);

View File

@ -14,7 +14,7 @@ class CC_DLL CCLabelTTFLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader);
protected:
virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelTTF);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -7,10 +7,6 @@ USING_NS_CC_EXT;
#define PROPERTY_OPACITY "opacity"
#define PROPERTY_BLENDFUNC "blendFunc"
CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCLayerColor::node();
}
void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLayerColor *)pNode)->setColor(pCCColor3B);

View File

@ -14,7 +14,7 @@ class CC_DLL CCLayerColorLoader : public CCLayerLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader);
protected:
virtual CCLayerColor * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerColor);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -10,10 +10,6 @@ USING_NS_CC_EXT;
#define PROPERTY_VECTOR "vector"
#define PROPERTY_BLENDFUNC "blendFunc"
CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCLayerGradient::node();
}
void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) {
((CCLayerGradient *)pNode)->setStartColor(pCCColor3B);

View File

@ -14,7 +14,7 @@ class CC_DLL CCLayerGradientLoader : public CCLayerLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader);
protected:
virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerGradient);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -8,10 +8,6 @@ USING_NS_CC_EXT;
#define PROPERTY_MOUSE_ENABLED "isMouseEnabled"
#define PROPERTY_KEYBOARD_ENABLED "isKeyboardEnabled"
CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCLayer::node();
}
void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_TOUCH_ENABLED) == 0) {
((CCLayer *)pNode)->setTouchEnabled(pCheck);

View File

@ -14,7 +14,7 @@ class CC_DLL CCLayerLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader);
protected:
virtual CCLayer * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayer);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader);
};

View File

@ -7,10 +7,6 @@ USING_NS_CC_EXT;
#define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame"
#define PROPERTY_DISABLEDDISPLAYFRAME "disabledSpriteFrame"
CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCMenuItemImage::node();
}
void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_NORMALDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) {

View File

@ -14,7 +14,7 @@ class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader);
protected:
virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItemImage);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *);
};

View File

@ -11,8 +11,9 @@ class CCBReader;
class CC_DLL CCMenuItemLoader : public CCNodeLoader {
public:
virtual ~CCMenuItemLoader() {};
protected:
virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0;
CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItem);
virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData *, CCBReader *);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *);

View File

@ -1,9 +0,0 @@
#include "CCMenuLoader.h"
USING_NS_CC;
USING_NS_CC_EXT;
CCMenu * CCMenuLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCMenu::node();
}

View File

@ -14,7 +14,7 @@ class CC_DLL CCMenuLoader : public CCLayerLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader);
protected:
virtual CCMenu * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenu);
};
NS_CC_EXT_END

View File

@ -25,10 +25,6 @@ CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * 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++) {

View File

@ -7,9 +7,11 @@
NS_CC_EXT_BEGIN
#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \
return T::node(); \
return T::node(); \
}
#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0
struct BlockData {
SEL_MenuHandler mSELMenuHandler;
CCObject * mTarget;
@ -33,7 +35,7 @@ class CC_DLL CCNodeLoader : public CCObject {
virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
protected:
virtual CCNode * createCCNode(CCNode * pParent, CCBReader * pCCBReader);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode);
virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual CCPoint parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);

View File

@ -26,10 +26,6 @@ USING_NS_CC_EXT;
#define PROPERTY_ENDRADIUS "endRadius"
#define PROPERTY_ROTATEPERSECOND "rotatePerSecond"
CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCParticleSystemQuad::node();
}
void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_EMITERMODE) == 0) {
((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled);

View File

@ -14,7 +14,7 @@ class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader);
protected:
virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCParticleSystemQuad);
virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *);
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *);

View File

@ -14,10 +14,6 @@ USING_NS_CC_EXT;
#define PROPERTY_INSETRIGHT "insetRight"
#define PROPERTY_INSETBOTTOM "insetBottom"
CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCScale9Sprite::node();
}
void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_SPRITEFRAME) == 0) {
((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame);

View File

@ -14,7 +14,7 @@ class CC_DLL CCScale9SpriteLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader);
protected:
virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScale9Sprite);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -1,10 +1,7 @@
#include "CCScrollViewLoader.h"
NS_CC_EXT_BEGIN
CCScrollView * CCScrollViewLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCScrollView::node();
}
USING_NS_CC;
USING_NS_CC_EXT;
void CCScrollViewLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
@ -30,5 +27,3 @@ void CCScrollViewLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent,
{
}
NS_CC_EXT_END

View File

@ -14,7 +14,7 @@ class CC_DLL CCScrollViewLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScrollViewLoader, loader);
protected:
virtual CCScrollView * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScrollView);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -9,10 +9,6 @@ USING_NS_CC_EXT;
#define PROPERTY_OPACITY "opacity"
#define PROPERTY_BLENDFUNC "blendFunc"
CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCSprite::node();
}
void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_DISPLAYFRAME) == 0) {
((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame);

View File

@ -14,7 +14,7 @@ class CC_DLL CCSpriteLoader : public CCNodeLoader {
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader);
protected:
virtual CCSprite * createCCNode(CCNode *, CCBReader *);
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCSprite);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);

View File

@ -1 +1 @@
b0bc510824d786752a37f8b48a77a4c418c146b4
96920b02a30e4746149c7b1b150ff3f6d9cd4e68