2012-06-13 02:59:49 +08:00
|
|
|
#include "CCMenuItemLoader.h"
|
2012-06-01 08:07:02 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
using namespace cocos2d;
|
2012-06-01 08:07:02 +08:00
|
|
|
|
|
|
|
#define PROPERTY_BLOCK "block"
|
|
|
|
#define PROPERTY_ISENABLED "isEnabled"
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocosbuilder {
|
2012-07-19 17:22:36 +08:00
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
if (NULL != pBlockData) // Add this condition to allow MenuItemImage without target/selector predefined
|
2012-07-29 21:17:35 +08:00
|
|
|
{
|
2013-07-27 21:44:49 +08:00
|
|
|
((MenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->_target, std::placeholders::_1) );
|
|
|
|
// ((MenuItem *)pNode)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler);
|
2012-07-29 21:17:35 +08:00
|
|
|
}
|
2012-06-01 08:07:02 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, ccbReader);
|
2012-06-01 08:07:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 21:44:49 +08:00
|
|
|
void MenuItemLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) {
|
2012-11-26 21:51:05 +08:00
|
|
|
if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) {
|
2013-06-20 14:15:53 +08:00
|
|
|
((MenuItem *)pNode)->setEnabled(pCheck);
|
2012-06-01 08:07:02 +08:00
|
|
|
} else {
|
2013-07-27 21:44:49 +08:00
|
|
|
NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader);
|
2012-06-01 08:07:02 +08:00
|
|
|
}
|
2012-07-19 17:22:36 +08:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:45:24 +08:00
|
|
|
}
|