void dataconfigs::loadLevelBGO()
{
    unsigned int i;

    obj_bgo sbgo;
    unsigned long bgo_total=0;
    QString bgo_ini = config_dir + "lvl_bgo.ini";

    if(!QFile::exists(bgo_ini))
    {
        addError(QString("ERROR LOADING lvl_bgo.ini: file does not exist"),  PGE_LogLevel::Critical);
        return;
    }

    QSettings bgoset(bgo_ini, QSettings::IniFormat);
    bgoset.setIniCodec("UTF-8");

    main_bgo.clear();   //Clear old
//    index_bgo.clear();

    bgoset.beginGroup("background-main");
        bgo_total = bgoset.value("total", "0").toInt();
        total_data +=bgo_total;
    bgoset.endGroup();

    emit progressPartNumber(1);
    emit progressMax(bgo_total);
    emit progressValue(0);
    emit progressTitle(QObject::tr("Loading BGOs..."));

    ConfStatus::total_bgo = bgo_total;

    main_bgo.allocateSlots(bgo_total);

    if(ConfStatus::total_bgo==0)
    {
        addError(QString("ERROR LOADING lvl_bgo.ini: number of items not define, or empty config"), PGE_LogLevel::Critical);
        return;
    }

    for(i=1; i<=bgo_total; i++)
    {
        emit progressValue(i);
        if( loadLevelBGO(sbgo, QString("background-"+QString::number(i)), 0, "", &bgoset) )
        {
            sbgo.id = i;
            main_bgo.storeElement(i, sbgo);
        }

        if( bgoset.status() != QSettings::NoError )
        {
            addError(QString("ERROR LOADING lvl_bgo.ini N:%1 (bgo-%2)").arg(bgoset.status()).arg(i), PGE_LogLevel::Critical);
        }
    }

    if((unsigned int)main_bgo.stored()<bgo_total)
    {
        addError(QString("Not all BGOs loaded! Total: %1, Loaded: %2").arg(bgo_total).arg(main_bgo.stored()));
    }
}
void dataconfigs::loadRotationTable()
{
    size_t i = 0;
    obj_rotation_table rTable;

    QString rtables_ini = config_dir + "rotation_table.ini";

    if(!QFile::exists(rtables_ini))
    {
        addError(QString("Rotation tables wasn't load: rotation_table.ini does not exist"), PGE_LogLevel::Warning);
        return;
    }

    IniProcessing rtable_set(rtables_ini);
    main_rotation_table.clear();

    std::vector<std::string> groups = rtable_set.childGroups();

    if(groups.size()==0)
    {
        addError(QString("ERROR LOADING of rotation_table.ini: number of items not define, or empty config"), PGE_LogLevel::Warning);
        return;
    }

    emit progressPartNumber(12);
    emit progressMax(static_cast<int>(groups.size()));
    emit progressValue(0);
    emit progressTitle(QObject::tr("Loading rotation rules table..."));

    for(i = 0; i < groups.size(); i++)
    {
        emit progressValue(static_cast<int>(i));

        if(groups[i]=="main")
            continue;

        rtable_set.beginGroup( groups[i] );
        {
            rTable.type =           Items::getItemType(rtable_set.value("type", "-1").toQString());
            rTable.id   =           rtable_set.value("id", "0").toInt();
            rTable.rotate_left =    rtable_set.value("rotate-left", "0").toInt();
            rTable.rotate_right =   rtable_set.value("rotate-right", "0").toInt();
            rTable.flip_h =         rtable_set.value("flip-h", "0").toInt();
            rTable.flip_v =         rtable_set.value("flip-v", "0").toInt();
        }
        rtable_set.endGroup();

        if(rTable.type<0) continue;

        main_rotation_table.push_back(rTable);

        if(rtable_set.lastError() != IniProcessing::ERR_OK)
        {
            addError(QString("ERROR LOADING lvl_bgo.ini N:%1 (bgo-%2)").arg(rtable_set.lastError()).arg(i), PGE_LogLevel::Critical);
        }
    }
}
Exemple #3
0
void dataconfigs::loadLevelBGO()
{
    unsigned long i;

    obj_bgo sbgo;
    unsigned long bgo_total=0;
    bool useDirectory=false;

    QString bgo_ini = getFullIniPath("lvl_bgo.ini");
    if(bgo_ini.isEmpty())
        return;

    QString nestDir = "";

    QSettings setup(bgo_ini, QSettings::IniFormat);
    setup.setIniCodec("UTF-8");

    main_bgo.clear();   //Clear old

    if(!openSection( &setup, "background-main")) return;
        bgo_total = setup.value("total", 0).toUInt();
        defaultGrid.bgo = setup.value("grid", defaultGrid.bgo).toUInt();
        total_data +=bgo_total;
        nestDir =   setup.value("config-dir", "").toString();
        if(!nestDir.isEmpty())
        {
            nestDir = config_dir + nestDir;
            useDirectory = true;
        }
    closeSection(&setup);

    emit progressPartNumber(1);
    emit progressMax(static_cast<int>(bgo_total));
    emit progressValue(0);
    emit progressTitle(QObject::tr("Loading BGOs..."));

    ConfStatus::total_bgo = static_cast<long>(bgo_total);

    main_bgo.allocateSlots(static_cast<int>(bgo_total));

    if(ConfStatus::total_bgo==0)
    {
        addError(QString("ERROR LOADING lvl_bgo.ini: number of items not define, or empty config"), PGE_LogLevel::Critical);
        return;
    }

    for(i=1; i<=bgo_total; i++)
    {
        emit progressValue(static_cast<int>(i));
        bool valid=false;

        if(useDirectory)
        {
            valid = loadLevelBGO(sbgo, "background", nullptr, QString("%1/background-%2.ini").arg(nestDir).arg(i));
        }
        else
        {
            valid = loadLevelBGO(sbgo, QString("background-%1").arg(i), 0, "", &setup);
        }

        /***************Load image*******************/
        if(valid)
        {
            QString errStr;
            GraphicsHelps::loadMaskedImage(bgoPath,
               sbgo.setup.image_n, sbgo.setup.mask_n,
               sbgo.image,
               errStr);

            if(!errStr.isEmpty())
            {
                valid=false;
                addError(QString("BGO-%1 %2").arg(i).arg(errStr));
            }
        }
        /***************Load image*end***************/
        sbgo.setup.id = i;
        main_bgo.storeElement(static_cast<int>(i), sbgo, valid);

        if( setup.status() != QSettings::NoError )
        {
            addError(QString("ERROR LOADING lvl_bgo.ini N:%1 (bgo-%2)").arg(setup.status()).arg(i), PGE_LogLevel::Critical);
        }
    }

    if(static_cast<unsigned long>(main_bgo.stored()) < bgo_total)
    {
        addError(QString("Not all BGOs loaded! Total: %1, Loaded: %2").arg(bgo_total).arg(main_bgo.stored()));
    }
}
void dataconfigs::loadTilesets()
{
    main_tilesets.clear();
    main_tilesets_grp.clear();

    QString tileset_dir = config_dir + "tilesets/";
    QString tileset_grp_dir = config_dir + "group_tilesets/";
    QStringList filters;

    if(QDir(tileset_dir).exists())
    {
        emit progressPartNumber(10);
        emit progressMax(100);
        emit progressValue(0);
        emit progressTitle(QObject::tr("Loading Tilesets..."));

        filters.clear();
        filters << "*.tileset.ini";
        QDir tilesetDir(tileset_dir);
        tilesetDir.setSorting(QDir::Name);
        tilesetDir.setNameFilters(filters);
        QStringList files = tilesetDir.entryList(filters);

        emit progressMax(files.size());
        for(int i=0;i<files.size(); i++)
        {
            emit progressValue(i);
            SimpleTileset xxx;
            if(tileset::OpenSimpleTileset(tileset_dir + files[i], xxx))
            {
                main_tilesets.push_back(xxx);
            }
        }
    }

    if(QDir(tileset_grp_dir).exists())
    {
        emit progressPartNumber(11);
        emit progressMax(100);
        emit progressValue(0);
        emit progressTitle(QObject::tr("Loading Tileset groups..."));

        filters.clear();
        filters << "*.tsgrp.ini";
        QDir tilesetDir(tileset_grp_dir);
        tilesetDir.setSorting(QDir::Name);
        tilesetDir.setNameFilters(filters);

        QStringList files = tilesetDir.entryList(filters);
        emit progressMax(files.size());
        for(int i=0;i<files.size(); i++)
        {
            emit progressValue(i);
            SimpleTilesetGroup xxx;
            if(TilesetGroupEditor::OpenSimpleTilesetGroup(tileset_grp_dir + files[i], xxx))
            {
                main_tilesets_grp.push_back(xxx);
            }
        }
    }
}
void dataconfigs::loadLevelBlocks()
{
    unsigned int i;

    obj_block sblock;
    unsigned long block_total=0;


    QString block_ini = config_dir + "lvl_blocks.ini";

    if(!QFile::exists(block_ini))
    {
        addError(QString("ERROR LOADING lvl_blocks.ini: file does not exist"), QtCriticalMsg);
          return;
    }

    QSettings blockset(block_ini, QSettings::IniFormat);
    blockset.setIniCodec("UTF-8");

    main_block.clear();   //Clear old
    index_blocks.clear();

    blockset.beginGroup("blocks-main");
        block_total = blockset.value("total", "0").toInt();
        total_data +=block_total;
    blockset.endGroup();

    emit progressMax(block_total);
    emit progressTitle(QApplication::tr("Loading Blocks..."));

    ConfStatus::total_blocks = block_total;

    //creation of empty indexes of arrayElements
    blocksIndexes blockIndex;
    for(i=0;i<=block_total; i++)
    {
        blockIndex.i=i;
        blockIndex.type=0;
        index_blocks.push_back(blockIndex);
    }


    if(ConfStatus::total_blocks==0)
    {
        addError(QString("ERROR LOADING lvl_blocks.ini: number of items not define, or empty config"), QtCriticalMsg);
        return;
    }


        for(i=1; i<=block_total; i++)
        {
            emit progressValue(i);
            QString errStr;

            blockset.beginGroup( QString("block-%1").arg(i) );

                sblock.name =       blockset.value("name", QString("block %1").arg(i) ).toString();

                if(sblock.name=="")
                {
                    addError(QString("BLOCK-%1 Item name isn't defined").arg(i));
                    goto skipBLOCK;
                }

                sblock.group =      blockset.value("group", "_NoGroup").toString();
                sblock.category =   blockset.value("category", "_Other").toString();
                sblock.grid =       blockset.value("grid", default_grid).toInt();

                sblock.image_n =           blockset.value("image", "").toString();
                /***************Load image*******************/
                GraphicsHelps::loadMaskedImage(blockPath,
                   sblock.image_n, sblock.mask_n,
                   sblock.image,   sblock.mask,
                   errStr);

                if(!errStr.isEmpty())
                {
                    addError(QString("BLOCK-%1 %2").arg(i).arg(errStr));
                    goto skipBLOCK;
                }
                /***************Load image*end***************/

                sblock.sizable =                blockset.value("sizable", "0").toBool();
                sblock.danger =                 blockset.value("danger", "0").toInt();
                sblock.collision =              blockset.value("collision", "1").toInt();
                sblock.slopeslide =             blockset.value("slope-slide", "0").toBool();
                sblock.phys_shape =             blockset.value("fixture-type", "0").toInt();// Leaved for compatibility
                sblock.phys_shape =             blockset.value("shape-type", sblock.phys_shape).toInt();//new value-name
                sblock.lava =                   blockset.value("lava", "0").toBool();
                sblock.destroyable =            blockset.value("destroyable", "0").toBool();
                sblock.destroyable_by_bomb =    blockset.value("destroyable-by-bomb", "0").toBool();
                sblock.destroyable_by_fireball= blockset.value("destroyable-by-fireball", "0").toBool();

                Temp01 =     blockset.value("spawn-on-destroy", "0").toString();
                if(Temp01!="0")
                {
                    tmp =  Temp01.split("-", QString::SkipEmptyParts);
                    if(tmp.size()==2)
                    {
                        if(tmp[0]=="npc")
                            sblock.spawn_obj = 1;
                        else
                        if(tmp[0]=="block")
                             sblock.spawn_obj = 2;
                        else
                        if(tmp[0]=="bgo")
                             sblock.spawn_obj = 3;
                        // 1 - NPC, 2 - block, 3 - BGO
                        sblock.spawn_obj_id = tmp[1].toInt();
                    }
                    else // if syntax error in config
                    {
                        sblock.spawn = false;
                        sblock.spawn_obj = 0;
                        sblock.spawn_obj_id = 0;
                    }
                }
                else
                {
                    sblock.spawn = false;
                    sblock.spawn_obj = 0;
                    sblock.spawn_obj_id = 0;
                }

                sblock.effect=                  blockset.value("destroy-effect", "1").toInt();

                sblock.bounce =                 blockset.value("bounce", "0").toBool();
                sblock.hitable =                blockset.value("hitable", "0").toBool();
                sblock.transfororm_on_hit_into= blockset.value("transform-onhit-into", "2").toInt();
                sblock.algorithm =              blockset.value("algorithm", "2").toInt();
                sblock.view =             (int)(blockset.value("view", "background").toString()=="foreground");
                sblock.animated =               blockset.value("animated", "0").toBool();
                sblock.animation_rev =          blockset.value("animation-reverse", "0").toBool(); //Reverse animation
                sblock.animation_bid =          blockset.value("animation-bidirectional", "0").toBool(); //Bidirectional animation
                sblock.frames =                 blockset.value("frames", "1").toInt();
                sblock.framespeed =             blockset.value("framespeed", "125").toInt();

                sblock.frame_h =               (sblock.animated?
                                                    qRound(
                                                        qreal(sblock.image.height())
                                                        /sblock.frames)
                                                  : sblock.image.height());

                sblock.display_frame =          blockset.value("display-frame", "0").toInt();

                long iTmp;
                iTmp =  blockset.value("default-invisible", "-1").toInt();
                    sblock.default_invisible = (iTmp>=0);
                    sblock.default_invisible_value = (iTmp>=0)?(bool)iTmp:false;

                iTmp = blockset.value("default-slippery", "-1").toInt();
                    sblock.default_slippery = (iTmp>=0);
                    sblock.default_slippery_value = (iTmp>=0)?(bool)iTmp:false;

                iTmp = blockset.value("default-npc-content", "-1").toInt();
                    sblock.default_content = (iTmp>=0);
                    sblock.default_content_value = (iTmp>=0) ? (iTmp<1000? iTmp*-1 : iTmp-1000) : 0;

                sblock.id = i;
                main_block.push_back(sblock);

                /************Add to Index***************/
                if(i < (unsigned int)index_blocks.size())
                    index_blocks[i].i = i-1;
                /************Add to Index***************/

            skipBLOCK:
            blockset.endGroup();

          if( blockset.status()!=QSettings::NoError)
          {
            addError(QString("ERROR LOADING lvl_blocks.ini N:%1 (block-%2)").arg(blockset.status()).arg(i), QtCriticalMsg);
            break;
          }
       }

       if((unsigned int)main_block.size()<block_total)
       {
           addError(QString("Not all blocks loaded! Total: %1, Loaded: %2)").arg(block_total).arg(main_block.size()), QtWarningMsg);
       }

}
Exemple #6
0
void dataconfigs::loadLevelBackgrounds()
{
    unsigned int i;
    obj_BG sbg;
    unsigned long bg_total=0;
    bool useDirectory=false;

    QString bg_ini = getFullIniPath("lvl_bkgrd.ini");
    if( bg_ini.isEmpty() )
        return;

    QString nestDir = "";

    QSettings setup(bg_ini, QSettings::IniFormat);
    setup.setIniCodec("UTF-8");

    main_bg.clear();   //Clear old

    if(!openSection(&setup, "background2-main")) return;
        bg_total = setup.value("total", 0).toUInt();
        total_data += bg_total;
        nestDir = setup.value("config-dir", "").toString();
        if(!nestDir.isEmpty())
        {
            nestDir = config_dir + nestDir;
            useDirectory = true;
        }
    closeSection(&setup);

    emit progressPartNumber(0);
    emit progressMax(int(bg_total));
    emit progressValue(0);
    emit progressTitle(QObject::tr("Loading Backgrounds..."));

    ConfStatus::total_bg = long(bg_total);
    main_bg.allocateSlots(int(bg_total));

    if(ConfStatus::total_bg==0)
    {
        addError(QString("ERROR LOADING lvl_bkgrd.ini: number of items not define, or empty config"), PGE_LogLevel::Critical);
        return;
    }

    for(i=1; i<=bg_total; i++)
    {
        emit progressValue(int(i));

        bool valid = false;
        if(useDirectory)
        {
            valid = loadLevelBackground(sbg, "background2", nullptr, QString("%1/background2-%2.ini").arg(nestDir).arg(i));
        }
        else
        {
            valid = loadLevelBackground(sbg, QString("background2-%1").arg(i), 0, "", &setup);
        }

        sbg.id = i;
        main_bg.storeElement(int(i), sbg, valid);

        if( setup.status() != QSettings::NoError )
        {
            addError(QString("ERROR LOADING lvl_bgrnd.ini N:%1 (background2-%2)").arg(setup.status()).arg(i), PGE_LogLevel::Critical);
        }
    }
}
void dataconfigs::loadLevelBGO()
{
    unsigned long i;

    obj_bgo sbgo;
    unsigned long bgo_total = 0;
    bool useDirectory = false;

    QString bgo_ini = getFullIniPath("lvl_bgo.ini");
    if(bgo_ini.isEmpty())
        return;

    IniProcessing setup(bgo_ini);

    folderLvlBgo.items.clear();
    main_bgo.clear();   //Clear old

    if(!openSection(&setup, "background-main"))
        return;
    {
        setup.read("total", bgo_total, 0);
        setup.read("grid",  defaultGrid.bgo, defaultGrid.bgo);
        total_data += bgo_total;
        setup.read("config-dir", folderLvlBgo.items, "");
        setup.read("extra-settings", folderLvlBgo.extraSettings, folderLvlBgo.items);
        if(!folderLvlBgo.items.isEmpty())
        {
            folderLvlBgo.items = config_dir + folderLvlBgo.items;
            useDirectory = true;
        }
    }
    closeSection(&setup);

    emit progressPartNumber(1);
    emit progressMax(static_cast<int>(bgo_total));
    emit progressValue(0);
    emit progressTitle(QObject::tr("Loading BGOs..."));

    ConfStatus::total_bgo = static_cast<long>(bgo_total);

    main_bgo.allocateSlots(static_cast<int>(bgo_total));

    if(ConfStatus::total_bgo == 0)
    {
        addError(QString("ERROR LOADING lvl_bgo.ini: number of items not define, or empty config"), PGE_LogLevel::Critical);
        return;
    }

    for(i = 1; i <= bgo_total; i++)
    {
        emit progressValue(static_cast<int>(i));
        bool valid = false;

        if(useDirectory)
            valid = loadLevelBGO(sbgo, "background", nullptr, QString("%1/background-%2.ini").arg(folderLvlBgo.items).arg(i));
        else
            valid = loadLevelBGO(sbgo, QString("background-%1").arg(i), 0, "", &setup);

        /***************Load image*******************/
        if(valid)
        {
            QString errStr;
            GraphicsHelps::loadMaskedImage(folderLvlBgo.graphics,
                                           sbgo.setup.image_n, sbgo.setup.mask_n,
                                           sbgo.image,
                                           errStr);

            if(!errStr.isEmpty())
            {
                valid = false;
                addError(QString("BGO-%1 %2").arg(i).arg(errStr));
            }
        }
        /***************Load image*end***************/
        sbgo.setup.id = i;
        main_bgo.storeElement(static_cast<int>(i), sbgo, valid);

        if(setup.lastError() != IniProcessing::ERR_OK)
            addError(QString("ERROR LOADING lvl_bgo.ini N:%1 (bgo-%2)").arg(setup.lastError()).arg(i), PGE_LogLevel::Critical);
    }

    if(static_cast<unsigned long>(main_bgo.stored()) < bgo_total)
        addError(QString("Not all BGOs loaded! Total: %1, Loaded: %2").arg(bgo_total).arg(main_bgo.stored()));
}
void dataconfigs::loadWorldScene()
{
    unsigned int i;

    obj_w_scenery sScene;
    unsigned long scenery_total=0;
    QString scene_ini = config_dir + "wld_scenery.ini";

    if(!QFile::exists(scene_ini))
    {
        addError(QString("ERROR LOADING wld_scenery.ini: file does not exist"), QtCriticalMsg);
        return;
    }


    QSettings sceneset(scene_ini, QSettings::IniFormat);
    sceneset.setIniCodec("UTF-8");

    main_wscene.clear();   //Clear old
    index_wscene.clear();

    sceneset.beginGroup("scenery-main");
        scenery_total = sceneset.value("total", "0").toInt();
        total_data +=scenery_total;
    sceneset.endGroup();

    emit progressMax(scenery_total);
    emit progressTitle(QApplication::tr("Loading Sceneries..."));

    ConfStatus::total_wscene= scenery_total;

    //creation of empty indexes of arrayElements
        wSceneIndexes sceneIndex;
        for(i=0;i<=scenery_total; i++)
        {
            sceneIndex.i=i;
            sceneIndex.type=0;
            sceneIndex.ai=0;
            index_wscene.push_back(sceneIndex);
        }

    if(ConfStatus::total_wscene==0)
    {
        addError(QString("ERROR LOADING wld_scenery.ini: number of items not define, or empty config"), QtCriticalMsg);
        return;
    }

    for(i=1; i<=scenery_total; i++)
    {
        emit progressValue(i);
        QString errStr;

        sceneset.beginGroup( QString("scenery-"+QString::number(i)) );

            sScene.group =         sceneset.value("group", "_NoGroup").toString();
            sScene.category =      sceneset.value("category", "_Other").toString();

            sScene.image_n =       sceneset.value("image", "").toString();
            /***************Load image*******************/
            GraphicsHelps::loadMaskedImage(scenePath,
               sScene.image_n, sScene.mask_n,
               sScene.image,   sScene.mask,
               errStr);

            if(!errStr.isEmpty())
            {
                addError(QString("SCENE-%1 %2").arg(i).arg(errStr));
                goto skipScene;
            }
            /***************Load image*end***************/

            sScene.grid =          sceneset.value("grid", qRound(qreal(default_grid)/2)).toInt();

            sScene.animated =     (sceneset.value("animated", "0").toString()=="1");
            sScene.frames =        sceneset.value("frames", "1").toInt();
            sScene.framespeed =    sceneset.value("frame-speed", "175").toInt();

            sScene.frame_h =   (sScene.animated?
                      qRound(qreal(sScene.image.height())/
                                   sScene.frames)
                                 : sScene.image.height());

            sScene.display_frame = sceneset.value("display-frame", "0").toInt();



            sScene.id = i;
            main_wscene.push_back(sScene);
            /************Add to Index***************/
            if(i <= (unsigned int)index_wscene.size())
            {
                index_wscene[i].i = i-1;
            }
            /************Add to Index***************/

        skipScene:
        sceneset.endGroup();

        if( sceneset.status() != QSettings::NoError )
        {
            addError(QString("ERROR LOADING wld_scenery.ini N:%1 (scene-%2)").arg(sceneset.status()).arg(i), QtCriticalMsg);
        }
    }

    if((unsigned int)main_wscene.size()<scenery_total)
    {
        addError(QString("Not all Sceneries loaded! Total: %1, Loaded: %2").arg(scenery_total).arg(main_wscene.size()));
    }
}
void dataconfigs::loadWorldLevels()
{
    unsigned int i;

    obj_w_level slevel;
    unsigned long levels_total=0;
    QString level_ini = config_dir + "wld_levels.ini";

    if(!QFile::exists(level_ini))
    {
        addError(QString("ERROR LOADING wld_levels.ini: file does not exist"), QtCriticalMsg);
        return;
    }


    QSettings levelset(level_ini, QSettings::IniFormat);
    levelset.setIniCodec("UTF-8");

    main_wlevels.clear();   //Clear old
    index_wlvl.clear();

    levelset.beginGroup("levels-main");
        levels_total = levelset.value("total", "0").toInt();
        marker_wlvl.path = levelset.value("path", "0").toInt();
        marker_wlvl.bigpath = levelset.value("bigpath", "0").toInt();
        total_data +=levels_total;
    levelset.endGroup();

    emit progressMax(levels_total);
    emit progressTitle(QApplication::tr("Loading Level images..."));

    ConfStatus::total_wlvl = levels_total;

    //creation of empty indexes of arrayElements
        wLevelIndexes levelIndex;
        for(i=0;i<=levels_total; i++)
        {
            levelIndex.i=i;
            levelIndex.type=0;
            levelIndex.ai=0;
            index_wlvl.push_back(levelIndex);
        }

    if(ConfStatus::total_wlvl==0)
    {
        addError(QString("ERROR LOADING wld_levels.ini: number of items not define, or empty config"), QtCriticalMsg);
        return;
    }

    for(i=0; i<=levels_total; i++)
    {
        emit progressValue(i);
        QString errStr;

        levelset.beginGroup( QString("level-"+QString::number(i)) );

        slevel.group =      levelset.value("group", "_NoGroup").toString();
        slevel.category =   levelset.value("category", "_Other").toString();

        slevel.image_n =    levelset.value("image", "").toString();
        /***************Load image*******************/
        GraphicsHelps::loadMaskedImage(wlvlPath,
           slevel.image_n, slevel.mask_n,
           slevel.image,   slevel.mask,
           errStr);

        if(!errStr.isEmpty())
        {
            addError(QString("LEVEL-%1 %2").arg(i).arg(errStr));
            goto skipLevel;
        }
        /***************Load image*end***************/

        slevel.grid =       levelset.value("grid", default_grid).toInt();

        slevel.animated =  (levelset.value("animated", "0").toString()=="1");
        slevel.frames =     levelset.value("frames", "1").toInt();
        slevel.framespeed = levelset.value("frame-speed", "175").toInt();

        slevel.frame_h =   (slevel.animated?
                                qRound(qreal(slevel.image.height())/
                                             slevel.frames)
                                    : slevel.image.height());

        slevel.display_frame = levelset.value("display-frame", "0").toInt();


        slevel.id = i;
        main_wlevels.push_back(slevel);

        /************Add to Index***************/
        if(i <= (unsigned int)index_wlvl.size())
        {
            index_wlvl[i].i = i;
        }
        /************Add to Index***************/

        skipLevel:
        levelset.endGroup();

        if( levelset.status() != QSettings::NoError )
        {
            addError(QString("ERROR LOADING wld_levels.ini N:%1 (level-%2)").arg(levelset.status()).arg(i), QtCriticalMsg);
        }
    }

    if((unsigned int)main_wlevels.size()<levels_total)
    {
        addError(QString("Not all Level images loaded! Total: %1, Loaded: %2").arg(levels_total).arg(main_wlevels.size()));
    }
}