add link resource support

This commit is contained in:
chuanweizhang2013 2014-08-29 15:05:55 +08:00
parent 37b71ec0cc
commit 0d8c9eeb19
6 changed files with 57 additions and 24 deletions

View File

@ -1,4 +1,4 @@
{
"templateVersion":"1.3",
"runtimeVersion":"1.3"
"templateVersion":"1.4",
"runtimeVersion":"1.4"
}

View File

@ -6,7 +6,8 @@
"width": 960,
"height": 640,
"entry": "src/main.lua",
"consolePort": 6010
"consolePort": 6010,
"uploadPort": 6020
},
"simulator_screen_size": [
{

View File

@ -26,6 +26,7 @@ void ConfigParser::readConfig()
_isInit = true;
_isWindowTop = false;
_consolePort = 6010;
_uploadPort = 6020;
string filecfg = "config.json";
string fileContent;
@ -73,9 +74,14 @@ void ConfigParser::readConfig()
}
if (objectInitView.HasMember("consolePort")){
_consolePort = objectInitView["consolePort"].GetUint();
if(0 == _consolePort)
if(_consolePort<=0)
_consolePort = 6010;
}
if (objectInitView.HasMember("uploadPort")){
_uploadPort = objectInitView["uploadPort"].GetUint();
if(_uploadPort<=0)
_uploadPort = 6020;
}
if (objectInitView.HasMember("isWindowTop") && objectInitView["isWindowTop"].IsBool()){
_isWindowTop= objectInitView["isWindowTop"].GetBool();
}
@ -141,6 +147,10 @@ int ConfigParser::getConsolePort()
{
return _consolePort;
}
int ConfigParser::getUploadPort()
{
return _uploadPort;
}
int ConfigParser::getScreenSizeCount(void)
{
return (int)_screenSizeArray.size();

View File

@ -37,6 +37,7 @@ public:
rapidjson::Document& getConfigJsonRoot();
const SimulatorScreenSize getScreenSize(int index);
int getConsolePort();
int getUploadPort();
bool isLanscape();
bool isWindowTop();
bool isInit();
@ -52,6 +53,7 @@ private:
bool _isInit;
bool _isWindowTop;
int _consolePort;
int _uploadPort;
rapidjson::Document _docRootjson;
};

View File

@ -50,7 +50,7 @@ using namespace std;
using namespace cocos2d;
std::string g_resourcePath;
static std::string g_projectPath;
//1M size
#define MAXPROTOLENGTH 1048576
@ -64,7 +64,7 @@ std::string g_resourcePath;
extern string getIPAddress();
const char* getRuntimeVersion()
{
return "1.3";
return "1.4";
}
static string& replaceAll(string& str,const string& old_value,const string& new_value)
@ -801,11 +801,13 @@ public:
_console->listenOnTCP(6010);
#endif
_fileserver = nullptr;
#if(CC_PLATFORM_MAC != CC_TARGET_PLATFORM && CC_PLATFORM_WIN32 != CC_TARGET_PLATFORM)
_fileserver= FileServer::getShareInstance();
#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM)
_fileserver->listenOnTCP(ConfigParser::getInstance()->getUploadPort());
#else
_fileserver->listenOnTCP(6020);
_fileserver->readResFileFinfo();
#endif
_fileserver->readResFileFinfo();
}
~ConsoleCustomCommand()
@ -998,13 +1000,17 @@ int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S)
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if(!ok)
return 0;
std::string argtmp = arg0;
if (!FileUtils::getInstance()->isAbsolutePath(arg0))
arg0 = g_resourcePath+arg0;
std::string originPath = arg0;
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
arg0 = g_resourcePath+originPath;
cobj->addSearchPath(arg0);
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
cobj->addSearchPath(g_projectPath + originPath);
#endif
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
if (!FileUtils::getInstance()->isAbsolutePath(argtmp))
cobj->addSearchPath(argtmp);
if (!FileUtils::getInstance()->isAbsolutePath(originPath))
cobj->addSearchPath(originPath);
#endif
return 0;
}
@ -1052,17 +1058,22 @@ int lua_cocos2dx_runtime_setSearchPaths(lua_State* tolua_S)
ok &= luaval_to_std_vector_string(tolua_S, 2,&vecPaths);
if(!ok)
return 0;
std::vector<std::string> argtmp;
std::vector<std::string> originPath; // for IOS platform.
std::vector<std::string> projPath; // for Desktop platform.
for (int i = 0; i < vecPaths.size(); i++)
{
if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i]))
{
argtmp.push_back(vecPaths[i]);
originPath.push_back(vecPaths[i]); // for IOS platform.
projPath.push_back(g_projectPath+vecPaths[i]); //for Desktop platform.
vecPaths[i] = g_resourcePath + vecPaths[i];
}
}
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
vecPaths.insert(vecPaths.end(),projPath.begin(),projPath.end());
#endif
#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
vecPaths.insert(vecPaths.end(),argtmp.begin(),argtmp.end());
vecPaths.insert(vecPaths.end(),originPath.begin(),originPath.end());
#endif
cobj->setSearchPaths(vecPaths);
return 0;
@ -1109,18 +1120,23 @@ bool initRuntime()
vector<string> searchPathArray;
searchPathArray=FileUtils::getInstance()->getSearchPaths();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
if (g_resourcePath.empty())
if (g_projectPath.empty())
{
extern std::string getCurAppPath();
string resourcePath = getCurAppPath();
string appPath = getCurAppPath();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
resourcePath.append("/../../");
appPath.append("/../../");
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
resourcePath.append("/../../../");
appPath.append("/../../../");
#endif
resourcePath =replaceAll(resourcePath,"\\","/");
g_resourcePath = resourcePath;
appPath =replaceAll(appPath,"\\","/");
g_projectPath = appPath;
}
searchPathArray.insert(searchPathArray.begin(),g_projectPath);
g_resourcePath = FileUtils::getInstance()->getWritablePath();
g_resourcePath += "debugruntime/";
g_resourcePath += ConfigParser::getInstance()->getInitViewName();
g_resourcePath +="/";
#else
g_resourcePath = FileUtils::getInstance()->getWritablePath();
g_resourcePath += "debugruntime/";

View File

@ -1,10 +1,14 @@
/* debugger.c */
#if __cplusplus
extern "C"{
#endif
#include "lua.h"
#include "lauxlib.h"
#include "lua_debugger.h"
#if __cplusplus
}
#endif
/* ldt_debugger */
static const char lua_m_ldt_debugger[] = {
0x1b,0x4c,0x4a,0x01,0x02,0x87,0x01,0x00,0x01,0x0c,0x00,0x06,0x02,0x18,0x32,0x01,