Пример #1
0
bool SmartImporter::attemptFastImport()
{
    if(targetLevelWindow)
    {
        if(targetLevelWindow->isUntitled)
        {
            QMessageBox::warning(parentWid, tr("File not saved"), tr("You need to save the level, so you can import custom graphics!"), QMessageBox::Ok);
            return false;
        }
        CustomDirManager uLVL(targetLevelWindow->LvlData.meta.path, targetLevelWindow->LvlData.meta.filename);
        QDir sourceDir(importPath);
        if(!sourceDir.exists())
            return false;

        QStringList allFiles = sourceDir.entryList(QDir::Files | QDir::Readable, QDir::Name);
        QStringList filteredFiles;
        foreach (QString tarFile, allFiles)
        {
            if(tarFile.endsWith(".tileset.ini", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("block-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("background-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("background2-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("npc-", Qt::CaseInsensitive) &&
                    (tarFile.endsWith(".gif", Qt::CaseInsensitive)||
                    tarFile.endsWith(".txt", Qt::CaseInsensitive)))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("effect-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("yoshib-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("yoshit-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("mario-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("luigi-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("peach-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("toad-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
            if(tarFile.startsWith("link-", Qt::CaseInsensitive) && tarFile.endsWith(".gif", Qt::CaseInsensitive))
                filteredFiles << importPath + tarFile;
        }

        uLVL.createDirIfNotExsist();
        uLVL.import(filteredFiles);
        return true;
    }
    else if(targetWorldWindow)
Пример #2
0
//Search and load custom User's files
void LvlScene::loadUserData(QProgressDialog &progress)
{
    int i, total=0;

    UserBGs uBG;
    UserBlocks uBlock;
    UserBGOs uBGO;
    UserNPCs uNPC;

    bool WrongImagesDetected=false;

    uBGOs.clear();
    uBlocks.clear();
    uNPCs.clear();
    uBGs.clear();

    bool loaded1, loaded2;

    CustomDirManager uLVL(LvlData->path, LvlData->filename);

    //Load custom rotation rules
    QString rTableFile = uLVL.getCustomFile("rotation_table.ini");
    if(!rTableFile.isEmpty())
    {
        QSettings rTableINI(rTableFile, QSettings::IniFormat);
        rTableINI.setIniCodec("UTF-8");

        QStringList rules = rTableINI.childGroups();

        int count=0;
        foreach(QString x, rules)
        {
            obj_rotation_table t;
            rTableINI.beginGroup(x);
                t.id = rTableINI.value("id", 0).toInt();
                t.type = Items::getItemType(rTableINI.value("type", "-1").toString());
                t.rotate_left = rTableINI.value("rotate-left", 0).toInt();
                t.rotate_right = rTableINI.value("rotate-right", 0).toInt();
                t.flip_h = rTableINI.value("flip-h", 0).toInt();
                t.flip_v = rTableINI.value("flip-v", 0).toInt();
            rTableINI.endGroup();
            if(t.id<=0) continue;

            if(t.type==ItemTypes::LVL_Block)
            {
                local_rotation_table_blocks[t.id]=t;
                count++;
            }
            else
            if(t.type==ItemTypes::LVL_BGO)
            {
                local_rotation_table_bgo[t.id]=t;
                count++;
            }
            else
            if(t.type==ItemTypes::LVL_NPC)
            {
                local_rotation_table_npc[t.id]=t;
                count++;
            }
        }