2012-06-13 02:59:49 +08:00
|
|
|
#include "CCMenuItemLoader.h"
|
2012-06-01 08:07:02 +08:00
|
|
|
|
2012-09-24 11:47:33 +08:00
|
|
|
|
2012-06-01 08:07:02 +08:00
|
|
|
|
|
|
|
#define PROPERTY_BLOCK "block"
|
|
|
|
#define PROPERTY_ISENABLED "isEnabled"
|
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) {
|
2012-07-29 21:17:35 +08:00
|
|
|
if (NULL != pBlockData) // Add this condition to allow CCMenuItemImage without target/selector predefined
|
|
|
|
{
|
2013-06-12 07:30:05 +08:00
|
|
|
((CCMenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->mTarget, std::placeholders::_1) );
|
|
|
|
// ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler);
|
2012-07-29 21:17:35 +08:00
|
|
|
}
|
2012-06-01 08:07:02 +08:00
|
|
|
} else {
|
2012-06-05 06:52:49 +08:00
|
|
|
CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader);
|
2012-06-01 08:07:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-26 21:51:05 +08:00
|
|
|
void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
|
|
|
if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) {
|
2012-06-15 16:47:30 +08:00
|
|
|
((CCMenuItem *)pNode)->setEnabled(pCheck);
|
2012-06-01 08:07:02 +08:00
|
|
|
} else {
|
|
|
|
CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
|
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_CC_EXT_END
|