issue #2868:modify ccs lua test samples

This commit is contained in:
samuele3 2013-11-12 16:52:03 +08:00
parent cfb1cfdf65
commit c1d256c159
5 changed files with 106 additions and 102 deletions

View File

@ -132,7 +132,7 @@ static void extendUIWidget(lua_State* L)
} }
} }
static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L) static int lua_cocos2dx_UICheckBox_addEventListenerCheckBox(lua_State* L)
{ {
if (nullptr == L) if (nullptr == L)
return 0; return 0;
@ -149,7 +149,7 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L)
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
if (nullptr == self) { if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListener'\n", NULL); tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UICheckBox_addEventListenerCheckBox'\n", NULL);
return 0; return 0;
} }
#endif #endif
@ -174,17 +174,17 @@ static int lua_cocos2dx_UICheckBox_addEventListener(lua_State* L)
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
self->setUserObject(listener); self->setUserObject(listener);
self->addEventListener(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0; return 0;
} }
CCLOG("'addEventListener' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); CCLOG("'addEventListenerCheckBox' function of UICheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0; return 0;
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
tolua_lerror: tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err);
return 0; return 0;
#endif #endif
} }
@ -196,11 +196,11 @@ static void extendUICheckBox(lua_State* L)
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1)) if (lua_istable(L,-1))
{ {
tolua_function(L, "addEventListener", lua_cocos2dx_UICheckBox_addEventListener); tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_UICheckBox_addEventListenerCheckBox);
} }
} }
static int lua_cocos2dx_UISlider_addEventListener(lua_State* L) static int lua_cocos2dx_UISlider_addEventListenerSlider(lua_State* L)
{ {
if (nullptr == L) if (nullptr == L)
return 0; return 0;
@ -217,7 +217,7 @@ static int lua_cocos2dx_UISlider_addEventListener(lua_State* L)
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
if (nullptr == self) { if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListener'\n", NULL); tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UISlider_addEventListenerSlider'\n", NULL);
return 0; return 0;
} }
#endif #endif
@ -242,18 +242,18 @@ static int lua_cocos2dx_UISlider_addEventListener(lua_State* L)
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
self->setUserObject(listener); self->setUserObject(listener);
self->addEventListener(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0; return 0;
} }
CCLOG("'addEventListener' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1); CCLOG("'addEventListenerSlider' function of UISlider has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0; return 0;
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
tolua_lerror: tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err);
return 0; return 0;
#endif #endif
} }
@ -264,11 +264,11 @@ static void extendUISlider(lua_State* L)
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1)) if (lua_istable(L,-1))
{ {
tolua_function(L, "addEventListener", lua_cocos2dx_UISlider_addEventListener); tolua_function(L, "addEventListenerSlider", lua_cocos2dx_UISlider_addEventListenerSlider);
} }
} }
static int lua_cocos2dx_UITextField_addEventListener(lua_State* L) static int lua_cocos2dx_UITextField_addEventListenerTextField(lua_State* L)
{ {
if (nullptr == L) if (nullptr == L)
return 0; return 0;
@ -285,7 +285,7 @@ static int lua_cocos2dx_UITextField_addEventListener(lua_State* L)
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
if (nullptr == self) { if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListener'\n", NULL); tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UITextField_addEventListenerTextField'\n", NULL);
return 0; return 0;
} }
#endif #endif
@ -310,18 +310,18 @@ static int lua_cocos2dx_UITextField_addEventListener(lua_State* L)
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
self->setUserObject(listener); self->setUserObject(listener);
self->addEventListener(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0; return 0;
} }
CCLOG("'addEventListener' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); CCLOG("'addEventListenerTextField' function of UITextField has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0; return 0;
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
tolua_lerror: tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err);
return 0; return 0;
#endif #endif
} }
@ -332,11 +332,11 @@ static void extendUITextField(lua_State* L)
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1)) if (lua_istable(L,-1))
{ {
tolua_function(L, "addEventListener", lua_cocos2dx_UITextField_addEventListener); tolua_function(L, "addEventListenerTextField", lua_cocos2dx_UITextField_addEventListenerTextField);
} }
} }
static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L) static int lua_cocos2dx_UIPageView_addEventListenerPageView(lua_State* L)
{ {
if (nullptr == L) if (nullptr == L)
return 0; return 0;
@ -353,7 +353,7 @@ static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L)
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
if (nullptr == self) { if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListener'\n", NULL); tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIPageView_addEventListenerPageView'\n", NULL);
return 0; return 0;
} }
#endif #endif
@ -378,18 +378,18 @@ static int lua_cocos2dx_UIPageView_addEventListener(lua_State* L)
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
self->setUserObject(listener); self->setUserObject(listener);
self->addEventListener(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
return 0; return 0;
} }
CCLOG("'addEventListener' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); CCLOG("'addEventListenerPageView' function of UIPageView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
return 0; return 0;
#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
tolua_lerror: tolua_lerror:
tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err);
return 0; return 0;
#endif #endif
} }
@ -400,79 +400,77 @@ static void extendUIPageView(lua_State* L)
lua_rawget(L, LUA_REGISTRYINDEX); lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1)) if (lua_istable(L,-1))
{ {
tolua_function(L, "addEventListener", lua_cocos2dx_UIPageView_addEventListener); tolua_function(L, "addEventListenerPageView", lua_cocos2dx_UIPageView_addEventListenerPageView);
} }
} }
//static int lua_cocos2dx_UIListView_addEventListener(lua_State* L) static int lua_cocos2dx_UIListView_addEventListenerListView(lua_State* L)
//{ {
// if (nullptr == L) if (nullptr == L)
// return 0; return 0;
//
// int argc = 0; int argc = 0;
// UIListView* self = nullptr; UIListView* self = nullptr;
//
//#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
// tolua_Error tolua_err; tolua_Error tolua_err;
// if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror; if (!tolua_isusertype(L,1,"UIListView",0,&tolua_err)) goto tolua_lerror;
//#endif #endif
//
// self = static_cast<UIListView*>(tolua_tousertype(L,1,0)); self = static_cast<UIListView*>(tolua_tousertype(L,1,0));
//
//#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
// if (nullptr == self) { if (nullptr == self) {
// tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListener'\n", NULL); tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_UIListView_addEventListenerListView'\n", NULL);
// return 0; return 0;
// } }
//#endif #endif
// argc = lua_gettop(L) - 1; argc = lua_gettop(L) - 1;
// if (2 == argc) if (1 == argc)
// { {
//#if COCOS2D_DEBUG >= 1 #if COCOS2D_DEBUG >= 1
// if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
// !tolua_isusertype(L, 3, "Object", 0, &tolua_err) ) {
// { goto tolua_lerror;
// goto tolua_lerror; }
// } #endif
//#endif LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create();
// LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); if (nullptr == listern)
// if (nullptr == listern) {
// { tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL);
// tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); return 0;
// return 0; }
// }
// LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
// LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
// Object* obj = static_cast<Object*>(tolua_tousertype(L, 3, nullptr)); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
//
// listern->setObjToLua(obj); self->setUserObject(listern);
// ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER); self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
//
// self->addEventListener(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); return 0;
// }
// return 0;
// } CCLOG("'addEventListenerListView' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 1);
//
// CCLOG("'addEventListener' function of UIListView has wrong number of arguments: %d, was expecting %d\n", argc, 2); return 0;
//
// return 0; #if COCOS2D_DEBUG >= 1
// tolua_lerror:
//#if COCOS2D_DEBUG >= 1 tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err);
//tolua_lerror: return 0;
// tolua_error(L,"#ferror in function 'addEventListener'.",&tolua_err); #endif
// return 0; }
//#endif
//} static void extendUIListView(lua_State* L)
// {
//static void extendUIListView(lua_State* L) lua_pushstring(L, "UIListView");
//{ lua_rawget(L, LUA_REGISTRYINDEX);
// lua_pushstring(L, "UIListView"); if (lua_istable(L,-1))
// lua_rawget(L, LUA_REGISTRYINDEX); {
// if (lua_istable(L,-1)) tolua_function(L, "addEventListenerListView", lua_cocos2dx_UIListView_addEventListenerListView);
// { }
// tolua_function(L, "addEventListener", lua_cocos2dx_UIListView_addEventListener); }
// }
//}
static int lua_cocos2dx_UILayoutParameter_setMargin(lua_State* L) static int lua_cocos2dx_UILayoutParameter_setMargin(lua_State* L)
{ {
@ -907,7 +905,7 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L)
extendUISlider(L); extendUISlider(L);
extendUITextField(L); extendUITextField(L);
extendUIPageView(L); extendUIPageView(L);
// extendUIListView(L); extendUIListView(L);
extendLayoutParameter(L); extendLayoutParameter(L);
extendArmatureAnimation(L); extendArmatureAnimation(L);
extendArmatureDataManager(L); extendArmatureDataManager(L);

View File

@ -59,6 +59,14 @@ bool AppDelegate::applicationDidFinishLaunching()
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths(); std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.insert(searchPaths.begin(), "Images"); searchPaths.insert(searchPaths.begin(), "Images");
searchPaths.insert(searchPaths.begin(), "cocosbuilderRes"); searchPaths.insert(searchPaths.begin(), "cocosbuilderRes");
if (screenSize.height > 320)
{
searchPaths.insert(searchPaths.begin(), "hd/scenetest");
}
else
{
searchPaths.insert(searchPaths.begin(), "scenetest");
}
#if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY
searchPaths.push_back("TestCppResources"); searchPaths.push_back("TestCppResources");

View File

@ -1 +1 @@
f6747c1223734554b4f7eeff72714b4457758e00 63707dd119d9dad00da66996544c1892162dab08

View File

@ -32,10 +32,8 @@ function SceneEditorTestLayer:createGameScene()
self._curNode = node self._curNode = node
local function menuCloseCallback( sender ) local function menuCloseCallback( sender )
local backMusic = tolua.cast(self._curNode:getComponent("CCBackgroundAudio"),"ComAudio") ccs.SceneReader:getInstance():destroySceneReader()
backMusic:stopBackgroundMusic(); ccs.ActionManagerEx:destroyActionManager()
ccs.SceneReader:getInstance():purgeSceneReader();
ccs.ActionManagerEx:getInstance():purgeActionManager();
local scene = CocoStudioTestMain() local scene = CocoStudioTestMain()
if scene ~= nil then if scene ~= nil then
cc.Director:getInstance():replaceScene(scene) cc.Director:getInstance():replaceScene(scene)

View File

@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/co
# what classes to produce code for. You can use regular expressions here. When testing the regular # 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*$". # expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter CCSGUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWidget UILayout UIRootWidget UIButton UICheckBox UIImageView UILabel UICCLabelAtlas UILabelAtlas UILoadingBar UIScrollView UISlider UICCTextField UITextField UIListView UILabelBMFont UIPageView UIHelper UILayer UILayoutParameter GUIReader UILinearLayoutParameter UIRelativeLayoutParameter SceneReader ActionManagerEx ComAudio
# what should we skip? in the format ClassName::[function function] # 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 # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@ -45,11 +45,11 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*
UILayer::[getInputManager], UILayer::[getInputManager],
UILayoutParameter::[(s|g)etMargin], UILayoutParameter::[(s|g)etMargin],
UIHelper::[init], UIHelper::[init],
CCSGUIReader::[setPropsForImageButtonFromJsonDictionary] GUIReader::[setPropsForImageButtonFromJsonDictionary]
rename_functions = UIHelper::[instance=getInstance], rename_functions = UIHelper::[instance=getInstance],
ArmatureDataManager::[sharedArmatureDataManager=getInstance], ArmatureDataManager::[sharedArmatureDataManager=getInstance],
CCSGUIReader::[shareReader=getInstance], GUIReader::[shareReader=getInstance],
ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager], ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager],
SceneReader::[purgeSceneReader=destroySceneReader] SceneReader::[purgeSceneReader=destroySceneReader]