2012-06-13 02:59:49 +08:00
|
|
|
#include "CCLabelTTFLoader.h"
|
2012-05-31 06:38:20 +08:00
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
USING_NS_CC;
|
2012-05-31 06:38:20 +08:00
|
|
|
|
|
|
|
#define PROPERTY_COLOR "color"
|
|
|
|
#define PROPERTY_OPACITY "opacity"
|
|
|
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
|
|
|
#define PROPERTY_FONTNAME "fontName"
|
|
|
|
#define PROPERTY_FONTSIZE "fontSize"
|
|
|
|
#define PROPERTY_HORIZONTALALIGNMENT "horizontalAlignment"
|
|
|
|
#define PROPERTY_VERTICALALIGNMENT "verticalAlignment"
|
|
|
|
#define PROPERTY_STRING "string"
|
2012-05-31 07:51:33 +08:00
|
|
|
#define PROPERTY_DIMENSIONS "dimensions"
|
2012-05-31 06:38:20 +08:00
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_COLOR) == 0) {
|
2012-05-31 06:38:20 +08:00
|
|
|
((CCLabelTTF *)pNode)->setColor(pCCColor3B);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_OPACITY) == 0) {
|
2012-05-31 06:38:20 +08:00
|
|
|
((CCLabelTTF *)pNode)->setOpacity(pByte);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) {
|
2012-05-31 06:38:20 +08:00
|
|
|
((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_FONTNAME) == 0) {
|
|
|
|
((CCLabelTTF *)pNode)->setFontName(pFontTTF->getCString());
|
2012-05-31 06:38:20 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_STRING) == 0) {
|
|
|
|
((CCLabelTTF *)pNode)->setString(pText->getCString());
|
2012-05-31 06:38:20 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_FONTSIZE) == 0) {
|
2012-05-31 06:38:20 +08:00
|
|
|
((CCLabelTTF *)pNode)->setFontSize(pFloatScale);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_HORIZONTALALIGNMENT) == 0) {
|
2012-05-31 06:38:20 +08:00
|
|
|
((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled));
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_VERTICALALIGNMENT) == 0) {
|
2012-06-13 02:30:36 +08:00
|
|
|
((CCLabelTTF *)pNode)->setVerticalAlignment(CCVerticalTextAlignment(pIntegerLabeled));
|
2012-05-31 06:38:20 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
|
|
|
}
|
2012-05-31 07:51:33 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_DIMENSIONS) == 0) {
|
2012-05-31 07:51:33 +08:00
|
|
|
((CCLabelTTF *)pNode)->setDimensions(pSize);
|
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|