Merge branch 'gles20-ccbi' of https://github.com/nicolasgramlich/cocos2d-x into gles20-ccbi

This commit is contained in:
James Chen 2012-06-16 11:05:28 +08:00
commit ab3dd66167
66 changed files with 866 additions and 629 deletions

View File

@ -124,6 +124,11 @@ unsigned int CCString::length() const
return m_sString.length(); return m_sString.length();
} }
int CCString::compare(const char * pStr) const
{
return strcmp(getCString(), pStr);
}
CCObject* CCString::copyWithZone(CCZone* pZone) CCObject* CCString::copyWithZone(CCZone* pZone)
{ {
CCAssert(pZone == NULL, "CCString should not be inherited."); CCAssert(pZone == NULL, "CCString should not be inherited.");
@ -157,6 +162,31 @@ CCString* CCString::create(const char* pStr)
return pRet; return pRet;
} }
CCString* CCString::stringWithString(const std::string& pStr)
{
CCString* pRet = new CCString(pStr);
pRet->autorelease();
return pRet;
}
CCString* CCString::stringWithCStringData(const char* pData, unsigned long nLen)
{
CCString* pRet = NULL;
if (pData != NULL)
{
char* pStr = (char*)malloc(nLen+1);
if (pStr != NULL)
{
pStr[nLen] = '\0';
memcpy(pStr, pData, nLen);
pRet = CCString::stringWithCString(pStr);
free(pStr);
}
}
return pRet;
}
CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen)
{ {
return CCString::createWithData(pData, nLen); return CCString::createWithData(pData, nLen);

View File

@ -66,6 +66,9 @@ public:
/** get the length of string */ /** get the length of string */
unsigned int length() const; unsigned int length() const;
/** compare to a c string */
int compare(const char *) const;
/* override functions */ /* override functions */
virtual CCObject* copyWithZone(CCZone* pZone); virtual CCObject* copyWithZone(CCZone* pZone);
virtual bool isEqual(const CCObject* pObject); virtual bool isEqual(const CCObject* pObject);
@ -78,6 +81,18 @@ public:
*/ */
static CCString* stringWithCString(const char* pStr); static CCString* stringWithCString(const char* pStr);
/** create a string with c string
* @return A CCString pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it.
*/
static CCString* stringWithCStringData(const char* pData, unsigned long nLen);
/** create a string with std::string
* @return A CCString pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it.
*/
static CCString* stringWithString(const std::string& str);
/** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes,
* if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file.
* @return A CCString pointer which is an autorelease object pointer, * @return A CCString pointer which is an autorelease object pointer,
@ -134,6 +149,13 @@ public:
std::string m_sString; std::string m_sString;
}; };
struct CCStringCompare : public std::binary_function<CCString *, CCString *, bool> {
public:
bool operator() (CCString * a, CCString * b) const {
return strcmp(a->getCString(), b->getCString()) < 0;
}
};
#define CCStringMake(str) CCString::create(str) #define CCStringMake(str) CCString::create(str)
#define ccs CCStringMake #define ccs CCStringMake

View File

@ -9,8 +9,8 @@ CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
return CCNode::node(); return CCNode::node();
} }
void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_CCBFILE) == 0) { if(pPropertyName->compare(PROPERTY_CCBFILE) == 0) {
pNode->addChild(pCCBFileNode); pNode->addChild(pCCBFileNode);
} else { } else {
CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader);

View File

@ -10,12 +10,12 @@ class CCBReader;
class CC_DLL CCBFileLoader : public CCNodeLoader { class CC_DLL CCBFileLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader);
protected: protected:
virtual CCNode * createCCNode(CCNode *, CCBReader *); virtual CCNode * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode *, CCBReader *); virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode *, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -5,9 +5,16 @@
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
#define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) if(pTarget == TARGET && pMemberVariableName->compare(MEMBERVARIABLENAME) == 0) { \
MEMBERVARIABLE = dynamic_cast<MEMBERVARIABLETYPE>(pNode); \
CC_ASSERT(MEMBERVARIABLE); \
MEMBERVARIABLE->retain(); \
return true; \
}
class CC_DLL CCBMemberVariableAssigner { class CC_DLL CCBMemberVariableAssigner {
public: public:
virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) = 0; virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -35,25 +35,6 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab
#endif #endif
} }
CCBReader::~CCBReader() {
if(this->mBytes != NULL) {
delete this->mBytes;
this->mBytes = NULL;
}
this->mCCNodeLoaderLibrary->release();
/* Clear string cache. */
this->mStringCache.clear();
if(this->mRootCCBReader) {
/* Clear loaded spritesheets. */
this->mLoadedSpriteSheets.clear();
}
CC_SAFE_RELEASE(this->mRootNode);
}
CCBReader::CCBReader(CCBReader * pCCBReader) { CCBReader::CCBReader(CCBReader * pCCBReader) {
this->mRootNode = NULL; this->mRootNode = NULL;
this->mRootCCBReader = false; this->mRootCCBReader = false;
@ -69,7 +50,25 @@ CCBReader::CCBReader(CCBReader * pCCBReader) {
this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener; this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener;
} }
std::string CCBReader::getCCBRootPath() { CCBReader::~CCBReader() {
CC_SAFE_DELETE(this->mBytes);
this->mCCNodeLoaderLibrary->release();
/* Clear string cache. */
std::vector<CCString *>::iterator stringCacheIterator;
for (stringCacheIterator = this->mStringCache.begin(); stringCacheIterator != this->mStringCache.end(); stringCacheIterator++) {
(*stringCacheIterator)->release();
}
this->mStringCache.clear();
if(this->mRootCCBReader) {
/* Clear loaded spritesheets. */
this->mLoadedSpriteSheets.clear();
}
}
CCString * CCBReader::getCCBRootPath() {
return this->mCCBRootPath; return this->mCCBRootPath;
} }
@ -89,16 +88,21 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char
return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize());
} }
CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner) {
return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize());
}
CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) {
return this->readNodeGraphFromFile(CCString::stringWithCString(pCCBRootPath), CCString::stringWithCString(pCCBFileName), pOwner, pRootContainerSize);
}
CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) {
this->mCCBRootPath = pCCBRootPath; this->mCCBRootPath = pCCBRootPath;
this->mCCBRootPath->retain();
char* ccbFullFilePath = (char*)malloc(strlen(pCCBRootPath) + strlen(pCCBFileName) + 1); CCString * ccbFullFilePath = CCBReader::concat(pCCBRootPath, pCCBFileName);
ccbFullFilePath[strlen(pCCBRootPath) + strlen(pCCBFileName)] = '\0';
strcpy(ccbFullFilePath, pCCBRootPath); const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString());
strcat(ccbFullFilePath, pCCBFileName);
const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath);
CC_SAFE_FREE(ccbFullFilePath); CC_SAFE_FREE(ccbFullFilePath);
@ -107,18 +111,21 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char
this->mCurrentByte = 0; this->mCurrentByte = 0;
this->mCurrentBit = 0; this->mCurrentBit = 0;
this->mOwner = pOwner; this->mOwner = pOwner;
this->mOwner->retain();
this->mRootContainerSize = pRootContainerSize; this->mRootContainerSize = pRootContainerSize;
if(!this->readHeader()) { CCNode * node = NULL;
return NULL; if(this->readHeader() && this->readStringCache()) {
node = this->readNodeGraph();
} }
if(!this->readStringCache()) { CC_SAFE_RELEASE(this->mOwner);
return NULL; CC_SAFE_RELEASE(this->mCCBRootPath);
} CC_SAFE_RELEASE(this->mRootNode);
return this->readNodeGraph(); return node;
} }
bool CCBReader::readHeader() { bool CCBReader::readHeader() {
@ -162,7 +169,8 @@ void CCBReader::readStringCacheEntry() {
int numBytes = b0 << 8 | b1; int numBytes = b0 << 8 | b1;
const char * src = (const char *) (this->mBytes + this->mCurrentByte); const char * src = (const char *) (this->mBytes + this->mCurrentByte);
std::string string(src, numBytes); CCString * string = CCString::stringWithCStringData(src, (unsigned long)numBytes);
string->retain();
this->mCurrentByte += numBytes; this->mCurrentByte += numBytes;
@ -264,19 +272,19 @@ void CCBReader::alignBits() {
} }
} }
std::string CCBReader::readCachedString() { CCString * CCBReader::readCachedString() {
int i = this->readInt(false); int i = this->readInt(false);
return this->mStringCache[i]; return this->mStringCache[i];
} }
CCNode * CCBReader::readNodeGraph(CCNode * pParent) { CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
/* Read class name. */ /* Read class name. */
const char * className = this->readCachedString().c_str(); CCString * className = this->readCachedString();
int memberVarAssignmentType = this->readInt(false); int memberVarAssignmentType = this->readInt(false);
const char * memberVarAssignmentName; CCString * memberVarAssignmentName;
if(memberVarAssignmentType != kCCBTargetTypeNone) { if(memberVarAssignmentType != kCCBTargetTypeNone) {
memberVarAssignmentName = this->readCachedString().c_str(); memberVarAssignmentName = this->readCachedString();
} }
CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className);
@ -348,49 +356,54 @@ CCSize CCBReader::getContainerSize(CCNode * pNode) {
} }
} }
bool CCBReader::isSpriteSheetLoaded(const char * pSpriteSheet) { bool CCBReader::isSpriteSheetLoaded(CCString * pSpriteSheet) {
return this->mLoadedSpriteSheets.find(pSpriteSheet) != this->mLoadedSpriteSheets.end(); return this->mLoadedSpriteSheets.find(pSpriteSheet->m_sString) != this->mLoadedSpriteSheets.end();
} }
void CCBReader::addLoadedSpriteSheet(const char * pSpriteSheet) { void CCBReader::addLoadedSpriteSheet(CCString * pSpriteSheet) {
this->mLoadedSpriteSheets.insert(pSpriteSheet); pSpriteSheet->retain();
this->mLoadedSpriteSheets.insert(pSpriteSheet->m_sString);
} }
std::string CCBReader::lastPathComponent(const char * pPath) { CCString * CCBReader::lastPathComponent(CCString * pPath) {
std::string path(pPath); std::string path(pPath->getCString());
int slashPos = path.find_last_of("/"); int slashPos = path.find_last_of("/");
if(slashPos != std::string::npos) { if(slashPos != std::string::npos) {
return path.substr(slashPos + 1, path.length() - slashPos); return CCString::stringWithCString(path.substr(slashPos + 1, path.length() - slashPos).c_str());
} }
return path; return CCString::stringWithCString(path.c_str());
} }
std::string CCBReader::deletePathExtension(const char * pPath) { CCString * CCBReader::deletePathExtension(CCString * pPath) {
std::string path(pPath); std::string path(pPath->getCString());
int dotPos = path.find_last_of("."); int dotPos = path.find_last_of(".");
if(dotPos != std::string::npos) { if(dotPos != std::string::npos) {
return path.substr(0, dotPos); return CCString::stringWithCString(path.substr(0, dotPos).c_str());
} }
return path; return CCString::stringWithCString(path.c_str());
} }
std::string CCBReader::toLowerCase(const char * pString) { CCString * CCBReader::toLowerCase(CCString * pString) {
std::string copy(pString); std::string copy(pString->getCString());
std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower);
return copy; return CCString::stringWithCString(copy.c_str());
} }
std::string CCBReader::concat(const char * pStringA, const char * pStringB) { CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) {
std::string stringA(pStringA); int concatenatedLength = pStringA->length() + pStringB->length() + 1;
std::string stringB(pStringB); char concatenated[concatenatedLength];
std::string string = stringA + stringB; strcpy(concatenated, pStringA->getCString());
return string; strcat(concatenated, pStringB->getCString());
concatenated[concatenatedLength] = '\0';
return CCString::stringWithCString(concatenated);
} }
bool CCBReader::endsWith(const char * pString, const char * pEnding) { bool CCBReader::endsWith(CCString * pString, CCString * pEnding) {
std::string string(pString); std::string string(pString->getCString());
std::string ending(pEnding); std::string ending(pEnding->getCString());
if(string.length() >= ending.length()) { if(string.length() >= ending.length()) {
return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0); return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0);
} else { } else {

View File

@ -3,10 +3,24 @@
#include "cocos2d.h" #include "cocos2d.h"
#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \
T * t = new T(); \ T * ptr = new T(); \
t->autorelease(); \ if(ptr != NULL) { \
return t; \ ptr->autorelease(); \
return ptr; \
} \
CC_SAFE_DELETE(ptr); \
return NULL; \
}
#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(T, METHOD) static T * METHOD() { \
T * ptr = new T(); \
if(ptr != NULL && ptr->init()) { \
ptr->autorelease(); \
return ptr; \
} \
CC_SAFE_DELETE(ptr); \
return NULL; \
} }
#define kCCBVersion 2 #define kCCBVersion 2
@ -84,7 +98,7 @@ class CCBSelectorResolver;
*/ */
class CC_DLL CCBReader : public CCObject { class CC_DLL CCBReader : public CCObject {
private: private:
std::string mCCBRootPath; CCString * mCCBRootPath;
bool mRootCCBReader; bool mRootCCBReader;
unsigned char * mBytes; unsigned char * mBytes;
@ -100,7 +114,7 @@ class CC_DLL CCBReader : public CCObject {
CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBMemberVariableAssigner * mCCBMemberVariableAssigner;
CCBSelectorResolver * mCCBSelectorResolver; CCBSelectorResolver * mCCBSelectorResolver;
std::vector<std::string> mStringCache; std::vector<CCString *> mStringCache;
std::set<std::string> mLoadedSpriteSheets; std::set<std::string> mLoadedSpriteSheets;
public: public:
@ -111,32 +125,35 @@ class CC_DLL CCBReader : public CCObject {
~CCBReader(); ~CCBReader();
CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL);
CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner = NULL);
CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize);
CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize);
CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); CCBMemberVariableAssigner * getCCBMemberVariableAssigner();
CCBSelectorResolver * getCCBSelectorResolver(); CCBSelectorResolver * getCCBSelectorResolver();
std::string getCCBRootPath(); CCString * getCCBRootPath();
CCObject * getOwner(); CCObject * getOwner();
CCNode * getRootNode(); CCNode * getRootNode();
CCSize getContainerSize(CCNode *); CCSize getContainerSize(CCNode *);
float getResolutionScale(); float getResolutionScale();
bool isSpriteSheetLoaded(const char *); bool isSpriteSheetLoaded(CCString *);
void addLoadedSpriteSheet(const char *); void addLoadedSpriteSheet(CCString *);
/* Utility methods. */ /* Utility methods. */
std::string lastPathComponent(const char *); static CCString * lastPathComponent(CCString *);
std::string deletePathExtension(const char *); static CCString * deletePathExtension(CCString *);
std::string toLowerCase(const char *); static CCString * toLowerCase(CCString *);
bool endsWith(const char *, const char *); static bool endsWith(CCString *, CCString *);
std::string concat(const char *, const char *); static CCString * concat(CCString *, CCString *);
/* Parse methods. */ /* Parse methods. */
int readInt(bool pSign); int readInt(bool pSign);
unsigned char readByte(); unsigned char readByte();
bool readBool(); bool readBool();
float readFloat(); float readFloat();
std::string readCachedString(); CCString * readCachedString();
private: private:
bool readHeader(); bool readHeader();
@ -147,7 +164,7 @@ class CC_DLL CCBReader : public CCObject {
bool getBit(); bool getBit();
void alignBits(); void alignBits();
const char * readUTF8(); CCString * readUTF8();
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -5,10 +5,18 @@
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
#define CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && pSelectorName->compare(SELECTORNAME) == 0) { \
return menu_selector(METHOD); \
}
#define CCB_SELECTORRESOLVER_CCCONTROL_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && pSelectorName->compare(SELECTORNAME) == 0) { \
return cccontrol_selector(METHOD); \
}
class CC_DLL CCBSelectorResolver { class CC_DLL CCBSelectorResolver {
public: public:
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) = 0; virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0;
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) = 0; virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0;
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -26,82 +26,76 @@ CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pC
return CCControlButton::node(); return CCControlButton::node();
} }
void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_ZOOMONTOUCHDOWN) == 0) { if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) {
((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck); ((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck);
} else { } else {
CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { if(pPropertyName->compare(PROPERTY_TITLE_NORMAL) == 0) {
CCString * ccString = new CCString(pString); ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateNormal);
ccString->autorelease(); } else if(pPropertyName->compare(PROPERTY_TITLE_HIGHLIGHTED) == 0) {
((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateNormal); ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateHighlighted);
} else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLE_DISABLED) == 0) {
CCString * ccString = new CCString(pString); ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateDisabled);
ccString->autorelease();
((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateHighlighted);
} else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) {
CCString * ccString = new CCString(pString);
ccString->autorelease();
((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateDisabled);
} else { } else {
CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) { if(pPropertyName->compare(PROPERTY_TITLETTF_NORMAL) == 0) {
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateNormal); ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateNormal);
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLETTF_HIGHLIGHTED) == 0) {
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateHighlighted); ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateHighlighted);
} else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLETTF_DISABLED) == 0) {
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateDisabled); ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateDisabled);
} else { } else {
CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) { if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_NORMAL) == 0) {
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal); ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal);
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) {
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted); ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted);
} else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_DISABLED) == 0) {
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled); ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled);
} else { } else {
CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) { if(pPropertyName->compare(PROPERTY_LABELANCHORPOINT) == 0) {
((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint); ((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint);
} else { } else {
CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { if(pPropertyName->compare(PROPERTY_PREFEREDSIZE) == 0) {
((CCControlButton *)pNode)->setPreferredSize(pSize); ((CCControlButton *)pNode)->setPreferredSize(pSize);
} else { } else {
CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
} }
} }
void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal); ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal);
} }
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { } else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted); ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted);
} }
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled); ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled);
} }
@ -110,12 +104,12 @@ void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode *
} }
} }
void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) { if(pPropertyName->compare(PROPERTY_TITLECOLOR_NORMAL) == 0) {
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal); ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal);
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted); ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted);
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_TITLECOLOR_DISABLED) == 0) {
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled); ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled);
} else { } else {
CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);

View File

@ -10,19 +10,19 @@ class CCBReader;
class CC_DLL CCControlButtonLoader : public CCControlLoader { class CC_DLL CCControlButtonLoader : public CCControlLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader);
protected: protected:
virtual CCControl * createCCNode(CCNode *, CCBReader *); virtual CCControl * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *);
virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *);
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *);
virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -7,18 +7,18 @@ USING_NS_CC_EXT;
#define PROPERTY_SELECTED "selected" #define PROPERTY_SELECTED "selected"
#define PROPERTY_CCCONTROL "ccControl" #define PROPERTY_CCCONTROL "ccControl"
void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_ENABLED) == 0) { if(pPropertyName->compare(PROPERTY_ENABLED) == 0) {
((CCControl *)pNode)->setEnabled(pCheck); ((CCControl *)pNode)->setEnabled(pCheck);
} else if(strcmp(pPropertyName, PROPERTY_SELECTED) == 0) { } else if(pPropertyName->compare(PROPERTY_SELECTED) == 0) {
((CCControl *)pNode)->setSelected(pCheck); ((CCControl *)pNode)->setSelected(pCheck);
} else { } else {
CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
} }
} }
void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { if(pPropertyName->compare(PROPERTY_CCCONTROL) == 0) {
((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELCCControlHandler, pBlockCCControlData->mControlEvents); ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELCCControlHandler, pBlockCCControlData->mControlEvents);
} else { } else {
CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader); CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader);

View File

@ -12,8 +12,8 @@ class CC_DLL CCControlLoader : public CCNodeLoader {
protected: protected:
virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0;
virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData *, CCBReader *); virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData *, CCBReader *);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -13,41 +13,41 @@ CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader *
return CCLabelBMFont::node(); return CCLabelBMFont::node();
} }
void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLabelBMFont *)pNode)->setColor(pCCColor3B); ((CCLabelBMFont *)pNode)->setColor(pCCColor3B);
} else { } else {
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
((CCLabelBMFont *)pNode)->setOpacity(pByte); ((CCLabelBMFont *)pNode)->setOpacity(pByte);
} else { } else {
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCLabelBMFont *)pNode)->setBlendFunc(pCCBlendFunc); ((CCLabelBMFont *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
} }
} }
void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_FNTFILE) == 0) { if(pPropertyName->compare(PROPERTY_FNTFILE) == 0) {
((CCLabelBMFont *)pNode)->setFntFile(pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pFntFile).c_str()); ((CCLabelBMFont *)pNode)->setFntFile(pFntFile->getCString());
} else { } else {
CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader);
} }
} }
void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { if(pPropertyName->compare(PROPERTY_STRING) == 0) {
((CCLabelBMFont *)pNode)->setString(pText); ((CCLabelBMFont *)pNode)->setString(pText->getCString());
} else { } else {
CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader);
} }

View File

@ -10,16 +10,16 @@ class CCBReader;
class CC_DLL CCLabelBMFontLoader : public CCNodeLoader { class CC_DLL CCLabelBMFontLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader);
protected: protected:
virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -17,66 +17,66 @@ CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBRe
return CCLabelTTF::node(); return CCLabelTTF::node();
} }
void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLabelTTF *)pNode)->setColor(pCCColor3B); ((CCLabelTTF *)pNode)->setColor(pCCColor3B);
} else { } else {
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
((CCLabelTTF *)pNode)->setOpacity(pByte); ((CCLabelTTF *)pNode)->setOpacity(pByte);
} else { } else {
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc); ((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) { if(pPropertyName->compare(PROPERTY_FONTNAME) == 0) {
((CCLabelTTF *)pNode)->setFontName(pFontTTF); ((CCLabelTTF *)pNode)->setFontName(pFontTTF->getCString());
} else { } else {
CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { if(pPropertyName->compare(PROPERTY_STRING) == 0) {
((CCLabelTTF *)pNode)->setString(pText); ((CCLabelTTF *)pNode)->setString(pText->getCString());
} else { } else {
CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) { if(pPropertyName->compare(PROPERTY_FONTSIZE) == 0) {
((CCLabelTTF *)pNode)->setFontSize(pFloatScale); ((CCLabelTTF *)pNode)->setFontSize(pFloatScale);
} else { } else {
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { if(pPropertyName->compare(PROPERTY_HORIZONTALALIGNMENT) == 0) {
((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled)); ((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled));
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { } else if(pPropertyName->compare(PROPERTY_VERTICALALIGNMENT) == 0) {
((CCLabelTTF *)pNode)->setVerticalAlignment(CCVerticalTextAlignment(pIntegerLabeled)); ((CCLabelTTF *)pNode)->setVerticalAlignment(CCVerticalTextAlignment(pIntegerLabeled));
} else { } else {
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
} }
} }
void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) { if(pPropertyName->compare(PROPERTY_DIMENSIONS) == 0) {
((CCLabelTTF *)pNode)->setDimensions(pSize); ((CCLabelTTF *)pNode)->setDimensions(pSize);
} else { } else {
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);

View File

@ -10,19 +10,19 @@ class CCBReader;
class CC_DLL CCLabelTTFLoader : public CCNodeLoader { class CC_DLL CCLabelTTFLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader);
protected: protected:
virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *);
virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *);
virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *);
virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -11,24 +11,24 @@ CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pC
return CCLayerColor::node(); return CCLayerColor::node();
} }
void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCLayerColor *)pNode)->setColor(pCCColor3B); ((CCLayerColor *)pNode)->setColor(pCCColor3B);
} else { } else {
CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
((CCLayerColor *)pNode)->setOpacity(pByte); ((CCLayerColor *)pNode)->setOpacity(pByte);
} else { } else {
CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCLayerColor *)pNode)->setBlendFunc(pCCBlendFunc); ((CCLayerColor *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);

View File

@ -10,13 +10,13 @@ class CCBReader;
class CC_DLL CCLayerColorLoader : public CCLayerLoader { class CC_DLL CCLayerColorLoader : public CCLayerLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader);
protected: protected:
virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); virtual CCLayerColor * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -14,28 +14,28 @@ CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReade
return CCLayerGradient::node(); return CCLayerGradient::node();
} }
void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) {
((CCLayerGradient *)pNode)->setStartColor(pCCColor3B); ((CCLayerGradient *)pNode)->setStartColor(pCCColor3B);
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDCOLOR) == 0) {
((CCLayerGradient *)pNode)->setEndColor(pCCColor3B); ((CCLayerGradient *)pNode)->setEndColor(pCCColor3B);
} else { } else {
CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) { if(pPropertyName->compare(PROPERTY_STARTOPACITY) == 0) {
((CCLayerGradient *)pNode)->setStartOpacity(pByte); ((CCLayerGradient *)pNode)->setStartOpacity(pByte);
} else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDOPACITY) == 0) {
((CCLayerGradient *)pNode)->setEndOpacity(pByte); ((CCLayerGradient *)pNode)->setEndOpacity(pByte);
} else { } else {
CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc); ((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
@ -43,8 +43,8 @@ void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * p
} }
void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) { if(pPropertyName->compare(PROPERTY_VECTOR) == 0) {
((CCLayerGradient *)pNode)->setVector(pPoint); ((CCLayerGradient *)pNode)->setVector(pPoint);
// TODO Not passed along the ccbi file. // TODO Not passed along the ccbi file.

View File

@ -10,15 +10,15 @@ class CCBReader;
class CC_DLL CCLayerGradientLoader : public CCLayerLoader { class CC_DLL CCLayerGradientLoader : public CCLayerLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader);
protected: protected:
virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -12,15 +12,15 @@ CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader)
return CCLayer::node(); return CCLayer::node();
} }
void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TOUCH_ENABLED) == 0) { if(pPropertyName->compare(PROPERTY_TOUCH_ENABLED) == 0) {
((CCLayer *)pNode)->setTouchEnabled(pCheck); ((CCLayer *)pNode)->setTouchEnabled(pCheck);
} else if(strcmp(pPropertyName, PROPERTY_ACCELEROMETER_ENABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_ACCELEROMETER_ENABLED) == 0) {
((CCLayer *)pNode)->setAccelerometerEnabled(pCheck); ((CCLayer *)pNode)->setAccelerometerEnabled(pCheck);
} else if(strcmp(pPropertyName, PROPERTY_MOUSE_ENABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_MOUSE_ENABLED) == 0) {
// TODO XXX // TODO XXX
CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED);
} else if(strcmp(pPropertyName, PROPERTY_KEYBOARD_ENABLED) == 0) { } else if(pPropertyName->compare(PROPERTY_KEYBOARD_ENABLED) == 0) {
// TODO XXX // TODO XXX
CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED);
// This comes closest: ((CCLayer *)pNode)->setKeypadEnabled(pCheck); // This comes closest: ((CCLayer *)pNode)->setKeypadEnabled(pCheck);

View File

@ -10,12 +10,12 @@ class CCBReader;
class CC_DLL CCLayerLoader : public CCNodeLoader { class CC_DLL CCLayerLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader);
protected: protected:
virtual CCLayer * createCCNode(CCNode *, CCBReader *); virtual CCLayer * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -11,16 +11,16 @@ CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReade
return CCMenuItemImage::node(); return CCMenuItemImage::node();
} }
void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { if(pPropertyName->compare(PROPERTY_NORMALDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame);
} }
} else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { } else if(pPropertyName->compare(PROPERTY_SELECTEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame);
} }
} else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { } else if(pPropertyName->compare(PROPERTY_DISABLEDDISPLAYFRAME) == 0) {
if(pCCSpriteFrame != NULL) { if(pCCSpriteFrame != NULL) {
((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame);
} }

View File

@ -10,12 +10,12 @@ class CCBReader;
class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader { class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader);
protected: protected:
virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -6,16 +6,16 @@ USING_NS_CC_EXT;
#define PROPERTY_BLOCK "block" #define PROPERTY_BLOCK "block"
#define PROPERTY_ISENABLED "isEnabled" #define PROPERTY_ISENABLED "isEnabled"
void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) { if(pPropertyName->compare(PROPERTY_BLOCK) == 0) {
((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler); ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler);
} else { } else {
CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader); CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader);
} }
} }
void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) { if(pPropertyName->compare(PROPERTY_ISENABLED) == 0) {
((CCMenuItem *)pNode)->setEnabled(pCheck); ((CCMenuItem *)pNode)->setEnabled(pCheck);
} else { } else {
CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);

View File

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

View File

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

View File

@ -11,8 +11,8 @@
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
#define PROPERTY_VISIBLE "visible" #define PROPERTY_VISIBLE "visible"
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false)
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
USING_NS_CC; USING_NS_CC;
USING_NS_CC_EXT; USING_NS_CC_EXT;
@ -33,7 +33,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader *
int propertyCount = pCCBReader->readInt(false); int propertyCount = pCCBReader->readInt(false);
for(int i = 0; i < propertyCount; i++) { for(int i = 0; i < propertyCount; i++) {
int type = pCCBReader->readInt(false); int type = pCCBReader->readInt(false);
const char * propertyName = pCCBReader->readCachedString().c_str(); CCString * propertyName = pCCBReader->readCachedString();
// Check if the property can be set for this platform // Check if the property can be set for this platform
bool setProp = false; bool setProp = false;
@ -198,28 +198,28 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader *
break; break;
} }
case kCCBPropTypeFntFile: { case kCCBPropTypeFntFile: {
const char * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); CCString * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader);
if(setProp) { if(setProp) {
this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader); this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader);
} }
break; break;
} }
case kCCBPropTypeFontTTF: { case kCCBPropTypeFontTTF: {
const char * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); CCString * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader);
if(setProp) { if(setProp) {
this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader); this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader);
} }
break; break;
} }
case kCCBPropTypeString: { case kCCBPropTypeString: {
const char * string = this->parsePropTypeString(pNode, pParent, pCCBReader); CCString * string = this->parsePropTypeString(pNode, pParent, pCCBReader);
if(setProp) { if(setProp) {
this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader); this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader);
} }
break; break;
} }
case kCCBPropTypeText: { case kCCBPropTypeText: {
const char * text = this->parsePropTypeText(pNode, pParent, pCCBReader); CCString * text = this->parsePropTypeText(pNode, pParent, pCCBReader);
if(setProp) { if(setProp) {
this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader); this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader);
} }
@ -406,39 +406,39 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade
CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * spriteSheet = pCCBReader->readCachedString().c_str(); CCString * spriteSheet = pCCBReader->readCachedString();
const char * spriteFile = pCCBReader->readCachedString().c_str(); CCString * spriteFile = pCCBReader->readCachedString();
CCSpriteFrame * spriteFrame; CCSpriteFrame * spriteFrame;
if(strcmp(spriteSheet, "") == 0) { if(spriteSheet == NULL || spriteSheet->length() == 0) {
if(strcmp(spriteFile, "") == 0) { if(spriteFile == NULL || spriteFile->length() == 0) {
return NULL; return NULL;
} }
const char * spriteFilePath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteFile).c_str(); CCString * spriteFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteFile);
CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath); CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath->getCString());
CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height);
spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds);
} else { } else {
CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
const char * spriteSheetPath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteSheet).c_str(); CCString * spriteSheetPath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteSheet);
/* Load the sprite sheet only if it is not loaded. */ /* Load the sprite sheet only if it is not loaded. */
if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) { if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) {
frameCache->addSpriteFramesWithFile(spriteSheetPath); frameCache->addSpriteFramesWithFile(spriteSheetPath->getCString());
pCCBReader->addLoadedSpriteSheet(spriteSheetPath); pCCBReader->addLoadedSpriteSheet(spriteSheetPath);
} }
spriteFrame = frameCache->spriteFrameByName(spriteFile); spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString());
} }
return spriteFrame; return spriteFrame;
} }
CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * animationFile = pCCBReader->readCachedString().c_str(); CCString * animationFile = pCCBReader->readCachedString();
const char * animation = pCCBReader->readCachedString().c_str(); CCString * animation = pCCBReader->readCachedString();
CCAnimation * ccAnimation = NULL; CCAnimation * ccAnimation = NULL;
@ -447,22 +447,22 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar
// Eventually this should be handled by a client side asset manager // Eventually this should be handled by a client side asset manager
// interface which figured out what resources to load. // interface which figured out what resources to load.
// TODO Does this problem exist in C++? // TODO Does this problem exist in C++?
animation = pCCBReader->lastPathComponent(animation).c_str(); animation = CCBReader::lastPathComponent(animation);
animationFile = pCCBReader->lastPathComponent(animationFile).c_str(); animationFile = CCBReader::lastPathComponent(animationFile);
if(strcmp(animation, "") != 0) { if(animation != NULL && animation->compare("") != 0) {
CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache();
animationCache->addAnimationsWithFile(animationFile); animationCache->addAnimationsWithFile(animationFile->getCString());
ccAnimation = animationCache->animationByName(animation); ccAnimation = animationCache->animationByName(animation->getCString());
} }
return ccAnimation; return ccAnimation;
} }
CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * spriteFile = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pCCBReader->readCachedString().c_str()).c_str(); CCString * spriteFile = CCBReader::concat(pCCBReader->getCCBRootPath(), pCCBReader->readCachedString());
return CCTextureCache::sharedTextureCache()->addImage(spriteFile); return CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString());
} }
unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
@ -524,32 +524,36 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen
return blendFunc; return blendFunc;
} }
const char * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
return pCCBReader->readCachedString().c_str(); CCString * fntFile = pCCBReader->readCachedString();
return CCBReader::concat(pCCBReader->getCCBRootPath(), fntFile);
} }
const char * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
return pCCBReader->readCachedString().c_str(); return pCCBReader->readCachedString();
} }
const char * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
return pCCBReader->readCachedString().c_str(); return pCCBReader->readCachedString();
} }
const char * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * fnt = pCCBReader->readCachedString().c_str(); CCString * fontTTF = pCCBReader->readCachedString();
const char * ttfEnding("ttf"); CCString * ttfEnding = CCString::stringWithCString(".ttf");
if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt).c_str(), ttfEnding)){ /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path.
fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt).c_str()).c_str(); * System fonts come without the ".ttf" extension and do not need the path prepended. */
if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){
fontTTF = CCBReader::concat(pCCBReader->getCCBRootPath(), fontTTF);
} }
return fnt; return fontTTF;
} }
BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * selectorName = pCCBReader->readCachedString().c_str(); CCString * selectorName = pCCBReader->readCachedString();
int selectorTarget = pCCBReader->readInt(false); int selectorTarget = pCCBReader->readInt(false);
if(selectorTarget != kCCBTargetTypeNone) { if(selectorTarget != kCCBTargetTypeNone) {
@ -561,18 +565,18 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C
} }
if(target != NULL) { if(target != NULL) {
if(strlen(selectorName) > 0) { if(selectorName->length() > 0) {
SEL_MenuHandler selMenuHandler = 0; SEL_MenuHandler selMenuHandler = 0;
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
if(targetAsCCBSelectorResolver != NULL) { if(targetAsCCBSelectorResolver != NULL) {
selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName);
} }
if(selMenuHandler == 0) { if(selMenuHandler == 0) {
CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver();
if(ccbSelectorResolver != NULL) { if(ccbSelectorResolver != NULL) {
selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName);
} }
} }
@ -598,7 +602,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C
} }
BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * selectorName = pCCBReader->readCachedString().c_str(); CCString * selectorName = pCCBReader->readCachedString();
int selectorTarget = pCCBReader->readInt(false); int selectorTarget = pCCBReader->readInt(false);
int controlEvents = pCCBReader->readInt(false); int controlEvents = pCCBReader->readInt(false);
@ -611,7 +615,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C
} }
if(target != NULL) { if(target != NULL) {
if(strlen(selectorName) > 0) { if(selectorName->length() > 0) {
SEL_CCControlHandler selCCControlHandler = 0; SEL_CCControlHandler selCCControlHandler = 0;
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
@ -649,52 +653,52 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C
} }
CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
const char * ccbFileName = pCCBReader->readCachedString().c_str(); CCString * ccbFileName = pCCBReader->readCachedString();
/* Change path extension to .ccbi. */ /* Change path extension to .ccbi. */
const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName).c_str(); CCString * ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName);
const char * ccbiFileName = pCCBReader->concat(ccbFileWithoutPathExtension, ".ccbi").c_str(); CCString * ccbiFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::stringWithCString(".ccbi"));
CCBReader * ccbReader = new CCBReader(pCCBReader); CCBReader * ccbReader = new CCBReader(pCCBReader);
ccbReader->autorelease(); ccbReader->autorelease();
CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath().c_str(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize());
return ccbFileNode; return ccbFileNode;
} }
void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) { if(pPropertyName->compare(PROPERTY_POSITION) == 0) {
pNode->setPosition(pPosition); pNode->setPosition(pPosition);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) { if(pPropertyName->compare(PROPERTY_ANCHORPOINT) == 0) {
pNode->setAnchorPoint(pPoint); pNode->setAnchorPoint(pPoint);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { if(pPropertyName->compare(PROPERTY_CONTENTSIZE) == 0) {
pNode->setContentSize(pSize); pNode->setContentSize(pSize);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pScaleLock, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) { if(pPropertyName->compare(PROPERTY_SCALE) == 0) {
pNode->setScaleX(pScaleLock[0]); pNode->setScaleX(pScaleLock[0]);
pNode->setScaleY(pScaleLock[1]); pNode->setScaleY(pScaleLock[1]);
} else { } else {
@ -702,104 +706,104 @@ void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, c
} }
} }
void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pDegrees, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) { if(pPropertyName->compare(PROPERTY_ROTATION) == 0) {
pNode->setRotation(pDegrees); pNode->setRotation(pDegrees);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TAG) == 0) { if(pPropertyName->compare(PROPERTY_TAG) == 0) {
pNode->setTag(pInteger); pNode->setTag(pInteger);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { if(pPropertyName->compare(PROPERTY_VISIBLE) == 0) {
pNode->setVisible(pCheck); pNode->setVisible(pCheck);
} else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { } else if(pPropertyName->compare(PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) {
pNode->ignoreAnchorPointForPosition(pCheck); pNode->ignoreAnchorPointForPosition(pCheck);
} else { } else {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
} }
void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }
void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
} }

View File

@ -6,6 +6,10 @@
NS_CC_EXT_BEGIN 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(); \
}
struct BlockData { struct BlockData {
SEL_MenuHandler mSELMenuHandler; SEL_MenuHandler mSELMenuHandler;
CCObject * mTarget; CCObject * mTarget;
@ -22,7 +26,7 @@ class CCBReader;
class CC_DLL CCNodeLoader : public CCObject { class CC_DLL CCNodeLoader : public CCObject {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader);
virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader); virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader);
virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
@ -50,42 +54,42 @@ class CC_DLL CCNodeLoader : public CCObject {
virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual const char * parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCString * parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual const char * parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCString * parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual const char * parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCString * parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual const char * parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCString * parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual BlockData * parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual BlockData * parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual CCNode * parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCNode * parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader);
virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader); virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader);
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader);
virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader); virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader);
virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader); virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader);
virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader); virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pScaleLock, CCBReader * pCCBReader);
virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader); virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader);
virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader); virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pDegrees, CCBReader * pCCBReader);
virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader); virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader);
virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader); virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader);
virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader);
virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFoatVar, CCBReader * pCCBReader); virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFoatVar, CCBReader * pCCBReader);
virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader);
virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader); virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader);
virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader); virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader);
virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader); virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader);
virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader); virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader);
virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader); virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader);
virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader); virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader);
virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader); virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader);
virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader); virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader);
virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader); virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader);
virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader); virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader);
virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -42,25 +42,35 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() {
} }
void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) {
this->mCCNodeLoaders.insert(std::pair<const char *, CCNodeLoader *>(pClassName, pCCNodeLoader)); this->registerCCNodeLoader(CCString::stringWithCString(pClassName), pCCNodeLoader);
}
void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) {
pClassName->retain();
pCCNodeLoader->retain(); pCCNodeLoader->retain();
this->mCCNodeLoaders.insert(CCNodeLoaderMapEntry(pClassName, pCCNodeLoader));
} }
void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) { void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); this->unregisterCCNodeLoader(CCString::stringWithCString(pClassName));
}
void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) {
CCNodeLoaderMap::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName);
assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end());
ccNodeLoadersIterator->first->release();
ccNodeLoadersIterator->second->release(); ccNodeLoadersIterator->second->release();
} }
CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(const char * pClassName) { CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); CCNodeLoaderMap::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName);
assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end());
return ccNodeLoadersIterator->second; return ccNodeLoadersIterator->second;
} }
void CCNodeLoaderLibrary::purge(bool pReleaseCCNodeLoaders) { void CCNodeLoaderLibrary::purge(bool pReleaseCCNodeLoaders) {
if(pReleaseCCNodeLoaders) { if(pReleaseCCNodeLoaders) {
for(std::map<std::string, CCNodeLoader *>::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { for(CCNodeLoaderMap::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) {
it->second->release(); it->second->release();
} }
} }

View File

@ -6,20 +6,26 @@
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
typedef std::map<CCString *, CCNodeLoader *, CCStringCompare> CCNodeLoaderMap;
typedef std::pair<CCString *, CCNodeLoader *> CCNodeLoaderMapEntry;
class CC_DLL CCNodeLoaderLibrary : public CCObject { class CC_DLL CCNodeLoaderLibrary : public CCObject {
private: private:
std::map<std::string, CCNodeLoader *> mCCNodeLoaders; CCNodeLoaderMap mCCNodeLoaders;
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library);
CCNodeLoaderLibrary(); CCNodeLoaderLibrary();
~CCNodeLoaderLibrary(); ~CCNodeLoaderLibrary();
void registerDefaultCCNodeLoaders(); void registerDefaultCCNodeLoaders();
void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader);
void registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader);
void unregisterCCNodeLoader(const char * pClassName); void unregisterCCNodeLoader(const char * pClassName);
void unregisterCCNodeLoader(CCString * pClassName);
CCNodeLoader * getCCNodeLoader(const char * pClassName); CCNodeLoader * getCCNodeLoader(const char * pClassName);
CCNodeLoader * getCCNodeLoader(CCString * pClassName);
void purge(bool pDelete); void purge(bool pDelete);
public: public:

View File

@ -30,77 +30,77 @@ CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent
return CCParticleSystemQuad::node(); return CCParticleSystemQuad::node();
} }
void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) { if(pPropertyName->compare(PROPERTY_EMITERMODE) == 0) {
((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); ((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled);
} else { } else {
CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) { if(pPropertyName->compare(PROPERTY_POSVAR) == 0) {
((CCParticleSystemQuad *)pNode)->setPosVar(pPoint); ((CCParticleSystemQuad *)pNode)->setPosVar(pPoint);
} else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) { } else if(pPropertyName->compare(PROPERTY_GRAVITY) == 0) {
((CCParticleSystemQuad *)pNode)->setGravity(pPoint); ((CCParticleSystemQuad *)pNode)->setGravity(pPoint);
} else { } else {
CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_EMISSIONRATE) == 0) { if(pPropertyName->compare(PROPERTY_EMISSIONRATE) == 0) {
((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat); ((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat);
} else if(strcmp(pPropertyName, PROPERTY_DURATION) == 0) { } else if(pPropertyName->compare(PROPERTY_DURATION) == 0) {
((CCParticleSystemQuad *)pNode)->setDuration(pFloat); ((CCParticleSystemQuad *)pNode)->setDuration(pFloat);
} else { } else {
CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader);
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TOTALPARTICLES) == 0) { if(pPropertyName->compare(PROPERTY_TOTALPARTICLES) == 0) {
((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger); ((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger);
} else { } else {
CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader); CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader);
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_LIFE) == 0) { if(pPropertyName->compare(PROPERTY_LIFE) == 0) {
((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_STARTSIZE) == 0) { } else if(pPropertyName->compare(PROPERTY_STARTSIZE) == 0) {
((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ENDSIZE) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDSIZE) == 0) {
((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_STARTSPIN) == 0) { } else if(pPropertyName->compare(PROPERTY_STARTSPIN) == 0) {
((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ENDSPIN) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDSPIN) == 0) {
((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ANGLE) == 0) { } else if(pPropertyName->compare(PROPERTY_ANGLE) == 0) {
((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_SPEED) == 0) { } else if(pPropertyName->compare(PROPERTY_SPEED) == 0) {
((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_TANGENTIALACCEL) == 0) { } else if(pPropertyName->compare(PROPERTY_TANGENTIALACCEL) == 0) {
((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_RADIALACCEL) == 0) { } else if(pPropertyName->compare(PROPERTY_RADIALACCEL) == 0) {
((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_STARTRADIUS) == 0) { } else if(pPropertyName->compare(PROPERTY_STARTRADIUS) == 0) {
((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ENDRADIUS) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDRADIUS) == 0) {
((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ROTATEPERSECOND) == 0) { } else if(pPropertyName->compare(PROPERTY_ROTATEPERSECOND) == 0) {
((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]);
((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]); ((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]);
} else { } else {
@ -108,11 +108,11 @@ void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) {
((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]);
((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]); ((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]);
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { } else if(pPropertyName->compare(PROPERTY_ENDCOLOR) == 0) {
((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]);
((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]); ((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]);
} else { } else {
@ -120,16 +120,16 @@ void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNo
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc); ((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
} }
} }
void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) { if(pPropertyName->compare(PROPERTY_TEXTURE) == 0) {
((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D); ((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D);
} else { } else {
CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader); CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader);

View File

@ -10,19 +10,19 @@ class CCBReader;
class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader { class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader);
protected: protected:
virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *);
virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *);
virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *);
virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *);
virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float *, CCBReader *); virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float *, CCBReader *);
virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F *, CCBReader *); virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F *, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D *, CCBReader *); virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D *, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -18,32 +18,32 @@ CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader
return CCScale9Sprite::node(); return CCScale9Sprite::node();
} }
void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) { if(pPropertyName->compare(PROPERTY_SPRITEFRAME) == 0) {
((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame); ((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame);
} else { } else {
CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
} }
} }
void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCScale9Sprite *)pNode)->setColor(pCCColor3B); ((CCScale9Sprite *)pNode)->setColor(pCCColor3B);
} else { } else {
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
((CCScale9Sprite *)pNode)->setOpacity(pByte); ((CCScale9Sprite *)pNode)->setOpacity(pByte);
} else { } else {
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
// TODO Not exported by CocosBuilder yet! // TODO Not exported by CocosBuilder yet!
// ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc); // ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
@ -51,24 +51,24 @@ void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pP
} }
} }
void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { if(pPropertyName->compare(PROPERTY_CONTENTSIZE) == 0) {
//((CCScale9Sprite *)pNode)->setContentSize(pSize); //((CCScale9Sprite *)pNode)->setContentSize(pSize);
} else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { } else if(pPropertyName->compare(PROPERTY_PREFEREDSIZE) == 0) {
((CCScale9Sprite *)pNode)->setPreferredSize(pSize); ((CCScale9Sprite *)pNode)->setPreferredSize(pSize);
} else { } else {
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
} }
} }
void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) { if(pPropertyName->compare(PROPERTY_INSETLEFT) == 0) {
((CCScale9Sprite *)pNode)->setInsetLeft(pFloat); ((CCScale9Sprite *)pNode)->setInsetLeft(pFloat);
} else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) { } else if(pPropertyName->compare(PROPERTY_INSETTOP) == 0) {
((CCScale9Sprite *)pNode)->setInsetTop(pFloat); ((CCScale9Sprite *)pNode)->setInsetTop(pFloat);
} else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) { } else if(pPropertyName->compare(PROPERTY_INSETRIGHT) == 0) {
((CCScale9Sprite *)pNode)->setInsetRight(pFloat); ((CCScale9Sprite *)pNode)->setInsetRight(pFloat);
} else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) { } else if(pPropertyName->compare(PROPERTY_INSETBOTTOM) == 0) {
((CCScale9Sprite *)pNode)->setInsetBottom(pFloat); ((CCScale9Sprite *)pNode)->setInsetBottom(pFloat);
} else { } else {
CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader);

View File

@ -10,17 +10,17 @@ class CCBReader;
class CC_DLL CCScale9SpriteLoader : public CCNodeLoader { class CC_DLL CCScale9SpriteLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader);
protected: protected:
virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *);
virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *);
virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -13,16 +13,16 @@ CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader
return CCSprite::node(); return CCSprite::node();
} }
void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { if(pPropertyName->compare(PROPERTY_DISPLAYFRAME) == 0) {
((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame);
} else { } else {
CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
} }
} }
void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) { if(pPropertyName->compare(PROPERTY_FLIP) == 0) {
((CCSprite *)pNode)->setFlipX(pFlip[0]); ((CCSprite *)pNode)->setFlipX(pFlip[0]);
((CCSprite *)pNode)->setFlipX(pFlip[1]); ((CCSprite *)pNode)->setFlipX(pFlip[1]);
} else { } else {
@ -30,24 +30,24 @@ void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, cons
} }
} }
void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
((CCSprite *)pNode)->setColor(pCCColor3B); ((CCSprite *)pNode)->setColor(pCCColor3B);
} else { } else {
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
} }
} }
void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
((CCSprite *)pNode)->setOpacity(pByte); ((CCSprite *)pNode)->setOpacity(pByte);
} else { } else {
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
} }
} }
void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc); ((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc);
} else { } else {
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);

View File

@ -10,16 +10,16 @@ class CCBReader;
class CC_DLL CCSpriteLoader : public CCNodeLoader { class CC_DLL CCSpriteLoader : public CCNodeLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader);
protected: protected:
virtual CCSprite * createCCNode(CCNode *, CCBReader *); virtual CCSprite * createCCNode(CCNode *, CCBReader *);
virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *);
virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *);
virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *);
virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *);
virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool *, CCBReader *); virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool *, CCBReader *);
}; };
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -230,17 +230,14 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false); dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false);
} }
#if CC_FONT_LABEL_SUPPORT
if (! font) if (! font)
{ {
font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize]; font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize];
if (font) if (font)
{ {
//dim = [str sizeWithZFont:font]; dim =_calculateStringSizeWithFontOrZFont(str, font, &constrainSize, true);
dim =_caculateStringSizeWithFontOrZFont(str, font, &constrainSize, true);
} }
} }
#endif // CC_FONT_LABEL_SUPPORT
if (! font) if (! font)
{ {
@ -316,17 +313,14 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
: UITextAlignmentLeft; : UITextAlignmentLeft;
// normal fonts // normal fonts
if( [font isKindOfClass:[UIFont class] ] ) if( [font isKindOfClass:[UIFont class] ] )
{ {
[str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align]; [str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align];
} }
else // ZFont class
#if CC_FONT_LABEL_SUPPORT {
else // ZFont class [FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align];
{ }
[FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align];
}
#endif
UIGraphicsPopContext(); UIGraphicsPopContext();

View File

@ -51,10 +51,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
#if CC_FONT_LABEL_SUPPORT
// FontLabel support
#endif// CC_FONT_LABEL_SUPPORT
//CLASS IMPLEMENTATIONS: //CLASS IMPLEMENTATIONS:
// If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit) // If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit)

View File

@ -45,12 +45,10 @@ tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourP
tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \
tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \
tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \
tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp \ tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \
tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp \ tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \
tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp \ tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \
tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp \ tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \
tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp \
tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp \
tests/FontTest/FontTest.cpp \ tests/FontTest/FontTest.cpp \
tests/IntervalTest/IntervalTest.cpp \ tests/IntervalTest/IntervalTest.cpp \
tests/KeypadTest/KeypadTest.cpp \ tests/KeypadTest/KeypadTest.cpp \

View File

@ -1 +1 @@
e7a48f141ba644f5dc6c8d2f786899216a211a9a cf47c05a8260b8bdde74155d3dc2382ae9735b76

View File

@ -0,0 +1,56 @@
#include "ButtonTestLayer.h"
#include "extensions/CCBReader/CCBReader.h"
USING_NS_CC;
USING_NS_CC_EXT;
SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) {
return NULL;
}
SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) {
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonClicked", ButtonTestLayer::onCCControlButtonClicked);
return NULL;
}
bool ButtonTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) {
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mCCControlEventLabel", CCLabelBMFont *, this->mCCControlEventLabel);
return false;
}
void ButtonTestLayer::onCCControlButtonClicked(cocos2d::CCObject *pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
switch(pCCControlEvent) {
case CCControlEventTouchDown:
this->mCCControlEventLabel->setString("Touch Down.");
break;
case CCControlEventTouchDragInside:
this->mCCControlEventLabel->setString("Touch Drag Inside.");
break;
case CCControlEventTouchDragOutside:
this->mCCControlEventLabel->setString("Touch Drag Outside.");
break;
case CCControlEventTouchDragEnter:
this->mCCControlEventLabel->setString("Touch Drag Enter.");
break;
case CCControlEventTouchDragExit:
this->mCCControlEventLabel->setString("Touch Drag Exit.");
break;
case CCControlEventTouchUpInside:
this->mCCControlEventLabel->setString("Touch Up Inside.");
break;
case CCControlEventTouchUpOutside:
this->mCCControlEventLabel->setString("Touch Up Outside.");
break;
case CCControlEventTouchCancel:
this->mCCControlEventLabel->setString("Touch Cancel.");
break;
case CCControlEventValueChanged:
this->mCCControlEventLabel->setString("Value Changed.");
break;
default:
assert(false); // OH SHIT!
}
}

View File

@ -0,0 +1,23 @@
#ifndef _BUTTONTESTLAYER_H_
#define _BUTTONTESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCNodeLoader.h"
#include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.h"
class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node);
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode);
virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent);
private:
cocos2d::CCLabelBMFont * mCCControlEventLabel;
};
#endif

View File

@ -9,10 +9,10 @@ class CCBReader;
class ButtonTestLayerLoader : public cocos2d::extension::CCLayerLoader { class ButtonTestLayerLoader : public cocos2d::extension::CCLayerLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ButtonTestLayerLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ButtonTestLayerLoader, loader);
protected: protected:
virtual ButtonTestLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ButtonTestLayer);
}; };
#endif #endif

View File

@ -1,33 +0,0 @@
#include "ButtonTestLayer.h"
#include "extensions/CCBReader/CCBReader.h"
USING_NS_CC;
USING_NS_CC_EXT;
ButtonTestLayer * ButtonTestLayer::node() {
ButtonTestLayer * ptr = new ButtonTestLayer();
if(ptr && ptr->init()) {
ptr->autorelease();
return ptr;
}
CC_SAFE_DELETE(ptr);
return NULL;
}
SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) {
return NULL;
}
SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) {
if(pTarget == this) {
if(strcmp(pSelectorName, "onCCControlButtonClicked") == 0) {
return cccontrol_selector(ButtonTestLayer::onCCControlButtonClicked);
}
}
return NULL;
}
void ButtonTestLayer::onCCControlButtonClicked(cocos2d::CCObject *pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onCCControlButtonClicked\n");
}

View File

@ -1,18 +0,0 @@
#ifndef _BUTTONTESTLAYER_H_
#define _BUTTONTESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCNodeLoader.h"
#include "extensions/CCBReader/CCBSelectorResolver.h"
class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer {
public:
static ButtonTestLayer * node();
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName);
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName);
virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent);
};
#endif

View File

@ -1,8 +0,0 @@
#include "ButtonTestLayerLoader.h"
USING_NS_CC;
USING_NS_CC_EXT;
ButtonTestLayer * ButtonTestLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) {
return ButtonTestLayer::node();
}

View File

@ -26,7 +26,7 @@
#include "../../testResource.h" #include "../../testResource.h"
#include "extensions/CCBReader/CCBReader.h" #include "extensions/CCBReader/CCBReader.h"
#include "extensions/CCBReader/CCNodeLoaderLibrary.h" #include "extensions/CCBReader/CCNodeLoaderLibrary.h"
#include "HelloCocosBuilderLayerLoader.h" #include "HelloCocosBuilder/HelloCocosBuilderLayerLoader.h"
USING_NS_CC; USING_NS_CC;
USING_NS_CC_EXT; USING_NS_CC_EXT;

View File

@ -3,23 +3,16 @@
#include "extensions/CCBReader/CCBReader.h" #include "extensions/CCBReader/CCBReader.h"
#include "extensions/CCBReader/CCNodeLoaderLibrary.h" #include "extensions/CCBReader/CCNodeLoaderLibrary.h"
#include "TestHeaderLayerLoader.h" #include "../TestHeader/TestHeaderLayerLoader.h"
#include "ButtonTestLayerLoader.h" #include "../LabelTest/LabelTestLayerLoader.h"
#include "CCTransition.h" #include "../ButtonTest/ButtonTestLayerLoader.h"
#include "../SpriteTest/SpriteTestLayerLoader.h"
#include "../MenuTest/MenuTestLayerLoader.h"
#include "../ParticleSystemTest/ParticleSystemTestLayerLoader.h"
USING_NS_CC; USING_NS_CC;
USING_NS_CC_EXT; USING_NS_CC_EXT;
HelloCocosBuilderLayer * HelloCocosBuilderLayer::node() {
HelloCocosBuilderLayer * ptr = new HelloCocosBuilderLayer();
if(ptr && ptr->init()) {
ptr->autorelease();
return ptr;
}
CC_SAFE_DELETE(ptr);
return NULL;
}
void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) { void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) {
/* Create an autorelease CCNodeLoaderLibrary. */ /* Create an autorelease CCNodeLoaderLibrary. */
CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
@ -64,69 +57,49 @@ void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::exte
} }
SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) {
return NULL; return NULL;
} }
SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) {
if(pTarget == this) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked);
if(strcmp(pSelectorName, "onMenuTestClicked") == 0) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked);
return cccontrol_selector(HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked);
} else if(strcmp(pSelectorName, "onSpriteTestClicked") == 0) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked);
return cccontrol_selector(HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onParticleSystemTestClicked", HelloCocosBuilderLayer::onParticleSystemTestClicked);
} else if(strcmp(pSelectorName, "onButtonTestClicked") == 0) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onScrollViewTestClicked", HelloCocosBuilderLayer::onScrollViewTestClicked);
return cccontrol_selector(HelloCocosBuilderLayer::onButtonTestClicked);
} else if(strcmp(pSelectorName, "onLabelTestClicked") == 0) {
return cccontrol_selector(HelloCocosBuilderLayer::onLabelTestClicked);
} else if(strcmp(pSelectorName, "onParticleSystemTestClicked") == 0) {
return cccontrol_selector(HelloCocosBuilderLayer::onParticleSystemTestClicked);
} else if(strcmp(pSelectorName, "onScrollViewTestClicked") == 0) {
return cccontrol_selector(HelloCocosBuilderLayer::onScrollViewTestClicked);
}
}
return NULL; return NULL;
} }
bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) {
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", CCSprite *, this->mBurstSprite);
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", CCLabelTTF *, this->mTestTitleLabelTTF);
bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) {
if(pTarget == this) {
if(strcmp(pMemberVariableName, "mBurstSprite") == 0) {
this->mBurstSprite = dynamic_cast<CCSprite *>(pNode);
CC_ASSERT(this->mBurstSprite);
this->mBurstSprite->retain();
return true;
} else if(strcmp(pMemberVariableName, "mTestTitleLabel") == 0) {
this->mTestTitleLabelTTF = dynamic_cast<CCLabelTTF *>(pNode);
CC_ASSERT(this->mTestTitleLabelTTF);
this->mTestTitleLabelTTF->retain();
return true;
}
}
return false; return false;
} }
void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onMenuTestClicked\n"); this->openTest("ccb/MenuTest.ccbi", "MenuTestLayer", MenuTestLayerLoader::loader());
} }
void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onSpriteTestClicked\n"); this->openTest("ccb/SpriteTest.ccbi", "SpriteTestLayer", SpriteTestLayerLoader::loader());
} }
void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onButtonTestClicked\n");
this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader());
} }
void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onLabelTestClicked\n"); this->openTest("ccb/LabelTest.ccbi", "LabelTestLayer", LabelTestLayerLoader::loader());
} }
void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onParticleSystemTestClicked\n"); this->openTest("ccb/ParticleSystemTest.ccbi", "ParticleSystemTestLayer", ParticleSystemTestLayerLoader::loader());
} }
void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
printf("onScrollViewTestClicked\n"); CCLog("onScrollViewTestClicked\n");
} }

View File

@ -19,13 +19,13 @@
*/ */
class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCNodeLoaderListener, public cocos2d::CCLayer { class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCNodeLoaderListener, public cocos2d::CCLayer {
public: public:
static HelloCocosBuilderLayer * node(); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node);
void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL); void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL);
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, const char * pMemberVariableName, cocos2d::CCNode * pNode); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode);
virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader); virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader);
virtual void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); virtual void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent);

View File

@ -9,10 +9,10 @@ class CCBReader;
class HelloCocosBuilderLayerLoader : public cocos2d::extension::CCLayerLoader { class HelloCocosBuilderLayerLoader : public cocos2d::extension::CCLayerLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(HelloCocosBuilderLayerLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(HelloCocosBuilderLayerLoader, loader);
protected: protected:
virtual HelloCocosBuilderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(HelloCocosBuilderLayer);
}; };
#endif #endif

View File

@ -1,8 +0,0 @@
#include "HelloCocosBuilderLayerLoader.h"
USING_NS_CC;
USING_NS_CC_EXT;
HelloCocosBuilderLayer * HelloCocosBuilderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) {
return HelloCocosBuilderLayer::node();
}

View File

@ -0,0 +1,12 @@
#ifndef _LABELTESTLAYER_H_
#define _LABELTESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCBReader.h"
class LabelTestLayer : public cocos2d::CCLayer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(LabelTestLayer, node);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef _LABELTESTLAYERLOADER_H_
#define _LABELTESTLAYERLOADER_H_
#include "extensions/CCBReader/CCLayerLoader.h"
#include "LabelTestLayer.h"
/* Forward declaration. */
class CCBReader;
class LabelTestLayerLoader : public cocos2d::extension::CCLayerLoader {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTestLayerLoader, loader);
protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelTestLayer);
};
#endif

View File

@ -0,0 +1,37 @@
#include "MenuTestLayer.h"
#include "extensions/CCBReader/CCBReader.h"
USING_NS_CC;
USING_NS_CC_EXT;
SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) {
CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemAClicked", MenuTestLayer::onMenuItemAClicked);
CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemBClicked", MenuTestLayer::onMenuItemBClicked);
CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemCClicked", MenuTestLayer::onMenuItemCClicked);
return NULL;
}
SEL_CCControlHandler MenuTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) {
return NULL;
}
bool MenuTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) {
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mMenuItemStatusLabelBMFont", CCLabelBMFont *, this->mMenuItemStatusLabelBMFont);
return false;
}
void MenuTestLayer::onMenuItemAClicked(cocos2d::CCObject *pSender) {
this->mMenuItemStatusLabelBMFont->setString("Menu Item A clicked.");
}
void MenuTestLayer::onMenuItemBClicked(cocos2d::CCObject *pSender) {
this->mMenuItemStatusLabelBMFont->setString("Menu Item B clicked.");
}
void MenuTestLayer::onMenuItemCClicked(cocos2d::CCObject *pSender) {
this->mMenuItemStatusLabelBMFont->setString("Menu Item C clicked.");
}

View File

@ -0,0 +1,25 @@
#ifndef _MENUTESTLAYER_H_
#define _MENUTESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCNodeLoader.h"
#include "extensions/CCBReader/CCBSelectorResolver.h"
#include "extensions/CCBReader/CCBMemberVariableAssigner.h"
class MenuTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node);
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode);
virtual void onMenuItemAClicked(cocos2d::CCObject * pSender);
virtual void onMenuItemBClicked(cocos2d::CCObject * pSender);
virtual void onMenuItemCClicked(cocos2d::CCObject * pSender);
private:
cocos2d::CCLabelBMFont * mMenuItemStatusLabelBMFont;
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef _MENUTESTLAYERLOADER_H_
#define _MENUTESTLAYERLOADER_H_
#include "extensions/CCBReader/CCLayerLoader.h"
#include "MenuTestLayer.h"
/* Forward declaration. */
class CCBReader;
class MenuTestLayerLoader : public cocos2d::extension::CCLayerLoader {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(MenuTestLayerLoader, loader);
protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(MenuTestLayer);
};
#endif

View File

@ -0,0 +1,12 @@
#ifndef _PARTICLESYSTEMTESTLAYER_H_
#define _PARTICLESYSTEMTESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCBReader.h"
class ParticleSystemTestLayer : public cocos2d::CCLayer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ParticleSystemTestLayer, node);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef _PARTICLESYSTEMTESTLOADER_H_
#define _PARTICLESYSTEMTESTLOADER_H_
#include "extensions/CCBReader/CCLayerLoader.h"
#include "ParticleSystemTestLayer.h"
/* Forward declaration. */
class CCBReader;
class ParticleSystemTestLayerLoader : public cocos2d::extension::CCLayerLoader {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ParticleSystemTestLayerLoader, loader);
protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ParticleSystemTestLayer);
};
#endif

View File

@ -0,0 +1,12 @@
#ifndef _SPRITETESTLAYER_H_
#define _SPRITETESTLAYER_H_
#include "cocos2d.h"
#include "extensions/CCBReader/CCBReader.h"
class SpriteTestLayer : public cocos2d::CCLayer {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(SpriteTestLayer, node);
};
#endif

View File

@ -0,0 +1,18 @@
#ifndef _SPRITETESTLAYERLOADER_H_
#define _SPRITETESTLAYERLOADER_H_
#include "extensions/CCBReader/CCLayerLoader.h"
#include "SpriteTestLayer.h"
/* Forward declaration. */
class CCBReader;
class SpriteTestLayerLoader : public cocos2d::extension::CCLayerLoader {
public:
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(SpriteTestLayerLoader, loader);
protected:
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(SpriteTestLayer);
};
#endif

View File

@ -0,0 +1,21 @@
#include "TestHeaderLayer.h"
#include "extensions/CCBReader/CCBReader.h"
USING_NS_CC;
USING_NS_CC_EXT;
SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) {
CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onBackClicked", TestHeaderLayer::onBackClicked);
return NULL;
}
SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) {
return NULL;
}
void TestHeaderLayer::onBackClicked(cocos2d::CCObject *pSender) {
CCDirector::sharedDirector()->popScene();
}

View File

@ -7,10 +7,10 @@
class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer {
public: public:
static TestHeaderLayer * node(); CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node);
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName);
virtual void onBackClicked(cocos2d::CCObject * pSender); virtual void onBackClicked(cocos2d::CCObject * pSender);
}; };

View File

@ -9,10 +9,10 @@ class CCBReader;
class TestHeaderLayerLoader : public cocos2d::extension::CCLayerLoader { class TestHeaderLayerLoader : public cocos2d::extension::CCLayerLoader {
public: public:
STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TestHeaderLayerLoader, loader); CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TestHeaderLayerLoader, loader);
protected: protected:
virtual TestHeaderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(TestHeaderLayer);
}; };
#endif #endif

View File

@ -1,34 +0,0 @@
#include "TestHeaderLayer.h"
#include "extensions/CCBReader/CCBReader.h"
USING_NS_CC;
USING_NS_CC_EXT;
TestHeaderLayer * TestHeaderLayer::node() {
TestHeaderLayer * ptr = new TestHeaderLayer();
if(ptr && ptr->init()) {
ptr->autorelease();
return ptr;
}
CC_SAFE_DELETE(ptr);
return NULL;
}
SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) {
if(pTarget == this) {
if(strcmp(pSelectorName, "onBackClicked") == 0) {
return menu_selector(TestHeaderLayer::onBackClicked);
}
}
return NULL;
}
SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) {
return NULL;
}
void TestHeaderLayer::onBackClicked(cocos2d::CCObject *pSender) {
CCDirector::sharedDirector()->popScene();
}

View File

@ -1,8 +0,0 @@
#include "TestHeaderLayerLoader.h"
USING_NS_CC;
USING_NS_CC_EXT;
TestHeaderLayer * TestHeaderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) {
return TestHeaderLayer::node();
}