Esempio n. 1
0
void SimulatorWin::parseCocosProjectConfig(ProjectConfig &config)
{
    // get project directory
    ProjectConfig tmpConfig;
    // load project config from command line args
    vector<string> args;
    for (int i = 0; i < __argc; ++i)
    {
        wstring ws(__wargv[i]);
        string s;
        s.assign(ws.begin(), ws.end());
        args.push_back(s);
    }

    if (args.size() >= 2)
    {
        if (args.size() && args.at(1).at(0) == '/')
        {
            // FIXME:
            // for Code IDE before RC2
            tmpConfig.setProjectDir(args.at(1));
        }

        tmpConfig.parseCommandLine(args);
    }

    // set project directory as search root path
    FileUtils::getInstance()->setDefaultResourceRootPath(tmpConfig.getProjectDir().c_str());

    // parse config.json
    auto parser = ConfigParser::getInstance();
    auto configPath = tmpConfig.getProjectDir().append(CONFIG_FILE);
    parser->readConfig(configPath);

    // set information
    config.setConsolePort(parser->getConsolePort());
    config.setFileUploadPort(parser->getUploadPort());
    config.setFrameSize(parser->getInitViewSize());
    if (parser->isLanscape())
    {
        config.changeFrameOrientationToLandscape();
    }
    else
    {
        config.changeFrameOrientationToPortait();
    }
    config.setScriptFile(parser->getEntryFile());
}
void ProjectConfigUI::setDataForUI(ProjectConfig &projectConfig)
{
    m_projectConfig = projectConfig;

    clearUIDataAndSignal();
    ui->projectDir->setText(projectConfig.getProjectDir().data());
    ui->scriptFileName->setText(projectConfig.getScriptFile().data());
    ui->writablePath->setText(projectConfig.getWritablePath().data());

    int i = 0;
    int currentIndex = -1;
    for (; i < SimulatorConfig::sharedDefaults()->getScreenSizeCount(); i++)
    {
        const SimulatorScreenSize &screenSize = SimulatorConfig::sharedDefaults()->getScreenSize(i);
        ui->screenSizeComboBox->addItem(screenSize.title.data());

        CCSize size = projectConfig.getFrameSize();
        if ((screenSize.width == size.width && screenSize.height == size.height)
                ||(screenSize.width == size.height && screenSize.height == size.width))
        {
            currentIndex = i;
        }
    }

    ui->screenSizeComboBox->addItem(tr("Customized Size"));
    ui->screenSizeComboBox->setCurrentIndex(currentIndex == -1 ? i : currentIndex);

    if (projectConfig.isLandscapeFrame())
        ui->landscapeCheckBox->setChecked(true);
    else
        ui->protratCheckBox->setChecked(true);

    ui->screenWidth->setText(QString::number(projectConfig.getFrameSize().width));
    ui->screenHeight->setText(QString::number(projectConfig.getFrameSize().height));

    ui->showDebugConsole->setChecked(projectConfig.isShowConsole());
    ui->loadPreFramework->setChecked(projectConfig.isLoadPrecompiledFramework());
    ui->logToFile->setChecked(projectConfig.isWriteDebugLogToFile());

    reconnectUISignal();
}
Esempio n. 3
0
    CCLuaValueArray recentArray;
    QSettings settings;
    QVariantList recents = settings.value(kOpenRecentFiles).toList();
    Q_FOREACH(QVariant recentItem, recents)
    {
        QVariantMap item = recentItem.toMap();
        QString title = item.value(kRecentItemTitle).toString();
        recentArray.push_back(CCLuaValue::stringValue(title.toUtf8().constData()));
    }
    app.setOpenRecents(recentArray);

    ProjectConfig projectConfig;
    projectConfig.parseCommandLine(args);
    projectConfig.dump();

    const string projectDir = projectConfig.getProjectDir();
    // show the welcome UI as default
    if (projectDir.length() <= 0)
    {
        projectConfig.resetToWelcome();
    }
    else
    {
        CCFileUtils::sharedFileUtils()->setSearchRootPath(projectDir.c_str());
    }

    CCFileUtils::sharedFileUtils()->setWritablePath(projectConfig.getWritableRealPath().data());
    CCFileUtils::sharedFileUtils()->setCachePath(projectConfig.getWritableRealPath().data());

    // load lua bridge module
    player->loadLuaBridgeModule();