//*********************************************************
//****************READ FILE FORMAT*************************
//*********************************************************
bool FileFormats::ReadSMBX64ConfigFileF(PGESTRING  filePath, SMBX64_ConfigFile &FileData)
{
    FileData.meta.ERROR_info.clear();
    PGE_FileFormats_misc::TextFileInput file;

    if(!file.open(filePath, false))
    {
        FileData.meta.ERROR_info = "Failed to open file for read";
        FileData.meta.ERROR_linedata = "";
        FileData.meta.ERROR_linenum = -1;
        FileData.meta.ReadFileValid = false;
        return false;
    }

    return ReadSMBX64ConfigFile(file, FileData);
}
Exemple #2
0
bool EpisodeBox_level::open(QString filePath)
{
    fPath=filePath;

    PGE_FileFormats_misc::TextFileInput file;
    if(file.open(fPath))
    {
        PGESTRING firstLine = file.read(8);
        file.close();
        if( PGE_StartsWith( firstLine, "SMBXFile" ) )
        {
            ftype = F_LVL38A;
            FileFormats::ReadSMBX38ALvlFileF(filePath, d);
        }
        else if( PGE_DetectSMBXFile( firstLine ) )
        {
            ftype = F_LVL;
            FileFormats::ReadSMBX64LvlFileF(filePath, d);
        }
        else
        {
            ftype = F_LVLX;
            FileFormats::ReadExtendedLvlFileF(filePath, d);
        }
        qDebug()<< "Opened level, is valid = " << d.ReadFileValid << filePath;
    }

    //Collect music entries!
    if(d.ReadFileValid)
    {
        QDir fullPath(d.path);
        //From sections
        for(int i=0; i<d.sections.size(); i++)
        {
            QString &musFile = d.sections[i].music_file;
            if(musFile.isEmpty()) continue;
            musFile.replace('\\', '/');
            musFile.replace("//", "/");
            QString mFile = fullPath.absoluteFilePath(musFile);

            MusicField mus;
            mus.absolutePath = mFile;
            mus.field = &musFile;
            music_entries.push_back(mus);
        }

        //For custom musics per events
        for(int i=0; i < d.events.size(); i++)
        {
            for(int j=0;j < d.events[i].sets.size(); j++)
            {
                QString &musFile = d.events[i].sets[j].music_file;
                if(musFile.isEmpty()) continue;
                musFile.replace('\\', '/');
                musFile.replace("//", "/");
                QString mFile = fullPath.absoluteFilePath(musFile);

                MusicField mus;
                mus.absolutePath = mFile;
                mus.field = &musFile;
                music_entries.push_back(mus);
            }
        }
    }

    return d.ReadFileValid;
}