static int tolua_PlayerLuaCore_ProjectConfig_setFrameSize00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (
        !tolua_isusertype(tolua_S,1,"ProjectConfig",0,&tolua_err) ||
        (tolua_isvaluenil(tolua_S,2,&tolua_err))
        )
        goto tolua_lerror;
    else
#endif
    {
        ProjectConfig* self = (ProjectConfig*)  tolua_tousertype(tolua_S,1,0);
        int argc = 0;
        bool ok  = true;
        argc = lua_gettop(tolua_S)-1;
        
        if (1 == argc)
        {
            cocos2d::Size size;
            ok &= luaval_to_size(tolua_S, 2, &size);
            if (!ok)
                return 0;
            
            self->setFrameSize(size);
            return 0;
        }
        else if(2 == argc)
        {
            double width;
            ok &= luaval_to_number(tolua_S, 2,&width);
            
            if (!ok)
                return 0;
            
            double height;
            ok &= luaval_to_number(tolua_S, 3,&height);
            
            if (!ok)
                return 0;
            
            self->setFrameSize(cocos2d::Size(width, height));
            return 0;
        }
    }
    return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'setFrameSize'.",&tolua_err);
    return 0;
#endif
}
void PlayerWin::openNewPlayerWithProjectConfig(const ProjectConfig &config)
{
    static long taskid = 100;
    stringstream buf;
    buf << taskid++;

    string commandLine;
    commandLine.append(getApplicationExePath());
    if (!config.isWelcome())
    {
        commandLine.append(" ");
        commandLine.append(config.makeCommandLine());
    }
    
    CCLOG("PlayerWin::openNewPlayerWithProjectConfig(): %s", commandLine.c_str());

    // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx
    SECURITY_ATTRIBUTES sa = {0};
    sa.nLength = sizeof(sa);

    PROCESS_INFORMATION pi = {0};
    STARTUPINFO si = {0};
    si.cb = sizeof(STARTUPINFO);

#define MAX_COMMAND 1024 // lenth of commandLine is always beyond MAX_PATH

    WCHAR command[MAX_COMMAND];
    memset(command, 0, sizeof(command));
	MultiByteToWideChar(CP_ACP, 0, commandLine.c_str(), -1, command, MAX_COMMAND);

    BOOL success = CreateProcess(NULL,
                                 command,   // command line 
                                 NULL,      // process security attributes 
                                 NULL,      // primary thread security attributes 
                                 FALSE,     // handles are inherited 
                                 0,         // creation flags 
                                 NULL,      // use parent's environment 
                                 NULL,      // use parent's current directory 
                                 &si,       // STARTUPINFO pointer 
                                 &pi);      // receives PROCESS_INFORMATION 

    if (!success)
    {
        CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", commandLine.c_str());
    }
}
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();
}
Beispiel #4
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());
}
Beispiel #5
0
        SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(quickCocos2dxRoot.toLocal8Bit().constData());
    }

    // recent files
    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());