mirror of https://github.com/axmolengine/axmol.git
bind gui and studio.
This commit is contained in:
parent
425ce40a67
commit
8b14575d7e
|
@ -63,6 +63,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForGui", "..\cocos\scripting\javascript\bindings\gui\libJSBindingForGui.vcxproj", "{9A844C88-97E8-4E2D-B09A-E138C67D338B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -189,18 +191,23 @@ Global
|
|||
{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}.Release|Win32.Build.0 = Release|Win32
|
||||
{9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{F9DA0FC1-651B-457B-962E-A4D61CEBF5FD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{79D34511-E54E-410A-8BBA-EF175AD6C695} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{3BEC13F5-E227-4D80-BC77-1C857F83BCFC} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{625F7391-9A91-48A1-8CFC-79508C822637} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{39379840-825A-45A0-B363-C09FFEF864BD} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{21070E58-EEC6-4E16-8B4F-6D083DF55790} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
{9A844C88-97E8-4E2D-B09A-E138C67D338B} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1}
|
||||
EndGlobalSection
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
|
|
|
@ -1 +1 @@
|
|||
e1cdac55b4aa56ff532e0d23fe27272510058a42
|
||||
1dbcea49018d245ac72bf4138633f3905ef4dc7f
|
|
@ -1 +1 @@
|
|||
9490bdedbc6e817240a1661c6bcbcafc9095c267
|
||||
2461d13fd6f4fadc6ee396109932e50b1de8ed99
|
|
@ -138,7 +138,8 @@ static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *
|
|||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
@ -162,7 +163,8 @@ static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx,
|
|||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
@ -188,8 +190,8 @@ static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint
|
|||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[2]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
tmpObj->setJSCallbackFunc(argv[1]);
|
||||
tmpObj->setJSCallbackThis(argv[2]);
|
||||
|
||||
std::string ret;
|
||||
jsval_to_std_string(cx, argv[0], &ret);
|
||||
|
@ -205,8 +207,8 @@ static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint
|
|||
JSArmatureWrapper *tmpObj = new JSArmatureWrapper();
|
||||
tmpObj->autorelease();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[4]);
|
||||
tmpObj->setJSCallbackThis(argv[3]);
|
||||
tmpObj->setJSCallbackFunc(argv[3]);
|
||||
tmpObj->setJSCallbackThis(argv[4]);
|
||||
|
||||
std::string imagePath;
|
||||
jsval_to_std_string(cx ,argv[0] , &imagePath);
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := jsb_gui_static
|
||||
|
||||
LOCAL_MODULE_FILENAME := libcocos2dxjsbgui
|
||||
|
||||
LOCAL_SRC_FILES := jsb_cocos2dx_gui_manual.cpp \
|
||||
../../../auto-generated/js-bindings/jsb_cocos2dx_gui_auto.cpp
|
||||
|
||||
LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT
|
||||
|
||||
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
||||
$(LOCAL_PATH)/../../../../../extensions \
|
||||
$(LOCAL_PATH)/../../../../gui
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_gui_static
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
$(call import-module,spidermonkey/prebuilt/android)
|
||||
$(call import-module,scripting/javascript/bindings)
|
||||
$(call import-module,gui)
|
|
@ -0,0 +1,317 @@
|
|||
//
|
||||
// jsb_cocos2dx_gui_manual.h
|
||||
//
|
||||
// Created by LinWenhai on 17/11/13.
|
||||
//
|
||||
//
|
||||
#include "jsb_cocos2dx_gui_manual.h"
|
||||
#include "ScriptingCore.h"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
#include "gui/CocosGUI.h"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
class JSStudioEventListenerWrapper: public JSCallbackWrapper {
|
||||
public:
|
||||
JSStudioEventListenerWrapper();
|
||||
virtual ~JSStudioEventListenerWrapper();
|
||||
|
||||
virtual void setJSCallbackThis(jsval thisObj);
|
||||
|
||||
virtual void eventCallbackFunc(Object*,int);
|
||||
|
||||
private:
|
||||
bool m_bNeedUnroot;
|
||||
};
|
||||
|
||||
JSStudioEventListenerWrapper::JSStudioEventListenerWrapper()
|
||||
: m_bNeedUnroot(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JSStudioEventListenerWrapper::~JSStudioEventListenerWrapper()
|
||||
{
|
||||
if (m_bNeedUnroot)
|
||||
{
|
||||
JSObject *thisObj = JSVAL_TO_OBJECT(_jsThisObj);
|
||||
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||
JS_RemoveObjectRoot(cx, &thisObj);
|
||||
}
|
||||
}
|
||||
|
||||
void JSStudioEventListenerWrapper::setJSCallbackThis(jsval jsThisObj)
|
||||
{
|
||||
JSCallbackWrapper::setJSCallbackThis(jsThisObj);
|
||||
|
||||
JSObject *thisObj = JSVAL_TO_OBJECT(jsThisObj);
|
||||
js_proxy *p = jsb_get_js_proxy(thisObj);
|
||||
if (!p)
|
||||
{
|
||||
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||
JS_AddObjectRoot(cx, &thisObj);
|
||||
m_bNeedUnroot = true;
|
||||
}
|
||||
}
|
||||
|
||||
void JSStudioEventListenerWrapper::eventCallbackFunc(Object* sender,int eventType)
|
||||
{
|
||||
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
|
||||
JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj);
|
||||
js_proxy_t *proxy = js_get_or_create_proxy(cx, sender);
|
||||
jsval retval;
|
||||
if (_jsCallback != JSVAL_VOID)
|
||||
{
|
||||
jsval touchVal = INT_TO_JSVAL(eventType);
|
||||
|
||||
jsval valArr[2];
|
||||
valArr[0] = OBJECT_TO_JSVAL(proxy->obj);
|
||||
valArr[1] = touchVal;
|
||||
|
||||
JS_AddValueRoot(cx, valArr);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 2, valArr, &retval);
|
||||
JS_RemoveValueRoot(cx, valArr);
|
||||
}
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UIWidget* cobj = (gui::UIWidget *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addTouchEventListener(tmpObj, toucheventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UICheckBox* cobj = (gui::UICheckBox *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UISlider* cobj = (gui::UISlider *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UITextField* cobj = (gui::UITextField *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addEventListenerTextField(tmpObj, textfieldeventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UIPageView* cobj = (gui::UIPageView *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addEventListenerPageView(tmpObj, pagevieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UIListView* cobj = (gui::UIListView *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 2) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper();
|
||||
cobj->setUserObject(tmpObj);
|
||||
tmpObj->release();
|
||||
|
||||
tmpObj->setJSCallbackFunc(argv[0]);
|
||||
tmpObj->setJSCallbackThis(argv[1]);
|
||||
|
||||
cobj->addEventListenerListView(tmpObj, listvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UILayoutParameter* cobj = (gui::UILayoutParameter *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 1) {
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
JSObject *tmp;
|
||||
JS::RootedValue jsleft(cx), jstop(cx),jsright(cx),jsbottom(cx);
|
||||
double left, top,right,bottom;
|
||||
JSBool ok = argv[0].isObject() &&
|
||||
JS_ValueToObject(cx, argv[0], &tmp) &&
|
||||
JS_GetProperty(cx, tmp, "left", &jsleft) &&
|
||||
JS_GetProperty(cx, tmp, "top", &jstop) &&
|
||||
JS_GetProperty(cx, tmp, "right", &jsright) &&
|
||||
JS_GetProperty(cx, tmp, "bottom", &jsbottom) &&
|
||||
JS_ValueToNumber(cx, jsleft, &left) &&
|
||||
JS_ValueToNumber(cx, jstop, &top) &&
|
||||
JS_ValueToNumber(cx, jsright, &right) &&
|
||||
JS_ValueToNumber(cx, jsbottom, &bottom);
|
||||
|
||||
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
|
||||
|
||||
cobj->setMargin(gui::UIMargin(left,top,right,bottom));
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
static JSBool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
gui::UILayoutParameter* cobj = (gui::UILayoutParameter *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
|
||||
|
||||
if (argc == 0) {
|
||||
JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL);
|
||||
if (!tmp) return JS_FALSE;
|
||||
gui::UIMargin margin = cobj->getMargin();
|
||||
JSBool ok = JS_DefineProperty(cx, tmp, "left", DOUBLE_TO_JSVAL(margin.left), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "top", DOUBLE_TO_JSVAL(margin.top), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "right", DOUBLE_TO_JSVAL(margin.right), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
JS_DefineProperty(cx, tmp, "bottom", DOUBLE_TO_JSVAL(margin.bottom), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
if (ok)
|
||||
{
|
||||
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
JS_ReportError(cx, "Invalid number of arguments");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
extern JSObject* jsb_UIWidget_prototype;
|
||||
extern JSObject* jsb_UICheckBox_prototype;
|
||||
extern JSObject* jsb_UISlider_prototype;
|
||||
extern JSObject* jsb_UITextField_prototype;
|
||||
extern JSObject* jsb_UILayoutParameter_prototype;
|
||||
extern JSObject* jsb_UIPageView_prototype;
|
||||
extern JSObject* jsb_UIListView_prototype;
|
||||
|
||||
void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global)
|
||||
{
|
||||
JS_DefineFunction(cx, jsb_UIWidget_prototype, "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UICheckBox_prototype, "addEventListenerCheckBox", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UISlider_prototype, "addEventListenerSlider", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UITextField_prototype, "addEventListenerTextField", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UIPageView_prototype, "addEventListenerPageView", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UIListView_prototype, "addEventListenerListView", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UILayoutParameter_prototype, "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, jsb_UILayoutParameter_prototype, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// jsb_cocos2dx_gui_manual.h
|
||||
//
|
||||
// Created by LinWenhai on 17/11/13.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __jsb_cocos2dx_gui_manual__
|
||||
#define __jsb_cocos2dx_gui_manual__
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
void register_all_cocos2dx_gui_manual(JSContext* cx, JSObject* global);
|
||||
|
||||
#endif /* defined(__jsb_cocos2dx_gui_manual__) */
|
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto.cpp" />
|
||||
<ClCompile Include="jsb_cocos2dx_gui_manual.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto.hpp" />
|
||||
<ClInclude Include="jsb_cocos2dx_gui_manual.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto_api.js" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9A844C88-97E8-4E2D-B09A-E138C67D338B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libJSBindingForGui</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\2d\cocos2d_headers.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\2d\cocos2d_headers.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration).win32\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IntDir>$(Configuration).win32\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)$(Configuration).win32\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IntDir>$(Configuration).win32\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4068;4101;4800;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(OutDir)"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4068;4101;4800;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="generated">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="manual">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto.cpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="jsb_cocos2dx_gui_manual.cpp">
|
||||
<Filter>manual</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto.hpp">
|
||||
<Filter>generated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="jsb_cocos2dx_gui_manual.h">
|
||||
<Filter>manual</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\auto-generated\js-bindings\jsb_cocos2dx_gui_auto_api.js">
|
||||
<Filter>generated</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -6,6 +6,8 @@
|
|||
require('jsb_cocos2d_constants.js');
|
||||
require('jsb_cocos2d.js');
|
||||
require('jsb_cocos2d_extension.js');
|
||||
require('jsb_cocos2d_studio.js');
|
||||
require('jsb_cocos2d_gui.js');
|
||||
require('jsb_chipmunk_constants.js');
|
||||
require('jsb_chipmunk.js');
|
||||
require('jsb_opengl_constants.js');
|
||||
|
|
|
@ -4,6 +4,20 @@
|
|||
|
||||
var cc = cc || {};
|
||||
|
||||
cc.TARGET_PLATFORM = {
|
||||
WINDOWS:0,
|
||||
LINUX:1,
|
||||
MACOS:2,
|
||||
ANDROID:3,
|
||||
IPHONE:4,
|
||||
IPAD:5,
|
||||
BLACKBERRY:6,
|
||||
NACL:7,
|
||||
EMSCRIPTEN:8,
|
||||
MOBILE_BROWSER:100,
|
||||
PC_BROWSER:101
|
||||
};
|
||||
|
||||
cc.RESOLUTION_POLICY = {
|
||||
// The entire application is visible in the specified area without trying to preserve the original aspect ratio.
|
||||
// Distortion can occur, and the application may appear stretched or compressed.
|
||||
|
@ -202,6 +216,10 @@ cc.pointEqualToPoint = function (point1, point2) {
|
|||
return ((point1.x == point2.x) && (point1.y == point2.y));
|
||||
};
|
||||
|
||||
cc.PointZero = function () {
|
||||
return cc.p(0, 0);
|
||||
};
|
||||
|
||||
//
|
||||
// Grid
|
||||
//
|
||||
|
@ -230,6 +248,10 @@ cc.sizeEqualToSize = function (size1, size2)
|
|||
return ((size1.width == size2.width) && (size1.height == size2.height));
|
||||
};
|
||||
|
||||
cc.SizeZero = function () {
|
||||
return cc.size(0, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* create a cc.rect object
|
||||
* @param {Number|cc.point|cc.rect} [x] a Number value as x or a cc.point object as origin or a cc.rect clone object
|
||||
|
@ -338,6 +360,10 @@ cc.rectIntersection = function (rectA, rectB) {
|
|||
return intersection;
|
||||
};
|
||||
|
||||
cc.RectZero = function () {
|
||||
return cc.rect(0, 0, 0, 0);
|
||||
};
|
||||
|
||||
//
|
||||
// Array: for cocos2d-html5 compatibility
|
||||
//
|
||||
|
@ -586,3 +612,5 @@ cc.Loader.preload = function (resources, selector, target) {
|
|||
this._instance.initWith(resources, selector, target);
|
||||
return this._instance;
|
||||
};
|
||||
|
||||
cc.LoaderScene = cc.Loader;
|
|
@ -0,0 +1,183 @@
|
|||
//
|
||||
// cocos2d gui constants
|
||||
//
|
||||
// This helper file should be required after jsb_cocos2d.js
|
||||
//
|
||||
|
||||
var ccs = ccs || {};
|
||||
|
||||
ccs.BrightStyle = {
|
||||
none: -1,
|
||||
normal: 0,
|
||||
highlight: 1
|
||||
};
|
||||
|
||||
ccs.WidgetType = {
|
||||
widget: 0, //control
|
||||
container: 1 //container
|
||||
};
|
||||
|
||||
ccs.TextureResType = {
|
||||
local: 0,
|
||||
plist: 1
|
||||
};
|
||||
|
||||
ccs.TouchEventType = {
|
||||
began: 0,
|
||||
moved: 1,
|
||||
ended: 2,
|
||||
canceled: 3
|
||||
};
|
||||
|
||||
ccs.SizeType = {
|
||||
absolute: 0,
|
||||
percent: 1
|
||||
};
|
||||
|
||||
ccs.PositionType = {
|
||||
absolute: 0,
|
||||
percent: 1
|
||||
};
|
||||
|
||||
ccs.CheckBoxEventType = {
|
||||
selected: 0,
|
||||
unselected: 1
|
||||
};
|
||||
|
||||
ccs.TextFiledEventType = {
|
||||
attach_with_me: 0,
|
||||
detach_with_ime: 1,
|
||||
insert_text: 2,
|
||||
delete_backward: 3
|
||||
};
|
||||
|
||||
ccs.LayoutBackGroundColorType = {
|
||||
none: 0,
|
||||
solid: 1,
|
||||
gradient: 2
|
||||
};
|
||||
|
||||
ccs.LayoutType = {
|
||||
absolute: 0,
|
||||
linearVertical: 1,
|
||||
linearHorizontal: 2,
|
||||
relative: 3
|
||||
};
|
||||
|
||||
ccs.UILayoutParameterType = {
|
||||
none: 0,
|
||||
linear: 1,
|
||||
relative: 2
|
||||
};
|
||||
|
||||
ccs.UILinearGravity = {
|
||||
none: 0,
|
||||
left: 1,
|
||||
top: 2,
|
||||
right: 3,
|
||||
bottom: 4,
|
||||
centerVertical: 5,
|
||||
centerHorizontal: 6
|
||||
};
|
||||
|
||||
ccs.UIRelativeAlign = {
|
||||
alignNone: 0,
|
||||
alignParentTopLeft: 1,
|
||||
alignParentTopCenterHorizontal: 2,
|
||||
alignParentTopRight: 3,
|
||||
alignParentLeftCenterVertical: 4,
|
||||
centerInParent: 5,
|
||||
alignParentRightCenterVertical: 6,
|
||||
alignParentLeftBottom: 7,
|
||||
alignParentBottomCenterHorizontal: 8,
|
||||
alignParentRightBottom: 9,
|
||||
locationAboveLeftAlign: 10,
|
||||
locationAboveCenter: 11,
|
||||
locationAboveRightAlign: 12,
|
||||
locationLeftOfTopAlign: 13,
|
||||
locationLeftOfCenter: 14,
|
||||
locationLeftOfBottomAlign: 15,
|
||||
locationRightOfTopAlign: 16,
|
||||
locationRightOfCenter: 17,
|
||||
locationRightOfBottomAlign: 18,
|
||||
locationBelowLeftAlign: 19,
|
||||
locationBelowCenter: 20,
|
||||
locationBelowRightAlign: 21
|
||||
};
|
||||
|
||||
ccs.SliderEventType = {percent_changed: 0};
|
||||
|
||||
ccs.LoadingBarType = { left: 0, right: 1};
|
||||
|
||||
ccs.ScrollViewDir = {
|
||||
none: 0,
|
||||
vertical: 1,
|
||||
horizontal: 2,
|
||||
both: 3
|
||||
};
|
||||
|
||||
ccs.ScrollviewEventType = {
|
||||
scrollToTop: 0,
|
||||
scrollToBottom: 1,
|
||||
scrollToLeft: 2,
|
||||
scrollToRight: 3,
|
||||
scrolling: 4,
|
||||
bounceTop: 5,
|
||||
bounceBottom: 6,
|
||||
bounceLeft: 7,
|
||||
bounceRight: 8
|
||||
};
|
||||
|
||||
ccs.ListViewEventType = {
|
||||
init_child: 0,
|
||||
update_child: 1
|
||||
};
|
||||
|
||||
ccs.PageViewEventType = {
|
||||
turning: 0
|
||||
};
|
||||
|
||||
ccs.PVTouchDir = {
|
||||
touchLeft: 0,
|
||||
touchRight: 1
|
||||
};
|
||||
|
||||
ccs.UIPanel = ccs.UILayout;
|
||||
ccs.UITextArea = ccs.UILabel;
|
||||
ccs.UIContainerWidget = ccs.UILayout;
|
||||
ccs.UITextButton = ccs.UIButton;
|
||||
ccs.UINodeContainer = ccs.UIWidget;
|
||||
ccs.PanelColorType = ccs.LayoutBackGroundColorType;
|
||||
|
||||
ccs.UILayout = ccs.Layout;
|
||||
|
||||
ccs.UIMargin = cc.Class.extend({
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
ctor: function () {
|
||||
if (arguments.length == 1) {
|
||||
var uiMargin = arguments[0];
|
||||
this.left = uiMargin.left;
|
||||
this.top = uiMargin.top;
|
||||
this.right = uiMargin.right;
|
||||
this.bottom = uiMargin.bottom;
|
||||
}
|
||||
if (arguments.length == 4) {
|
||||
this.left = arguments[0];
|
||||
this.top = arguments[1];
|
||||
this.right = arguments[2];
|
||||
this.bottom = arguments[3];
|
||||
}
|
||||
},
|
||||
setMargin: function (l, t, r, b) {
|
||||
this.left = l;
|
||||
this.top = t;
|
||||
this.right = r;
|
||||
this.bottom = b;
|
||||
},
|
||||
equals: function (target) {
|
||||
return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom);
|
||||
}
|
||||
});
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// cocos2d studio constants
|
||||
//
|
||||
// This helper file should be required after jsb_cocos2d.js
|
||||
//
|
||||
|
||||
var ccs = ccs || {};
|
||||
|
||||
//movement event type
|
||||
ccs.MovementEventType = {
|
||||
start: 0,
|
||||
complete: 1,
|
||||
loopComplete: 2
|
||||
};
|
||||
|
||||
// Armature
|
||||
if(ccs.Armature){
|
||||
ccs.Armature.prototype.setBody = function( body ) {
|
||||
var b = body;
|
||||
if( body.handle !== undefined )
|
||||
b = body.handle;
|
||||
return this._setCPBody( b );
|
||||
};
|
||||
|
||||
ccs.ComController.extend = cc.Class.extend;
|
||||
ccs.Armature.extend = cc.Class.extend;
|
||||
}
|
|
@ -7,8 +7,10 @@
|
|||
#include "jsb_cocos2dx_extension_auto.hpp"
|
||||
#include "jsb_cocos2dx_builder_auto.hpp"
|
||||
#include "jsb_cocos2dx_studio_auto.hpp"
|
||||
#include "jsb_cocos2dx_gui_auto.hpp"
|
||||
#include "extension/jsb_cocos2dx_extension_manual.h"
|
||||
#include "cocostudio/jsb_cocos2dx_studio_manual.h"
|
||||
#include "gui/jsb_cocos2dx_gui_manual.h"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
#include "cocosbuilder/cocosbuilder_specifics.hpp"
|
||||
#include "chipmunk/js_bindings_chipmunk_registration.h"
|
||||
|
@ -47,6 +49,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
FileUtils::getInstance()->addSearchPath("res");
|
||||
FileUtils::getInstance()->addSearchPath("script");
|
||||
FileUtils::getInstance()->addSearchPath("res/scenetest");
|
||||
|
||||
ScriptingCore* sc = ScriptingCore::getInstance();
|
||||
sc->addRegisterCallback(register_all_cocos2dx);
|
||||
|
@ -62,6 +65,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
sc->addRegisterCallback(register_all_cocos2dx_builder);
|
||||
sc->addRegisterCallback(register_CCBuilderReader);
|
||||
|
||||
sc->addRegisterCallback(register_all_cocos2dx_gui);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_gui_manual);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_studio);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_studio_manual);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES += jsb_extension_static
|
|||
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_localstorage_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_network_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_builder_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_gui_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_studio_static
|
||||
|
||||
|
||||
|
@ -30,4 +31,5 @@ $(call import-module,scripting/javascript/bindings/extension)
|
|||
$(call import-module,scripting/javascript/bindings/localstorage)
|
||||
$(call import-module,scripting/javascript/bindings/network)
|
||||
$(call import-module,scripting/javascript/bindings/cocosbuilder)
|
||||
$(call import-module,scripting/javascript/bindings/gui)
|
||||
$(call import-module,scripting/javascript/bindings/cocostudio)
|
||||
|
|
|
@ -225,6 +225,9 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y</Co
|
|||
<ProjectReference Include="..\..\..\..\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj">
|
||||
<Project>{625f7391-9a91-48a1-8cfc-79508c822637}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\cocos\scripting\javascript\bindings\gui\libJSBindingForGui.vcxproj">
|
||||
<Project>{9a844c88-97e8-4e2d-b09a-e138c67d338b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj">
|
||||
<Project>{68f5f371-bd7b-4c30-ae5b-0b08f22e0cde}</Project>
|
||||
</ProjectReference>
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
[cocos2dx_gui]
|
||||
# the prefix to be added to the generated functions. You might or might not use this in your own
|
||||
# templates
|
||||
prefix = cocos2dx_gui
|
||||
|
||||
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
|
||||
# all classes will be embedded in that namespace
|
||||
target_namespace = ccs
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
clang_flags = -nostdinc -x c++ -std=c++11
|
||||
|
||||
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s
|
||||
|
||||
cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT
|
||||
|
||||
cxxgenerator_headers =
|
||||
|
||||
# extra arguments for clang
|
||||
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||
|
||||
# what headers to parse
|
||||
headers = %(cocosdir)s/cocos/gui/CocosGUI.h
|
||||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = UIHelper UILayout UIWidget UILayer UIButton UICheckBox UIImageView UILabel UILabelAtlas UILabelBMFont UILoadingBar UISlider UISwitch UITextField UIScrollView UIPageView UIListView UILayoutParameter UILinearLayoutParameter UIRelativeLayoutParameter
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
|
||||
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
|
||||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*],
|
||||
UIWidget::[(s|g)etUserObject],
|
||||
UILayer::[getInputManager],
|
||||
UILayoutParameter::[(s|g)etMargin],
|
||||
UIImageView::[doubleClickEvent checkDoubleClick]
|
||||
|
||||
rename_functions =
|
||||
|
||||
rename_classes =
|
||||
|
||||
# for all class names, should we remove something when registering in the target VM?
|
||||
remove_prefix =
|
||||
|
||||
# classes for which there will be no "parent" lookup
|
||||
classes_have_no_parents = UIHelper
|
||||
|
||||
# base classes which will be skipped when their sub-classes found them.
|
||||
base_classes_to_skip = Object
|
||||
|
||||
# classes that create no constructor
|
||||
# Set is special and we will use a hand-written constructor
|
||||
abstract_classes = UIHelper
|
||||
|
||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||
script_control_cpp = no
|
||||
|
|
@ -5,7 +5,7 @@ prefix = cocos2dx_studio
|
|||
|
||||
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
|
||||
# all classes will be embedded in that namespace
|
||||
target_namespace = cc
|
||||
target_namespace = ccs
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager
|
||||
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -36,29 +36,34 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = .*Delegate::[*],
|
||||
.*Loader.*::[*],
|
||||
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener],
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*],
|
||||
InputDelegate::[didAccelerate on.*],
|
||||
GUIReader::[storeFileDesignSize getFileDesignSize],
|
||||
ComAttribute::[getDict],
|
||||
BatchNode::[init draw],
|
||||
Armature::[createBone updateBlendType getBody setBody getShapeList .*BlendFunc],
|
||||
Skin::[getSkinData setSkinData],
|
||||
ArmatureAnimation::[updateHandler updateFrameData frameEvent]
|
||||
ArmatureAnimation::[updateHandler updateFrameData frameEvent],
|
||||
ActionManagerEx::[initWithDictionary]
|
||||
|
||||
rename_functions =
|
||||
rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=purge],
|
||||
SceneReader::[purgeSceneReader=purge],
|
||||
GUIReader::[shareReader=getInstance purgeGUIReader=purge]
|
||||
|
||||
rename_classes =
|
||||
rename_classes = ActionManagerEx::ActionManager
|
||||
|
||||
# for all class names, should we remove something when registering in the target VM?
|
||||
remove_prefix =
|
||||
|
||||
# classes for which there will be no "parent" lookup
|
||||
classes_have_no_parents =
|
||||
classes_have_no_parents = InputDelegate SceneReader
|
||||
|
||||
# base classes which will be skipped when their sub-classes found them.
|
||||
base_classes_to_skip = Object ProcessBase
|
||||
|
||||
# classes that create no constructor
|
||||
# Set is special and we will use a hand-written constructor
|
||||
abstract_classes = ArmatureDataManager
|
||||
abstract_classes = ArmatureDataManager ComAttribute InputDelegate ComRender ComAudio InputDelegate ActionManagerEx SceneReader GUIReader BatchNode
|
||||
|
||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||
script_control_cpp = no
|
||||
|
|
|
@ -88,5 +88,8 @@ LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py
|
|||
echo "Generating bindings for cocos2dx_builder..."
|
||||
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_builder.ini -s cocos2dx_builder -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_builder_auto
|
||||
|
||||
echo "Generating bindings for cocos2dx_gui..."
|
||||
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_gui_auto
|
||||
|
||||
echo "Generating bindings for cocos2dx_studio..."
|
||||
LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t spidermonkey -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/js-bindings -n jsb_cocos2dx_studio_auto
|
Loading…
Reference in New Issue