Unified Header Guards. Added CCNodeLoaderListener, simulating the didLoadFromCCB selector.

This commit is contained in:
Nicolas Gramlich 2012-06-12 11:59:49 -07:00
parent 26d470f411
commit 895604f42e
37 changed files with 89 additions and 64 deletions

View File

@ -1,4 +1,4 @@
#import "CCBFileLoader.h"
#include "CCBFileLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCBFILE_LOADER_H_
#define _CCBFILE_LOADER_H_
#ifndef _CCB_CCBFILELOADER_H_
#define _CCB_CCBFILELOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,5 +1,5 @@
#ifndef _CCB_MEMBERVARIABLEASSIGNER_H_
#define _CCB_MEMBERVARIABLEASSIGNER_H_
#ifndef _CCB_CCBMEMBERVARIABLEASSIGNER_H_
#define _CCB_CCBMEMBERVARIABLEASSIGNER_H_
#include "cocos2d.h"

View File

@ -2,21 +2,26 @@
#include "CCNodeLoader.h"
#include "CCNodeLoaderLibrary.h"
#include "CCNodeLoaderListener.h"
#include "CCBMemberVariableAssigner.h"
#include "CCBSelectorResolver.h"
#ifdef __CC_PLATFORM_IOS
#import <UIKit/UIDevice.h>
#include <UIKit/UIDevice.h>
#endif
using namespace cocos2d;
using namespace cocos2d::extension;
CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver) {
CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, CCNodeLoaderListener * pCCNodeLoaderListener) {
this->mRootNode = NULL;
this->mRootCCBReader = true;
this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary;
this->mCCNodeLoaderLibrary->retain();
this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner;
this->mCCBSelectorResolver = pCCBSelectorResolver;
this->mCCNodeLoaderListener = pCCNodeLoaderListener;
this->mResolutionScale = 1;
@ -34,6 +39,8 @@ CCBReader::~CCBReader() {
this->mBytes = NULL;
}
this->mCCNodeLoaderLibrary->release();
/* Clear string cache. */
this->mStringCache.clear();
@ -57,6 +64,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) {
this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary;
this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner;
this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver;
this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener;
}
std::string CCBReader::getCCBRootPath() {
@ -296,12 +304,9 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
node->addChild(child);
}
// TODO
/*
if([node respondsToSelector:@selector(didLoadFromCCB)]) {
[node performSelector:@selector(didLoadFromCCB)];
if(this->mCCNodeLoaderListener != NULL) {
this->mCCNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
}
*/
return node;
}

View File

@ -1,9 +1,7 @@
#ifndef _CCB_READER_H_
#define _CCB_READER_H_
#ifndef _CCB_CCBREADER_H_
#define _CCB_CCBREADER_H_
#include "cocos2d.h"
#include "CCBMemberVariableAssigner.h"
#include "CCBSelectorResolver.h"
#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \
T * t = new T(); \
@ -77,6 +75,9 @@ NS_CC_EXT_BEGIN
/* Forward declaration. */
class CCNodeLoader;
class CCNodeLoaderLibrary;
class CCNodeLoaderListener;
class CCBMemberVariableAssigner;
class CCBSelectorResolver;
/**
* @brief Parse CCBI file which is generated by CocosBuilder
@ -95,6 +96,7 @@ class CC_DLL CCBReader : public CCObject {
float mResolutionScale;
CCNodeLoaderLibrary * mCCNodeLoaderLibrary;
CCNodeLoaderListener * mCCNodeLoaderListener;
CCBMemberVariableAssigner * mCCBMemberVariableAssigner;
CCBSelectorResolver * mCCBSelectorResolver;
@ -103,7 +105,7 @@ class CC_DLL CCBReader : public CCObject {
public:
/* Constructor. */
CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL);
CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL, CCNodeLoaderListener * = NULL);
CCBReader(CCBReader *);
/* Destructor. */
~CCBReader();

View File

@ -1,5 +1,5 @@
#ifndef _CCB_SELECTORRESOLVER_H_
#define _CCB_SELECTORRESOLVER_H_
#ifndef _CCB_CCBSELECTORRESOLVER_H_
#define _CCB_CCBSELECTORRESOLVER_H_
#include "cocos2d.h"

View File

@ -1,4 +1,4 @@
#import "CCControlButtonLoader.h"
#include "CCControlButtonLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCCONTROLBUTTON_LOADER_H_
#define _CCCONTROLBUTTON_LOADER_H_
#ifndef _CCB_CCCONTROLBUTTONLOADER_H_
#define _CCB_CCCONTROLBUTTONLOADER_H_
#include "CCControlLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCControlLoader.h"
#include "CCControlLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCCONTROL_LOADER_H_
#define _CCCONTROL_LOADER_H_
#ifndef _CCB_CCCONTROLLOADER_H_
#define _CCB_CCCONTROLLOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCLabelBMFontLoader.h"
#include "CCLabelBMFontLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCLABELBMFONT_LOADER_H_
#define _CCLABELBMFONT_LOADER_H_
#ifndef _CCB_CCLABELBMFONTLOADER_H_
#define _CCB_CCLABELBMFONTLOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCLabelTTFLoader.h"
#include "CCLabelTTFLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCLABELTTF_LOADER_H_
#define _CCLABELTTF_LOADER_H_
#ifndef _CCB_CCLABELTTFLOADER_H_
#define _CCB_CCLABELTTFLOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCLayerColorLoader.h"
#include "CCLayerColorLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCLAYERCOLOR_LOADER_H_
#define _CCLAYERCOLOR_LOADER_H_
#ifndef _CCB_CCLAYERCOLORLOADER_H_
#define _CCB_CCLAYERCOLORLOADER_H_
#include "CCLayerLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCLayerGradientLoader.h"
#include "CCLayerGradientLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCLAYERGRADIENT_LOADER_H_
#define _CCLAYERGRADIENT_LOADER_H_
#ifndef _CCB_CCLAYERGRADIENTLOADER_H_
#define _CCB_CCLAYERGRADIENTLOADER_H_
#include "CCLayerLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCLayerLoader.h"
#include "CCLayerLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCLAYER_LOADER_H_
#define _CCLAYER_LOADER_H_
#ifndef _CCB_CCLAYERLOADER_H_
#define _CCB_CCLAYERLOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCMenuItemImageLoader.h"
#include "CCMenuItemImageLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCMENUITEMIMAGE_LOADER_H_
#define _CCMENUITEMIMAGE_LOADER_H_
#ifndef _CCB_CCMENUITEMIMAGELOADER_H_
#define _CCB_CCMENUITEMIMAGELOADER_H_
#include "CCMenuItemLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCMenuItemLoader.h"
#include "CCMenuItemLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCMENUITEM_LOADER_H_
#define _CCMENUITEM_LOADER_H_
#ifndef _CCB_CCMENUITEMLOADER_H_
#define _CCB_CCMENUITEMLOADER_H_
#include "CCLayerLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCMenuLoader.h"
#include "CCMenuLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCMENU_LOADER_H_
#define _CCMENU_LOADER_H_
#ifndef _CCB_CCMENULOADER_H_
#define _CCB_CCMENULOADER_H_
#include "CCLayerLoader.h"

View File

@ -1,4 +1,5 @@
#import "CCNodeLoader.h"
#include "CCNodeLoader.h"
#include "CCBSelectorResolver.h"
#define PROPERTY_POSITION "position"
#define PROPERTY_CONTENTSIZE "contentSize"

View File

@ -1,5 +1,5 @@
#ifndef _CCNODE_LOADER_H_
#define _CCNODE_LOADER_H_
#ifndef _CCB_CCNODELOADER_H_
#define _CCB_CCNODELOADER_H_
#include "cocos2d.h"
#include "CCBReader.h"

View File

@ -1,5 +1,5 @@
#ifndef _CCNODE_LOADER_LIBRARY_H_
#define _CCNODE_LOADER_LIBRARY_H_
#ifndef _CCB_CCNODELOADERLIBRARY_H_
#define _CCB_CCNODELOADERLIBRARY_H_
#include "cocos2d.h"
#include "CCBReader.h"

View File

@ -0,0 +1,17 @@
#ifndef _CCB_CCNODELOADERLISTENER_H_
#define _CCB_CCNODELOADERLISTENER_H_
#include "cocos2d.h"
NS_CC_EXT_BEGIN
class CCNodeLoaderListener {
public:
virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader) = 0;
};
NS_CC_EXT_END
#endif

View File

@ -1,4 +1,4 @@
#import "CCParticleSystemQuadLoader.h"
#include "CCParticleSystemQuadLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCPARTICLESYSTEMQUAD_LOADER_H_
#define _CCPARTICLESYSTEMQUAD_LOADER_H_
#ifndef _CCB_CCPARTICLESYSTEMQUADLOADER_H_
#define _CCB_CCPARTICLESYSTEMQUADLOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCScale9SpriteLoader.h"
#include "CCScale9SpriteLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCSCALE9SPRITE_LOADER_H_
#define _CCSCALE9SPRITE_LOADER_H_
#ifndef _CCB_CCSCALE9SPRITELOADER_H_
#define _CCB_CCSCALE9SPRITELOADER_H_
#include "CCNodeLoader.h"

View File

@ -1,4 +1,4 @@
#import "CCSpriteLoader.h"
#include "CCSpriteLoader.h"
using namespace cocos2d;
using namespace cocos2d::extension;

View File

@ -1,5 +1,5 @@
#ifndef _CCSPRITE_LOADER_H_
#define _CCSPRITE_LOADER_H_
#ifndef _CCB_CCSPRITELOADER_H_
#define _CCB_CCSPRITELOADER_H_
#include "CCNodeLoader.h"

View File

@ -1 +1 @@
2183a27683dff4601536660a9a71e35cdfc1ce34
ac9e1ccb05629df842bf61eee24797838c23c929