From dcc98ef79fec1964886b2b0a34a2a02b3702b95e Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 11 Mar 2014 17:37:00 +0800 Subject: [PATCH] rename cocos2dx_gui to cocos2dx_ui --- .../lua-bindings/auto/api/ScrollView.lua | 255 +++--- .../auto/api/lua_cocos2dx_gui_auto_api.lua | 94 --- .../lua_cocos2dx_gui_auto.cpp.REMOVED.git-id | 1 - .../auto/lua_cocos2dx_gui_auto.hpp | 351 -------- .../manual/lua_cocos2dx_gui_manual.cpp | 765 ------------------ .../manual/lua_cocos2dx_gui_manual.hpp | 48 -- .../{cocos2dx_gui.ini => cocos2dx_ui.ini} | 0 tools/tolua/genbindings.py | 6 +- 8 files changed, 141 insertions(+), 1379 deletions(-) delete mode 100644 cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_gui_auto_api.lua delete mode 100644 cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.cpp.REMOVED.git-id delete mode 100644 cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.hpp delete mode 100644 cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.cpp delete mode 100644 cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.hpp rename tools/tolua/{cocos2dx_gui.ini => cocos2dx_ui.ini} (100%) diff --git a/cocos/scripting/lua-bindings/auto/api/ScrollView.lua b/cocos/scripting/lua-bindings/auto/api/ScrollView.lua index 05ce95c9ee..e2a02c3d00 100644 --- a/cocos/scripting/lua-bindings/auto/api/ScrollView.lua +++ b/cocos/scripting/lua-bindings/auto/api/ScrollView.lua @@ -2,176 +2,197 @@ -------------------------------- -- @module ScrollView -------------------------------- --- @function [parent=#ScrollView] scrollToTop --- @param self --- @param #float float --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] scrollToPercentHorizontal --- @param self --- @param #float float --- @param #float float --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] isInertiaScrollEnabled +-- @function [parent=#ScrollView] isClippingToBounds -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#ScrollView] scrollToPercentBothDirection +-- @function [parent=#ScrollView] setContainer +-- @param self +-- @param #cc.Node node + +-------------------------------- +-- @function [parent=#ScrollView] onTouchEnded +-- @param self +-- @param #cc.Touch touch +-- @param #cc.Event event + +-------------------------------- +-- @function [parent=#ScrollView] setContentOffsetInDuration -- @param self -- @param #point_table point -- @param #float float + +-------------------------------- +-- @function [parent=#ScrollView] setZoomScaleInDuration +-- @param self +-- @param #float float +-- @param #float float + +-------------------------------- +-- @function [parent=#ScrollView] setBounceable +-- @param self -- @param #bool bool -------------------------------- -- @function [parent=#ScrollView] getDirection -- @param self --- @return SCROLLVIEW_DIR#SCROLLVIEW_DIR ret (return value: ccui.SCROLLVIEW_DIR) +-- @return ScrollView::Direction#ScrollView::Direction ret (return value: cc.ScrollView::Direction) -------------------------------- --- @function [parent=#ScrollView] scrollToBottomLeft +-- @function [parent=#ScrollView] getContainer +-- @param self +-- @return Node#Node ret (return value: cc.Node) + +-------------------------------- +-- @function [parent=#ScrollView] updateTweenAction -- @param self -- @param #float float --- @param #bool bool +-- @param #string str -------------------------------- --- @function [parent=#ScrollView] getInnerContainer +-- @function [parent=#ScrollView] getZoomScale -- @param self --- @return Layout#Layout ret (return value: ccui.Layout) +-- @return float#float ret (return value: float) -------------------------------- --- @function [parent=#ScrollView] jumpToBottom +-- @function [parent=#ScrollView] updateInset -- @param self +-------------------------------- +-- @function [parent=#ScrollView] initWithViewSize +-- @param self +-- @param #size_table size +-- @param #cc.Node node +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] pause +-- @param self +-- @param #cc.Ref ref + -------------------------------- -- @function [parent=#ScrollView] setDirection -- @param self --- @param #ccui.SCROLLVIEW_DIR scrollview_dir +-- @param #cc.ScrollView::Direction direction -------------------------------- --- @function [parent=#ScrollView] scrollToTopLeft --- @param self --- @param #float float --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] jumpToTopRight --- @param self - --------------------------------- --- @function [parent=#ScrollView] jumpToBottomLeft --- @param self - --------------------------------- --- @function [parent=#ScrollView] setInnerContainerSize --- @param self --- @param #size_table size - --------------------------------- --- @function [parent=#ScrollView] getInnerContainerSize --- @param self --- @return size_table#size_table ret (return value: size_table) - --------------------------------- --- @function [parent=#ScrollView] isBounceEnabled +-- @function [parent=#ScrollView] init -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- --- @function [parent=#ScrollView] jumpToPercentVertical --- @param self --- @param #float float - --------------------------------- --- @function [parent=#ScrollView] setInertiaScrollEnabled --- @param self --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] jumpToTopLeft --- @param self - --------------------------------- --- @function [parent=#ScrollView] jumpToPercentHorizontal --- @param self --- @param #float float - --------------------------------- --- @function [parent=#ScrollView] jumpToBottomRight --- @param self - --------------------------------- --- @function [parent=#ScrollView] setBounceEnabled --- @param self --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] jumpToTop --- @param self - --------------------------------- --- @function [parent=#ScrollView] scrollToLeft --- @param self --- @param #float float --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] jumpToPercentBothDirection +-- @function [parent=#ScrollView] setContentOffset -- @param self -- @param #point_table point - --------------------------------- --- @function [parent=#ScrollView] scrollToPercentVertical --- @param self --- @param #float float --- @param #float float -- @param #bool bool -------------------------------- --- @function [parent=#ScrollView] scrollToBottom +-- @function [parent=#ScrollView] isDragging +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] isTouchEnabled +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] isBounceable +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] setTouchEnabled -- @param self --- @param #float float -- @param #bool bool -------------------------------- --- @function [parent=#ScrollView] scrollToBottomRight +-- @function [parent=#ScrollView] onTouchMoved +-- @param self +-- @param #cc.Touch touch +-- @param #cc.Event event + +-------------------------------- +-- @function [parent=#ScrollView] getContentOffset +-- @param self +-- @return point_table#point_table ret (return value: point_table) + +-------------------------------- +-- @function [parent=#ScrollView] resume +-- @param self +-- @param #cc.Ref ref + +-------------------------------- +-- @function [parent=#ScrollView] setClippingToBounds -- @param self --- @param #float float -- @param #bool bool -------------------------------- --- @function [parent=#ScrollView] jumpToLeft +-- @function [parent=#ScrollView] setViewSize -- @param self +-- @param #size_table size -------------------------------- --- @function [parent=#ScrollView] scrollToRight +-- @function [parent=#ScrollView] onTouchCancelled +-- @param self +-- @param #cc.Touch touch +-- @param #cc.Event event + +-------------------------------- +-- @function [parent=#ScrollView] getViewSize +-- @param self +-- @return size_table#size_table ret (return value: size_table) + +-------------------------------- +-- @function [parent=#ScrollView] maxContainerOffset +-- @param self +-- @return point_table#point_table ret (return value: point_table) + +-------------------------------- +-- @function [parent=#ScrollView] onTouchBegan +-- @param self +-- @param #cc.Touch touch +-- @param #cc.Event event +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] isTouchMoved +-- @param self +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] isNodeVisible +-- @param self +-- @param #cc.Node node +-- @return bool#bool ret (return value: bool) + +-------------------------------- +-- @function [parent=#ScrollView] minContainerOffset +-- @param self +-- @return point_table#point_table ret (return value: point_table) + +-------------------------------- +-- overload function: setZoomScale(float, bool) +-- +-- overload function: setZoomScale(float) +-- +-- @function [parent=#ScrollView] setZoomScale -- @param self -- @param #float float -- @param #bool bool - + -------------------------------- --- @function [parent=#ScrollView] jumpToRight +-- overload function: create() +-- +-- overload function: create(size_table, cc.Node) +-- +-- @function [parent=#ScrollView] create -- @param self - --------------------------------- --- @function [parent=#ScrollView] scrollToTopRight --- @param self --- @param #float float --- @param #bool bool - --------------------------------- --- @function [parent=#ScrollView] create --- @param self --- @return ScrollView#ScrollView ret (return value: ccui.ScrollView) - --------------------------------- --- @function [parent=#ScrollView] createInstance --- @param self --- @return Ref#Ref ret (return value: cc.Ref) - +-- @param #size_table size +-- @param #cc.Node node +-- @return ScrollView#ScrollView ret (retunr value: cc.ScrollView) + -------------------------------- -- @function [parent=#ScrollView] ScrollView -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_gui_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_gui_auto_api.lua deleted file mode 100644 index 918cb1f330..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_gui_auto_api.lua +++ /dev/null @@ -1,94 +0,0 @@ --------------------------------- --- @module ccui - --------------------------------------------------------- --- the ccui LayoutParameter --- @field [parent=#ccui] LayoutParameter#LayoutParameter LayoutParameter preloaded module - - --------------------------------------------------------- --- the ccui LinearLayoutParameter --- @field [parent=#ccui] LinearLayoutParameter#LinearLayoutParameter LinearLayoutParameter preloaded module - - --------------------------------------------------------- --- the ccui RelativeLayoutParameter --- @field [parent=#ccui] RelativeLayoutParameter#RelativeLayoutParameter RelativeLayoutParameter preloaded module - - --------------------------------------------------------- --- the ccui Widget --- @field [parent=#ccui] Widget#Widget Widget preloaded module - - --------------------------------------------------------- --- the ccui Layout --- @field [parent=#ccui] Layout#Layout Layout preloaded module - - --------------------------------------------------------- --- the ccui Button --- @field [parent=#ccui] Button#Button Button preloaded module - - --------------------------------------------------------- --- the ccui CheckBox --- @field [parent=#ccui] CheckBox#CheckBox CheckBox preloaded module - - --------------------------------------------------------- --- the ccui ImageView --- @field [parent=#ccui] ImageView#ImageView ImageView preloaded module - - --------------------------------------------------------- --- the ccui Text --- @field [parent=#ccui] Text#Text Text preloaded module - - --------------------------------------------------------- --- the ccui TextAtlas --- @field [parent=#ccui] TextAtlas#TextAtlas TextAtlas preloaded module - - --------------------------------------------------------- --- the ccui LoadingBar --- @field [parent=#ccui] LoadingBar#LoadingBar LoadingBar preloaded module - - --------------------------------------------------------- --- the ccui ScrollView --- @field [parent=#ccui] ScrollView#ScrollView ScrollView preloaded module - - --------------------------------------------------------- --- the ccui ListView --- @field [parent=#ccui] ListView#ListView ListView preloaded module - - --------------------------------------------------------- --- the ccui Slider --- @field [parent=#ccui] Slider#Slider Slider preloaded module - - --------------------------------------------------------- --- the ccui TextField --- @field [parent=#ccui] TextField#TextField TextField preloaded module - - --------------------------------------------------------- --- the ccui TextBMFont --- @field [parent=#ccui] TextBMFont#TextBMFont TextBMFont preloaded module - - --------------------------------------------------------- --- the ccui PageView --- @field [parent=#ccui] PageView#PageView PageView preloaded module - - --------------------------------------------------------- --- the ccui Helper --- @field [parent=#ccui] Helper#Helper Helper preloaded module - - -return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.cpp.REMOVED.git-id deleted file mode 100644 index f894d8b69c..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.cpp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -8a35e56a7f283d9816a34997ab75c41201e1c1da \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.hpp deleted file mode 100644 index 472d1be093..0000000000 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_gui_auto.hpp +++ /dev/null @@ -1,351 +0,0 @@ -#ifndef __cocos2dx_ui_h__ -#define __cocos2dx_ui_h__ - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -int register_all_cocos2dx_ui(lua_State* tolua_S); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#endif // __cocos2dx_ui_h__ diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.cpp b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.cpp deleted file mode 100644 index 2fb9b15452..0000000000 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.cpp +++ /dev/null @@ -1,765 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -#include "lua_cocos2dx_gui_manual.hpp" -#include "cocos2d.h" -#include "tolua_fix.h" -#include "LuaBasicConversions.h" -#include "LuaScriptHandlerMgr.h" -#include "CCLuaValue.h" -#include "CocosGUI.h" -#include "CCLuaEngine.h" - -using namespace ui; - -class LuaCocoStudioEventListener:public Ref -{ -public: - LuaCocoStudioEventListener(); - virtual ~LuaCocoStudioEventListener(); - - static LuaCocoStudioEventListener* create(); - - virtual void eventCallbackFunc(Ref* sender,int eventType); -}; - -LuaCocoStudioEventListener::LuaCocoStudioEventListener() -{ - -} - -LuaCocoStudioEventListener::~LuaCocoStudioEventListener() -{ - -} - -LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() -{ - LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); - if (nullptr == listener) - return nullptr; - - listener->autorelease(); - - return listener; -} - -void LuaCocoStudioEventListener::eventCallbackFunc(Ref* sender,int eventType) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - if (0 != handler) - { - LuaStudioEventListenerData eventData(sender,eventType); - BasicScriptData data(this,(void*)&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER, (void*)&data); - } -} - -static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - Widget* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "widgetTouchEvent"); - - self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addTouchEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err); - return 0; -#endif -} - -static void extendWidget(lua_State* L) -{ - lua_pushstring(L, "ccui.Widget"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addTouchEventListener", lua_cocos2dx_Widget_addTouchEventListener); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - CheckBox* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListenerCheckBox'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "checkBoxEventListener"); - - self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerCheckBox' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err); - return 0; -#endif -} - - -static void extendCheckBox(lua_State* L) -{ - lua_pushstring(L, "ccui.CheckBox"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_CheckBox_addEventListenerCheckBox); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - Slider* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListenerSlider'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "sliderEventListener"); - - self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerSlider' function of Slider has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err); - return 0; -#endif -} - -static void extendSlider(lua_State* L) -{ - lua_pushstring(L, "ccui.Slider"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerSlider", lua_cocos2dx_Slider_addEventListenerSlider); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - TextField* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListenerTextField'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "textfieldEventListener"); - - self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerTextField' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); - return 0; -#endif -} - -static void extendTextField(lua_State* L) -{ - lua_pushstring(L, "ccui.TextField"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerTextField", lua_cocos2dx_TextField_addEventListenerTextField); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - PageView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListenerPageView'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "pageViewEventListener"); - - self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerPageView' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err); - return 0; -#endif -} - -static void extendPageView(lua_State* L) -{ - lua_pushstring(L, "ccui.PageView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerPageView", lua_cocos2dx_PageView_addEventListenerPageView); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_ScrollView_addEventListenerScrollView(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - ScrollView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.ScrollView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ScrollView_addEventListenerScrollView'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "scrollViewEventListener"); - - self->addEventListenerScrollView(listener, scrollvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerScrollView' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerScrollView'.",&tolua_err); - return 0; -#endif -} - -static void extendScrollView(lua_State* L) -{ - lua_pushstring(L, "ccui.ScrollView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerScrollView", lua_cocos2dx_ScrollView_addEventListenerScrollView); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - ListView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListenerListView'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - __Dictionary* dict = static_cast<__Dictionary*>(self->getUserObject()); - if (nullptr == dict) - { - dict = Dictionary::create(); - self->setUserObject(dict); - } - dict->setObject(listener, "listViewEventListener"); - - self->addEventListenerListView(listener, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerListView' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err); - return 0; -#endif -} - -static void extendListView(lua_State* L) -{ - lua_pushstring(L, "ccui.ListView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerListView", lua_cocos2dx_ListView_addEventListenerListView); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - LayoutParameter* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_istable(L, 2, 0, &tolua_err)) - { - goto tolua_lerror; - } -#endif - - Margin margin; - lua_pushstring(L, "left"); - lua_gettable(L,2); - margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "top"); - lua_gettable(L,2); - margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "right"); - lua_gettable(L,2); - margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "bottom"); - lua_gettable(L,2); - margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - self->setMargin(margin); - return 0; - } - - CCLOG("'setMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - LayoutParameter* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - - if (0 == argc) - { - Margin margin = self->getMargin(); - - lua_newtable(L); - - lua_pushstring(L, "left"); - lua_pushnumber(L, (lua_Number) margin.left); - lua_rawset(L, -3); - - lua_pushstring(L, "top"); - lua_pushnumber(L, (lua_Number) margin.top); - lua_rawset(L, -3); - - lua_pushstring(L, "right"); - lua_pushnumber(L, (lua_Number) margin.right); - lua_rawset(L, -3); - - lua_pushstring(L, "bottom"); - lua_pushnumber(L, (lua_Number) margin.bottom); - lua_rawset(L, -3); - - return 1; - } - - CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err); - return 0; -#endif -} - -static void extendLayoutParameter(lua_State* L) -{ - lua_pushstring(L, "ccui.LayoutParameter"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "setMargin", lua_cocos2dx_LayoutParameter_setMargin); - tolua_function(L, "getMargin", lua_cocos2dx_LayoutParameter_getMargin); - } - lua_pop(L, 1); -} - -int register_all_cocos2dx_ui_manual(lua_State* L) -{ - if (nullptr == L) - return 0; - extendWidget(L); - extendCheckBox(L); - extendSlider(L); - extendTextField(L); - extendPageView(L); - extendScrollView(L); - extendListView(L); - extendLayoutParameter(L); - - return 0; -} diff --git a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.hpp b/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.hpp deleted file mode 100644 index a1846cb815..0000000000 --- a/cocos/scripting/lua-bindings/manual/lua_cocos2dx_gui_manual.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H -#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H - -#ifdef __cplusplus -extern "C" { -#endif -#include "tolua++.h" -#ifdef __cplusplus -} -#endif - -#include "CCRef.h" - -TOLUA_API int register_all_cocos2dx_ui_manual(lua_State* L); - -struct LuaStudioEventListenerData -{ - cocos2d::Ref* objTarget; - int eventType; - - LuaStudioEventListenerData(cocos2d::Ref* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) - { - } -}; -#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H diff --git a/tools/tolua/cocos2dx_gui.ini b/tools/tolua/cocos2dx_ui.ini similarity index 100% rename from tools/tolua/cocos2dx_gui.ini rename to tools/tolua/cocos2dx_ui.ini diff --git a/tools/tolua/genbindings.py b/tools/tolua/genbindings.py index 8905394f87..6e8b59c35d 100755 --- a/tools/tolua/genbindings.py +++ b/tools/tolua/genbindings.py @@ -106,7 +106,7 @@ def main(): if platform == 'win32': config.set('DEFAULT', 'extra_flags', '-D__WCHAR_MAX__=0x7fffffff -U__MINGW32__') - conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini')) + conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini')) print 'generating userconf.ini...' with open(conf_ini_file, 'w') as configfile: @@ -128,7 +128,7 @@ def main(): cmd_args = {'cocos2dx.ini' : ('cocos2d-x', 'lua_cocos2dx_auto'), \ 'cocos2dx_extension.ini' : ('cocos2dx_extension', 'lua_cocos2dx_extension_auto'), \ - 'cocos2dx_gui.ini' : ('cocos2dx_gui', 'lua_cocos2dx_gui_auto'), \ + 'cocos2dx_ui.ini' : ('cocos2dx_ui', 'lua_cocos2dx_ui_auto'), \ 'cocos2dx_studio.ini' : ('cocos2dx_studio', 'lua_cocos2dx_studio_auto'), \ 'cocos2dx_spine.ini' : ('cocos2dx_spine', 'lua_cocos2dx_spine_auto'), \ 'cocos2dx_physics.ini' : ('cocos2dx_physics', 'lua_cocos2dx_physics_auto'), \ @@ -158,7 +158,7 @@ def main(): sys.exit(1) else: raise - + # -------------- main -------------- if __name__ == '__main__':