mirror of https://github.com/axmolengine/axmol.git
85 lines
3.9 KiB
C++
85 lines
3.9 KiB
C++
#import "CCLabelTTFLoader.h"
|
|
|
|
using namespace cocos2d;
|
|
using namespace cocos2d::extension;
|
|
|
|
#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"
|
|
#define PROPERTY_DIMENSIONS "dimensions"
|
|
|
|
CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) {
|
|
return CCLabelTTF::node();
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
|
((CCLabelTTF *)pNode)->setColor(pCCColor3B);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) {
|
|
((CCLabelTTF *)pNode)->setOpacity(pByte);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
|
((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) {
|
|
((CCLabelTTF *)pNode)->setFontName(pFontTTF);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_STRING) == 0) {
|
|
((CCLabelTTF *)pNode)->setString(pText);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) {
|
|
((CCLabelTTF *)pNode)->setFontSize(pFloatScale);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
|
|
((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled));
|
|
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
|
|
// TODO Add support when CCLabelTTF supports it. ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b )
|
|
// ((CCLabelTTF *)pNode)->setVerticalAlignment(pIntegerLabeled);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) {
|
|
((CCLabelTTF *)pNode)->setDimensions(pSize);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
|
}
|
|
} |