void HeightmapDialog::compile()
{
  QString     working_directory = QDir::currentPath();
  QProcess    process(this);
  QStringList args;

  generateInputFile();
  args << "--compile-heightmap" << inputFilename() << outputFilename();
  process.setWorkingDirectory(working_directory);
#ifdef _WIN32
    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("Path", "..\\Panda3D-1.9.0\\bin;" + env.value("Path"));
    process.setProcessEnvironment(env);
    process.start("./game.exe", args);
#else
    process.start("./game", args);
#endif
    if (process.waitForFinished())
    {
      if (process.exitCode() == 0)
        emit heightmapCreated(outputFilename());
      else
        QMessageBox::warning(this, "Error", "The heightmap compiling failed.");
    }
    else
      QMessageBox::warning(this, "Error", "The heightmap compiling failed to start.");

}
示例#2
0
bool Wallet::writeBackupInstructions() {
    QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
    QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
    QFile outputFile(outputFilename);
    bool retval = false;

    if (QFile::exists(outputFilename) || getKeyFilePath() == "")
    {
        return false;
    }
    QFile::copy(inputFilename, outputFilename);

    if (QFile::exists(outputFilename) && outputFile.open(QIODevice::ReadWrite)) {

        QByteArray fileData = outputFile.readAll();
        QString text(fileData);

        text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath());

        outputFile.seek(0); // go to the beginning of the file
        outputFile.write(text.toUtf8()); // write the new text back to the file

        outputFile.close(); // close the file handle.

        retval = true;
        qCDebug(commerce) << "wrote html file successfully";
    } else {
        qCDebug(commerce) << "failed to open output html file" << outputFilename;
    }
    return retval;
}
示例#3
0
int main(int argc, char *argv[])
{
    QApplication  app(argc, argv);

    qDebug( " Syntax: pntdel [-i pnt-sourcefile -o pnt-targetfile -id idNumber] " );

    QString inputFilename("PDIFFBORDERS.PNT");
    int inputIndex = app.arguments().indexOf("-i");
    if (inputIndex > 0 && inputIndex + 1 < argc )
        inputFilename = app.arguments().at( inputIndex + 1 );

    QString outputFilename("NEW.PNT");
    int outputIndex = app.arguments().indexOf("-o");
    if (outputIndex > 0 && outputIndex + 1 < argc )
        outputFilename = app.arguments().at( outputIndex + 1 );

    int delIndex = -1;
    int idIndex = app.arguments().indexOf("-id");
    if (idIndex > 0 && idIndex + 1 < argc )
        delIndex = app.arguments().at( idIndex + 1 ).toInt();


    qDebug() << "input filename:" << inputFilename;
    qDebug() << "output filename:" << outputFilename;
    qDebug() << "remove index:" << delIndex;

    // INPUT
    QFile  file( inputFilename );

    if ( file.open( QIODevice::ReadOnly ) ) {
        QDataStream stream( &file );  // read the data serialized from the file
        stream.setByteOrder( QDataStream::LittleEndian );

        // OUTPUT
        QFile data(outputFilename);

        if (data.open(QFile::WriteOnly | QFile::Truncate)) {
            QDataStream out(&data);
            out.setByteOrder( QDataStream::LittleEndian );

            short  header;
            short  iLat;
            short  iLon;

            bool skip = false;

            while( !stream.atEnd() ){
                stream >> header >> iLat >> iLon;
                if ( header == delIndex ) {
                    skip = true;
                }
                else if ( header > 5 )
                    skip = false;

                if ( !skip )
                    out << header << iLat << iLon;
            }
            data.close();
        }
void HeightmapDialog::generateInputFile() const
{
  DataTree datatree;
  {
    Data    data(&datatree);
    QString heightmapPath = ui->heightmapFile->text();

    data["heightmap"]  = heightmapPath.toStdString();
    data["block_size"] = ui->blockSize->value();
    data["factor"]     = ui->factor->value();
    data["min_level"]  = ui->minimumLevel->value();
    data["max_height"] = ui->maximumLevel->value();
    DataTree::Writers::JSON(data, inputFilename().toStdString());
  }
}
示例#5
0
文件: Wallet.cpp 项目: Atlante45/hifi
bool Wallet::writeBackupInstructions() {
    QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html");
    QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE);
    QFile inputFile(inputFilename);
    QFile outputFile(outputFilename);
    bool retval = false;

    if (getKeyFilePath().isEmpty()) {
        return false;
    }

    if (QFile::exists(inputFilename) && inputFile.open(QIODevice::ReadOnly)) {
        if (outputFile.open(QIODevice::ReadWrite)) {
            // Read the data from the original file, then close it
            QByteArray fileData = inputFile.readAll();
            inputFile.close();

            // Translate the data from the original file into a QString
            QString text(fileData);

            // Replace the necessary string
            text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath());

            // Write the new text back to the file
            outputFile.write(text.toUtf8());

            // Close the output file
            outputFile.close();

            retval = true;
            qCDebug(commerce) << "wrote html file successfully";
        } else {
            qCDebug(commerce) << "failed to open output html file" << outputFilename;
        }
    } else {
        qCDebug(commerce) << "failed to open input html file" << inputFilename;
    }
    return retval;
}