mirror of https://github.com/axmolengine/axmol.git
Add first search path to command param.
This commit is contained in:
parent
32303b5904
commit
709d79ad14
|
@ -50,7 +50,6 @@ ProjectConfig::ProjectConfig()
|
|||
, _consolePort(kProjectConfigConsolePort)
|
||||
, _fileUploadPort(kProjectConfigUploadPort)
|
||||
, _bindAddress("")
|
||||
, _useLocalScript(false)
|
||||
{
|
||||
normalize();
|
||||
}
|
||||
|
@ -273,17 +272,6 @@ void ProjectConfig::setDebuggerType(int debuggerType)
|
|||
_debuggerType = debuggerType;
|
||||
}
|
||||
|
||||
|
||||
bool ProjectConfig::isUseLocalScript() const
|
||||
{
|
||||
return _useLocalScript;
|
||||
}
|
||||
|
||||
void ProjectConfig::setUseLocalScript(bool useLocalScript)
|
||||
{
|
||||
_useLocalScript = useLocalScript;
|
||||
}
|
||||
|
||||
void ProjectConfig::parseCommandLine(const vector<string> &args)
|
||||
{
|
||||
auto it = args.begin();
|
||||
|
@ -421,24 +409,11 @@ void ProjectConfig::parseCommandLine(const vector<string> &args)
|
|||
vector<string> pathes = split((*it), ';');
|
||||
setSearchPath(pathes);
|
||||
}
|
||||
else if (arg.compare("-use-local-script") == 0)
|
||||
else if (arg.compare("-first-search-path") == 0)
|
||||
{
|
||||
++it;
|
||||
if (it == args.end()) break;
|
||||
if ((*it).compare("enable") == 0)
|
||||
{
|
||||
setUseLocalScript(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setUseLocalScript(false);
|
||||
}
|
||||
}
|
||||
else if (arg.compare("-language-data-path") == 0)
|
||||
{
|
||||
++it;
|
||||
if (it == args.end()) break;
|
||||
setLanguageDataPath(*it);
|
||||
vector<string> pathes = split((*it), ';');
|
||||
setFirstSearchPath(pathes);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
@ -602,17 +577,20 @@ vector<string> ProjectConfig::makeCommandLineVector(unsigned int mask /* = kProj
|
|||
}
|
||||
}
|
||||
|
||||
if (mask & kProjectConfigUseLocalScript)
|
||||
if (mask & kProjectConfigFirstSearchPath)
|
||||
{
|
||||
if (isUseLocalScript())
|
||||
if (_searchPath.size() > 0)
|
||||
{
|
||||
ret.push_back("-use-local-script");
|
||||
ret.push_back("enable");
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.push_back("-use-local-script");
|
||||
ret.push_back("disable");
|
||||
stringstream pathbuff;
|
||||
for (auto &path : _searchPath)
|
||||
{
|
||||
pathbuff << dealWithSpaceWithPath(path) << ";";
|
||||
}
|
||||
string pathArgs = pathbuff.str();
|
||||
pathArgs[pathArgs.length() - 1] = '\0';
|
||||
|
||||
ret.push_back("-first-search-path");
|
||||
ret.push_back(pathArgs);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -658,26 +636,17 @@ const vector<string> &ProjectConfig::getSearchPath() const
|
|||
return _searchPath;
|
||||
}
|
||||
|
||||
void ProjectConfig::setLanguageDataPath(const std::string &filePath)
|
||||
void ProjectConfig::setFirstSearchPath(const vector<string> &args)
|
||||
{
|
||||
bool isBinary = true;
|
||||
string jsonExtension = ".json";
|
||||
int exLength = jsonExtension.length();
|
||||
if (filePath.length() >= exLength &&
|
||||
(0 == filePath.compare(filePath.length() - exLength, exLength, jsonExtension)))
|
||||
{
|
||||
isBinary = false;
|
||||
}
|
||||
|
||||
cocostudio::ILocalizationManager* lm;
|
||||
if (isBinary)
|
||||
lm = cocostudio::BinLocalizationManager::getInstance();
|
||||
else
|
||||
lm = cocostudio::JsonLocalizationManager::getInstance();
|
||||
lm->initLanguageData(filePath);
|
||||
cocostudio::LocalizationHelper::setCurrentManager(lm, isBinary);
|
||||
_firstSearchPath = args;
|
||||
}
|
||||
|
||||
const vector<string> &ProjectConfig::getFirstSearchPath() const
|
||||
{
|
||||
return _firstSearchPath;
|
||||
}
|
||||
|
||||
|
||||
bool ProjectConfig::isAppMenu() const
|
||||
{
|
||||
return _isAppMenu;
|
||||
|
|
|
@ -28,11 +28,11 @@ using namespace std;
|
|||
#define kProjectConfigDebugger 1024 // -debugger-ldt, -debugger-codeide, -disable-debugger
|
||||
#define kProjectConfigListen 2048 //
|
||||
#define kProjectConfigSearchPath 4096 //
|
||||
#define kProjectConfigUseLocalScript 8192 // -use-local-script
|
||||
#define kProjectConfigFirstSearchPath 8192 // -first-search-path
|
||||
|
||||
#define kProjectConfigOpenRecent (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile)
|
||||
|
||||
#define kProjectConfigAll (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile | kProjectConfigWindowOffset | kProjectConfigDebugger | kProjectConfigListen | kProjectConfigSearchPath)
|
||||
#define kProjectConfigAll (kProjectConfigProjectDir | kProjectConfigScriptFile | kProjectConfigPackagePath | kProjectConfigWritablePath | kProjectConfigFrameSize | kProjectConfigFrameScale | kProjectConfigShowConsole | kProjectConfigLoadPrecompiledFramework | kProjectConfigWriteDebugLogToFile | kProjectConfigWindowOffset | kProjectConfigDebugger | kProjectConfigListen | kProjectConfigSearchPath | kProjectConfigFirstSearchPath)
|
||||
|
||||
|
||||
#define kProjectConfigConsolePort 6010
|
||||
|
@ -105,10 +105,8 @@ public:
|
|||
const std::string &getBindAddress() const;
|
||||
void setSearchPath(const vector<string> &args);
|
||||
const vector<string> &getSearchPath() const;
|
||||
void setLanguageDataPath(const std::string &filePath);
|
||||
|
||||
bool isUseLocalScript() const;
|
||||
void setUseLocalScript(bool useLocalScript);
|
||||
void setFirstSearchPath(const vector<string> &args);
|
||||
const vector<string> &getFirstSearchPath() const;
|
||||
|
||||
bool isAppMenu() const;
|
||||
bool isResizeWindow() const;
|
||||
|
@ -138,8 +136,7 @@ private:
|
|||
int _fileUploadPort;
|
||||
string _bindAddress;
|
||||
vector<string> _searchPath;
|
||||
bool _useLocalScript;
|
||||
string _languageDataPath;
|
||||
vector<string> _firstSearchPath;
|
||||
|
||||
void normalize();
|
||||
string replaceProjectDirToMacro(const string &path) const;
|
||||
|
|
|
@ -223,12 +223,13 @@ void RuntimeEngine::setProjectPath(const std::string &workPath)
|
|||
g_projectPath = workPath;
|
||||
}
|
||||
|
||||
if (!_project.isUseLocalScript())
|
||||
// add project's root directory to search path
|
||||
searchPathArray.insert(searchPathArray.begin(), g_projectPath);
|
||||
|
||||
if (!_project.getFirstSearchPath().empty())
|
||||
{
|
||||
// add project's root directory to search path
|
||||
searchPathArray.insert(searchPathArray.begin(), g_projectPath);
|
||||
searchPathArray.insert(searchPathArray.begin(), _project.getFirstSearchPath().begin(), _project.getFirstSearchPath().end());
|
||||
}
|
||||
|
||||
|
||||
// add writable path to search path
|
||||
searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath());
|
||||
|
|
Loading…
Reference in New Issue