2012-06-13 02:59:49 +08:00
|
|
|
#ifndef _CCB_CCNODELOADER_H_
|
|
|
|
#define _CCB_CCNODELOADER_H_
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-07-30 22:57:59 +08:00
|
|
|
#include "../GUI/CCControlExtension/CCInvocation.h"
|
2012-05-31 02:28:50 +08:00
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "CCBReader.h"
|
2013-01-21 18:37:17 +08:00
|
|
|
#include "CCBValue.h"
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2012-09-09 22:34:32 +08:00
|
|
|
#define PROPERTY_POSITION "position"
|
|
|
|
#define PROPERTY_CONTENTSIZE "contentSize"
|
2013-03-15 08:43:56 +08:00
|
|
|
#define PROPERTY_SKEW "skew"
|
2012-09-09 22:34:32 +08:00
|
|
|
#define PROPERTY_ANCHORPOINT "anchorPoint"
|
|
|
|
#define PROPERTY_SCALE "scale"
|
|
|
|
#define PROPERTY_ROTATION "rotation"
|
2013-03-20 14:25:30 +08:00
|
|
|
#define PROPERTY_ROTATIONX "rotationX"
|
|
|
|
#define PROPERTY_ROTATIONY "rotationY"
|
2012-09-09 22:34:32 +08:00
|
|
|
#define PROPERTY_TAG "tag"
|
|
|
|
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
|
|
|
#define PROPERTY_VISIBLE "visible"
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY); assert(false)
|
2012-09-09 22:34:32 +08:00
|
|
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
|
|
|
|
|
2012-09-24 15:26:18 +08:00
|
|
|
#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \
|
2012-06-20 11:48:31 +08:00
|
|
|
return T::create(); \
|
2012-06-15 05:23:53 +08:00
|
|
|
}
|
|
|
|
|
2012-09-24 15:26:18 +08:00
|
|
|
#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0
|
2012-06-19 04:33:19 +08:00
|
|
|
|
2012-06-05 06:52:49 +08:00
|
|
|
struct BlockData {
|
|
|
|
SEL_MenuHandler mSELMenuHandler;
|
|
|
|
CCObject * mTarget;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BlockCCControlData {
|
2012-06-07 05:32:15 +08:00
|
|
|
SEL_CCControlHandler mSELCCControlHandler;
|
2012-06-05 06:52:49 +08:00
|
|
|
CCObject * mTarget;
|
|
|
|
int mControlEvents;
|
|
|
|
};
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
/* Forward declaration. */
|
|
|
|
class CCBReader;
|
|
|
|
|
2012-07-20 14:05:52 +08:00
|
|
|
class CCNodeLoader : public CCObject {
|
2012-05-31 02:28:50 +08:00
|
|
|
public:
|
2013-01-21 18:37:17 +08:00
|
|
|
CCNodeLoader();
|
|
|
|
virtual ~CCNodeLoader();
|
2012-06-15 05:23:53 +08:00
|
|
|
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader);
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader);
|
|
|
|
virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2013-01-21 18:37:17 +08:00
|
|
|
virtual CCDictionary* getCustomProperties();
|
|
|
|
|
2012-05-31 02:28:50 +08:00
|
|
|
protected:
|
2012-06-19 04:33:19 +08:00
|
|
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual CCPoint parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual CCPoint parsePropTypePointLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual CCSize parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual float * parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual float parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual float parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual float parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual int parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual int parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual float * parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual bool parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
|
|
|
virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual CCAnimation * parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual CCTexture2D * parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-09-17 14:27:17 +08:00
|
|
|
virtual unsigned char parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
|
|
|
virtual ccColor3B parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-11-26 21:51:05 +08:00
|
|
|
virtual std::string parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual std::string parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual std::string parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual std::string parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-06-14 06:57:59 +08:00
|
|
|
virtual BlockData * parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
|
|
|
virtual CCNode * parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2013-03-15 08:43:56 +08:00
|
|
|
virtual float * parsePropTypeFloatXY(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
|
2012-05-31 02:28:50 +08:00
|
|
|
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPosition, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPoint, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCSize pSize, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pFloat, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pDegrees, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float pFloatScale, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char* pPropertyName, int pInteger, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char* pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float * pFoatVar, CCBReader * pCCBReader);
|
2013-03-15 08:43:56 +08:00
|
|
|
virtual void onHandlePropTypeFloatXY(CCNode * pNode, CCNode * pParent, const char* pPropertyName, float * pFoatVar, CCBReader * pCCBReader);
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char* pPropertyName, bool pCheck, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char* pPropertyName, bool * pFlip, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char* pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pFntFile, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pString, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pText, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char* pPropertyName, const char * pFontTTF, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char* pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char* pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader);
|
|
|
|
virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char* pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader);
|
2013-01-21 18:37:17 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CCDictionary* m_pCustomProperties;
|
2012-05-31 02:28:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|
|
|
|
|
|
|
|
#endif
|