axmol/extensions/CCBReader/CCMenuItemLoader.cpp

30 lines
1.2 KiB
C++
Raw Normal View History

#include "CCMenuItemLoader.h"
#define PROPERTY_BLOCK "block"
#define PROPERTY_ISENABLED "isEnabled"
NS_CC_EXT_BEGIN
void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) {
if (NULL != pBlockData) // Add this condition to allow MenuItemImage without target/selector predefined
{
((MenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->_target, std::placeholders::_1) );
// ((MenuItem *)pNode)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler);
}
} else {
NodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, ccbReader);
}
}
void MenuItemLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char * pPropertyName, bool pCheck, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) {
((MenuItem *)pNode)->setEnabled(pCheck);
} else {
NodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, ccbReader);
}
}
NS_CC_EXT_END