Exemplo n.º 1
0
void ProjectConfig::resetToWelcome(void)
{
	m_isWelcome = true;

    //string path = SimulatorConfig::sharedDefaults()->getQuickCocos2dxRootPath();
    //path.append("player/welcome");
	//2014-04-03 zrong add path by enviroment.
#if defined(_WINDOWS)
	string path = "d:/works/yhq/projects/lulala";
	//string path = "d:/cocos2dx/quick/samples/filters";
	//string path = "d:/works/yhq/projects/test_player";
#else
	string path = "/Users/Team1201/works/yhq/projects/lulala";
   	//string path = "/Users/Team1201/cocos2dx/quick/samples/filters";
#endif
	//2014-04-03 zrong add done.

    SimulatorConfig::makeNormalizePath(&path);
    setProjectDir(path);
    setWritablePath(path);
    setScriptFile("$PROJDIR/scripts/main.lua");
    setFrameSize(CCSize(960, 640));
    setFrameScale(1.0f);
    setLoadPrecompiledFramework(false);
    setPackagePath("");
    setShowConsole(false);
    setWindowOffset(CCPointZero);
    setWriteDebugLogToFile(false);
}
void ProjectConfig::resetToWelcome(void)
{
	m_isWelcome = true;
    string path = SimulatorConfig::sharedDefaults()->getQuickCocos2dxRootPath();
    path.append("player/welcome");
    SimulatorConfig::makeNormalizePath(&path);
    setProjectDir(path);
    setWritablePath(path);
    setScriptFile("$PROJDIR/scripts/main.lua");
    setFrameSize(CCSize(960, 640));
    setFrameScale(1.0f);
    setLoadPrecompiledFramework(true);
    setPackagePath("");
    setShowConsole(true);
    setWindowOffset(CCPointZero);
    setWriteDebugLogToFile(false);
}
void ProjectConfig::parseCommandLine(vector<string>& args)
{
    vector<string>::iterator it = args.begin();
    while (it != args.end())
    {
        const string& arg = *it;

        if (arg.compare("-quick") == 0)
        {
            ++it;
            if (it == args.end()) break;
            SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath((*it).c_str());
        }
        else if (arg.compare("-workdir") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setProjectDir(*it);
            if (m_writablePath.length() == 0) setWritablePath(*it);
        }
        else if (arg.compare("-writable") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setWritablePath(*it);
        }
        else if (arg.compare("-file") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setScriptFile(*it);
        }
        else if (arg.compare("-package.path") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setPackagePath(*it);
        }
        else if (arg.compare("-landscape") == 0)
        {
            setFrameSize(CCSize(DEFAULT_HEIGHT, DEFAULT_WIDTH));
        }
        else if (arg.compare("-portrait") == 0)
        {
            setFrameSize(CCSize(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        }
        else if (arg.compare("-size") == 0)
        {
            ++it;
            if (it == args.end()) break;
            const string& sizeStr(*it);
            size_t pos = sizeStr.find('x');
            int width = 0;
            int height = 0;
            if (pos != sizeStr.npos && pos > 0)
            {
                string widthStr, heightStr;
                widthStr.assign(sizeStr, 0, pos);
                heightStr.assign(sizeStr, pos + 1, sizeStr.length() - pos);
                width = atoi(widthStr.c_str());
                height = atoi(heightStr.c_str());
                setFrameSize(CCSize(width, height));
            }
        }
        else if (arg.compare("-scale") == 0)
        {
            ++it;
            if (it == args.end()) break;
            float scale = atof((*it).c_str());
            setFrameScale(scale);
        }
        else if (arg.compare("-write-debug-log") == 0)
        {
            setWriteDebugLogToFile(true);
        }
        else if (arg.compare("-disable-write-debug-log") == 0)
        {
            setWriteDebugLogToFile(false);
        }
        else if (arg.compare("-console") == 0)
        {
            setShowConsole(true);
        }
        else if (arg.compare("-disable-console") == 0)
        {
            setShowConsole(false);
        }
        else if (arg.compare("-load-framework") == 0)
        {
            setLoadPrecompiledFramework(true);
        }
        else if (arg.compare("-disable-load-framework") == 0)
        {
            setLoadPrecompiledFramework(false);
        }
        else if (arg.compare("-offset") == 0)
        {
            ++it;
            if (it == args.end()) break;
            CCPoint pos = CCPointFromString((*it).c_str());
            setWindowOffset(pos);
        }
        else if (arg.compare("-debugger-ldt") == 0)
        {
            setDebuggerType(kCCLuaDebuggerLDT);
        }
        else if (arg.compare("-disable-debugger") == 0)
        {
            setDebuggerType(kCCLuaDebuggerNone);
        }
        else if (arg.compare("-relaunch-off") == 0)
        {
            setExitWhenRelaunch(true);
        }
        else if (arg.compare("-relaunch-on") == 0)
        {
            setExitWhenRelaunch(false);
        }

        ++it;
    }
}
Exemplo n.º 4
0
void ProjectConfig::parseCommandLine(const vector<string> &args)
{
    auto it = args.begin();
    while (it != args.end())
    {
        string arg = *it;

        if (arg.compare("-workdir") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setProjectDir(*it);
            if (_writablePath.length() == 0) setWritablePath(*it);
        }
        else if (arg.compare("-writable-path") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setWritablePath(*it);
        }
        else if (arg.compare("-entry") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setScriptFile(*it);
        }
        else if (arg.compare("-landscape") == 0)
        {
            setFrameSize(cocos2d::Size(DEFAULT_HEIGHT, DEFAULT_WIDTH));
        }
        else if (arg.compare("-portrait") == 0)
        {
            setFrameSize(cocos2d::Size(DEFAULT_WIDTH, DEFAULT_HEIGHT));
        }
        else if (arg.compare("-resolution") == 0)
        {
            ++it;
            if (it == args.end()) break;
            const string& sizeStr(*it);
            size_t pos = sizeStr.find('x');
            int width = 0;
            int height = 0;
            if (pos != sizeStr.npos && pos > 0)
            {
                string widthStr, heightStr;
                widthStr.assign(sizeStr, 0, pos);
                heightStr.assign(sizeStr, pos + 1, sizeStr.length() - pos);
                width = atoi(widthStr.c_str());
                height = atoi(heightStr.c_str());
                setFrameSize(cocos2d::Size(width, height));
            }
        }
        else if (arg.compare("-scale") == 0)
        {
            ++it;
            if (it == args.end()) break;
            float scale = atof((*it).c_str());
            setFrameScale(scale);
        }
        else if (arg.compare("-write-debug-log") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setDebugLogFilePath((*it));
            setWriteDebugLogToFile(true);
        }
        else if (arg.compare("-console") == 0)
        {
            ++it;
            if (it == args.end()) break;
            if ((*it).compare("enable") == 0)
            {
                setShowConsole(true);
            }
            else
            {
                setShowConsole(false);
            }
        }
        else if (arg.compare("-position") == 0)
        {
            ++it;
            if (it == args.end()) break;
            const string& posStr(*it);
            size_t pos = posStr.find(',');
            int x = 0;
            int y = 0;
            if (pos != posStr.npos && pos > 0)
            {
                string xStr, yStr;
                xStr.assign(posStr, 0, pos);
                yStr.assign(posStr, pos + 1, posStr.length() - pos);
                x = atoi(xStr.c_str());
                y = atoi(yStr.c_str());
                setWindowOffset(cocos2d::Vec2(x, y));
            }
        }
        else if (arg.compare("-debugger") == 0)
        {
            ++it;
            if (it == args.end()) break;
            if ((*it).compare("codeide") == 0)
            {
                setDebuggerType(kCCRuntimeDebuggerCodeIDE);
            }
            else if ((*it).compare("studio") == 0)
            {
                setDebuggerType(kCCRuntimeDebuggerStudio);
            }
        }
        else if (arg.compare("-app-menu") == 0)
        {
            _isAppMenu = true;
        }
        else if (arg.compare("-resize-window") == 0)
        {
            _isResizeWindow = true;
        }
        else if (arg.compare("-retina-display") == 0)
        {
            _isRetinaDisplay = true;
        }
        else if (arg.compare("-port") == 0)
        {
            CCLOG("TODO:");
        }
        else if (arg.compare("-listen") == 0)
        {
            ++it;
            setBindAddress((*it));
        }
        else if (arg.compare("-search-path") == 0)
        {
            ++it;
            vector<string> pathes = split((*it), ';');
            setSearchPath(pathes);
        }
        else if (arg.compare("-first-search-path") == 0)
        {
            ++it;
            vector<string> pathes = split((*it), ';');
            setFirstSearchPath(pathes);
        }
        else if (arg.compare("-language-data-path") == 0)
        {
            ++it;
            if (it == args.end()) break;
            setLanguageDataPath(*it);
        }
        ++it;
    }
}