mirror of https://github.com/axmolengine/axmol.git
Fix when start simulator in CocoStudio to run a scene, can not read the correct config.json on MacOSX
This commit is contained in:
parent
c08b4a0f9d
commit
3aeb5e0389
|
@ -206,6 +206,7 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files)
|
||||||
|
|
||||||
// set project directory as search root path
|
// set project directory as search root path
|
||||||
string solutionDir = tmpConfig.getProjectDir();
|
string solutionDir = tmpConfig.getProjectDir();
|
||||||
|
string spath = solutionDir;
|
||||||
if (!solutionDir.empty())
|
if (!solutionDir.empty())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < solutionDir.size(); ++i)
|
for (int i = 0; i < solutionDir.size(); ++i)
|
||||||
|
@ -215,6 +216,24 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files)
|
||||||
solutionDir[i] = '/';
|
solutionDir[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spath = solutionDir;
|
||||||
|
if (spath[spath.length() - 1] == '/') {
|
||||||
|
spath = spath.substr(0, spath.length() - 1);
|
||||||
|
}
|
||||||
|
string strExtention = FileUtils::getInstance()->getFileExtension(spath);
|
||||||
|
int pos = -1;
|
||||||
|
if(strExtention.compare(".csd") == 0)
|
||||||
|
{
|
||||||
|
pos = spath.rfind('/');
|
||||||
|
if(pos > 0)
|
||||||
|
spath = spath.substr(0, pos);
|
||||||
|
}
|
||||||
|
pos = spath.rfind('/');
|
||||||
|
if(pos > 0)
|
||||||
|
spath = spath.substr(0, pos+1);
|
||||||
|
FileUtils::getInstance()->addSearchPath(spath);
|
||||||
|
|
||||||
FileUtils::getInstance()->setDefaultResourceRootPath(solutionDir);
|
FileUtils::getInstance()->setDefaultResourceRootPath(solutionDir);
|
||||||
FileUtils::getInstance()->addSearchPath(solutionDir);
|
FileUtils::getInstance()->addSearchPath(solutionDir);
|
||||||
FileUtils::getInstance()->addSearchPath(tmpConfig.getProjectDir());
|
FileUtils::getInstance()->addSearchPath(tmpConfig.getProjectDir());
|
||||||
|
@ -226,7 +245,9 @@ static void glfwDropFunc(GLFWwindow *window, int count, const char **files)
|
||||||
|
|
||||||
// parse config.json
|
// parse config.json
|
||||||
auto parser = ConfigParser::getInstance();
|
auto parser = ConfigParser::getInstance();
|
||||||
auto configPath = solutionDir.append(CONFIG_FILE);
|
auto configPath = spath.append(CONFIG_FILE);
|
||||||
|
if(!FileUtils::getInstance()->isFileExist(configPath))
|
||||||
|
configPath = solutionDir.append(CONFIG_FILE);
|
||||||
parser->readConfig(configPath);
|
parser->readConfig(configPath);
|
||||||
|
|
||||||
// set information
|
// set information
|
||||||
|
|
Loading…
Reference in New Issue