Merge pull request #8976 from hongliang-goudou/runtime_addSearchPath_argc

overrided addSearchPath() by Runtime.cpp should support second argument
This commit is contained in:
minggo 2014-11-01 11:35:05 +08:00
commit 5ee8f0a134
1 changed files with 10 additions and 4 deletions

View File

@ -1071,24 +1071,30 @@ int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S)
#endif #endif
argc = lua_gettop(tolua_S)-1; argc = lua_gettop(tolua_S)-1;
if (argc == 1) if (argc == 1 || argc == 2)
{ {
std::string arg0; std::string arg0;
bool arg1 = false;
ok &= luaval_to_std_string(tolua_S, 2,&arg0); ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if (argc == 2) {
ok &= luaval_to_boolean(tolua_S, 3, &arg1);
}
if(!ok) if(!ok)
return 0; return 0;
std::string originPath = arg0; std::string originPath = arg0;
if (!FileUtils::getInstance()->isAbsolutePath(originPath)) if (!FileUtils::getInstance()->isAbsolutePath(originPath))
arg0 = g_resourcePath + originPath; arg0 = g_resourcePath + originPath;
cobj->addSearchPath(arg0); cobj->addSearchPath(arg0, arg1);
if (!FileUtils::getInstance()->isAbsolutePath(originPath)) if (!FileUtils::getInstance()->isAbsolutePath(originPath))
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
cobj->addSearchPath(g_projectPath + originPath); cobj->addSearchPath(g_projectPath + originPath, arg1);
#endif #endif
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
cobj->addSearchPath(originPath); cobj->addSearchPath(originPath, arg1);
#endif #endif
return 0; return 0;
} }