2012-06-13 02:59:49 +08:00
|
|
|
#include "CCControlButtonLoader.h"
|
2012-06-02 06:14:18 +08:00
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
USING_NS_CC;
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN;
|
2012-06-02 06:14:18 +08:00
|
|
|
|
|
|
|
#define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown"
|
|
|
|
#define PROPERTY_TITLE_NORMAL "title|1"
|
|
|
|
#define PROPERTY_TITLE_HIGHLIGHTED "title|2"
|
2012-09-17 14:27:17 +08:00
|
|
|
#define PROPERTY_TITLE_DISABLED "title|3"
|
2012-06-02 06:14:18 +08:00
|
|
|
#define PROPERTY_TITLECOLOR_NORMAL "titleColor|1"
|
|
|
|
#define PROPERTY_TITLECOLOR_HIGHLIGHTED "titleColor|2"
|
2012-09-17 14:27:17 +08:00
|
|
|
#define PROPERTY_TITLECOLOR_DISABLED "titleColor|3"
|
2012-06-02 06:14:18 +08:00
|
|
|
#define PROPERTY_TITLETTF_NORMAL "titleTTF|1"
|
|
|
|
#define PROPERTY_TITLETTF_HIGHLIGHTED "titleTTF|2"
|
2012-09-17 14:27:17 +08:00
|
|
|
#define PROPERTY_TITLETTF_DISABLED "titleTTF|3"
|
2012-06-02 06:14:18 +08:00
|
|
|
#define PROPERTY_TITLETTFSIZE_NORMAL "titleTTFSize|1"
|
|
|
|
#define PROPERTY_TITLETTFSIZE_HIGHLIGHTED "titleTTFSize|2"
|
2012-09-17 14:27:17 +08:00
|
|
|
#define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|3"
|
2012-06-02 06:14:18 +08:00
|
|
|
#define PROPERTY_LABELANCHORPOINT "labelAnchorPoint"
|
|
|
|
#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder!
|
|
|
|
#define PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL "backgroundSpriteFrame|1"
|
|
|
|
#define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2"
|
2012-09-17 14:27:17 +08:00
|
|
|
#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3"
|
2012-06-02 06:14:18 +08:00
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck);
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_TITLE_NORMAL) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateNormal);
|
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLE_HIGHLIGHTED) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateHighlighted);
|
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLE_DISABLED) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateDisabled);
|
2012-06-02 06:14:18 +08:00
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_TITLETTF_NORMAL) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateNormal);
|
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLETTF_HIGHLIGHTED) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateHighlighted);
|
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLETTF_DISABLED) == 0) {
|
|
|
|
((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateDisabled);
|
2012-06-02 06:14:18 +08:00
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_NORMAL) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal);
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted);
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_DISABLED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled);
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_LABELANCHORPOINT) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint);
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_PREFEREDSIZE) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setPreferredSize(pSize);
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
if(pCCSpriteFrame != NULL) {
|
|
|
|
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal);
|
|
|
|
}
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
if(pCCSpriteFrame != NULL) {
|
|
|
|
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted);
|
|
|
|
}
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
if(pCCSpriteFrame != NULL) {
|
|
|
|
((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) {
|
|
|
|
if(pPropertyName->compare(PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal);
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted);
|
2012-06-14 15:01:01 +08:00
|
|
|
} else if(pPropertyName->compare(PROPERTY_TITLECOLOR_DISABLED) == 0) {
|
2012-06-02 06:14:18 +08:00
|
|
|
((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled);
|
|
|
|
} else {
|
|
|
|
CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader);
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END;
|