2012-09-19 09:19:28 +08:00
|
|
|
//
|
|
|
|
// js_bindings_ccbreader.h
|
|
|
|
// watermelon
|
|
|
|
//
|
|
|
|
// Created by Rohan Kuruvilla on 14/08/2012.
|
|
|
|
//
|
|
|
|
//
|
2012-09-24 11:47:33 +08:00
|
|
|
#ifndef __JS_BINDINGS_CCBREADER_H__
|
|
|
|
#define __JS_BINDINGS_CCBREADER_H__
|
|
|
|
|
2012-09-19 09:19:28 +08:00
|
|
|
#include "jsapi.h"
|
2012-09-24 11:05:15 +08:00
|
|
|
#include "cocos-ext.h"
|
2012-09-19 09:19:28 +08:00
|
|
|
#include "cocos2d_specifics.hpp"
|
|
|
|
|
|
|
|
|
2013-06-20 14:33:59 +08:00
|
|
|
class CCBScriptCallbackProxy: public cocos2d::Layer
|
2012-09-19 09:19:28 +08:00
|
|
|
, public cocos2d::extension::CCBSelectorResolver
|
|
|
|
, public cocos2d::extension::CCBMemberVariableAssigner {
|
|
|
|
|
|
|
|
std::string callBackProp;
|
|
|
|
jsval owner;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
CCBScriptCallbackProxy () {}
|
|
|
|
virtual ~CCBScriptCallbackProxy() {}
|
|
|
|
|
|
|
|
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create);
|
2013-06-20 14:33:59 +08:00
|
|
|
virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget,
|
2012-11-26 21:51:05 +08:00
|
|
|
const char * pSelectorName);
|
2013-03-19 10:12:14 +08:00
|
|
|
|
2013-06-20 14:33:59 +08:00
|
|
|
virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget,
|
2012-11-26 21:51:05 +08:00
|
|
|
const char * pSelectorName);
|
2013-06-20 14:33:59 +08:00
|
|
|
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName,
|
|
|
|
cocos2d::Node * pNode);
|
|
|
|
virtual void onNodeLoaded(cocos2d::Node * pNode,
|
|
|
|
cocos2d::extension::NodeLoader * pNodeLoader);
|
2012-09-19 09:19:28 +08:00
|
|
|
|
|
|
|
virtual CCBSelectorResolver * createNew();
|
2013-06-20 14:33:59 +08:00
|
|
|
void menuItemCallback(Object *pSender);
|
|
|
|
void controlCallback(Object *pSender, cocos2d::extension::ControlEvent event);
|
2012-09-19 09:19:28 +08:00
|
|
|
void setCallbackProperty(const char *prop);
|
|
|
|
void setJSOwner(jsval ownr);
|
|
|
|
jsval getJSOwner();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-06-20 14:33:59 +08:00
|
|
|
class JSLayerLoader : public cocos2d::extension::LayerLoader {
|
2012-09-19 09:19:28 +08:00
|
|
|
public:
|
|
|
|
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy);
|
|
|
|
};
|
|
|
|
|
|
|
|
void register_CCBuilderReader(JSContext *cx, JSObject *global);
|
|
|
|
JSBool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp);
|
2012-09-24 11:47:33 +08:00
|
|
|
|
|
|
|
#endif /* __JS_BINDINGS_CCBREADER_H__ */
|
|
|
|
|