Exemplo n.º 1
0
// //////////////////////////////////////////////////////////////
void MainWindow::on_actionAnimation_triggered(bool checked)
{
    GlobalSettings::LvlOpts.animationEnabled = checked;
    if(activeChildWindow() == WND_Level)
    {
        LevelEdit *e=activeLvlEditWin(); if(!e) return;
        LvlScene  *s=e->scene; if(!s) return;
        if(GlobalSettings::LvlOpts.animationEnabled)
            s->startAnimation();
        else
            s->stopAnimation();
        s->m_opts.animationEnabled = GlobalSettings::LvlOpts.animationEnabled;
    }
    else
    if(activeChildWindow() == WND_World)
    {
        activeWldEditWin()->scene->m_opts.animationEnabled = GlobalSettings::LvlOpts.animationEnabled;
        if(GlobalSettings::LvlOpts.animationEnabled)
        {
            activeWldEditWin()->scene->startAnimation();
        }
        else
            activeWldEditWin()->scene->stopAnimation();
    }
}
Exemplo n.º 2
0
//Cut
void MainWindow::on_actionCut_triggered()
{
    int q1=0, q2=0, q3=0, q4=0, q5=0;
    if (activeChildWindow()==1) //if active window is a levelEditor
    {
       LvlBuffer=activeLvlEditWin()->scene->copy(true);
       q1 += LvlBuffer.blocks.size();
       q2 += LvlBuffer.bgo.size();
       q3 += LvlBuffer.npc.size();
       q4 += LvlBuffer.physez.size();
       statusBar()->showMessage(tr("%1 blocks, %2 BGO, %3 NPC, %4 Water items have been moved to clipboard").arg(q1).arg(q2).arg(q3).arg(q4), 2000);
       QString raw;
       FileFormats::WriteExtendedLvlFileRaw(LvlBuffer, raw);
       QApplication::clipboard()->setText(raw);
    }
    else
    if (activeChildWindow()==3) //if active window is a worldEditor
    {
       WldBuffer=activeWldEditWin()->scene->copy(true);
       q1 += WldBuffer.tiles.size();
       q2 += WldBuffer.scenery.size();
       q3 += WldBuffer.paths.size();
       q4 += WldBuffer.levels.size();
       q5 += WldBuffer.music.size();
       statusBar()->showMessage(tr("%1 tiles, %2 sceneries, %3 paths, %4 levels, %5 music boxes items have been moved to clipboard").arg(q1).arg(q2).arg(q3).arg(q4).arg(q5), 2000);
       QString raw;
       FileFormats::WriteExtendedWldFileRaw(WldBuffer, raw);
       QApplication::clipboard()->setText(raw);
    }
}
Exemplo n.º 3
0
// //////////////////////////////////////////////////////////////
void MainWindow::on_actionAnimation_triggered(bool checked)
{
    GlobalSettings::LvlOpts.animationEnabled = checked;
    if (activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->opts.animationEnabled = GlobalSettings::LvlOpts.animationEnabled;
        if(GlobalSettings::LvlOpts.animationEnabled)
        {
            activeLvlEditWin()->scene->startAnimation();
        }
        else
            activeLvlEditWin()->scene->stopAnimation();
    }
    else
    if (activeChildWindow()==3)
    {
        activeWldEditWin()->scene->opts.animationEnabled = GlobalSettings::LvlOpts.animationEnabled;
        if(GlobalSettings::LvlOpts.animationEnabled)
        {
            activeWldEditWin()->scene->startAnimation();
        }
        else
            activeWldEditWin()->scene->stopAnimation();
    }
}
Exemplo n.º 4
0
void MainWindow::on_actionZoomReset_triggered()
{
    if(activeChildWindow()==1)
        activeLvlEditWin()->ResetZoom();
    else
    if(activeChildWindow()==3)
        activeWldEditWin()->ResetZoom();
}
Exemplo n.º 5
0
//Reload opened file data
void MainWindow::on_actionReload_triggered()
{
    LevelData FileData;
    QString filePath;
    QRect wnGeom;

    if (activeChildWindow()==1)
    {
        filePath = activeLvlEditWin()->curFile;

        QFile fileIn(filePath);

        if (!fileIn.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(this, tr("File open error"),
        tr("Can't open the file."), QMessageBox::Ok);
            return;
        }

        FileData = FileFormats::ReadLevelFile(fileIn); //function in file_formats.cpp
        if( !FileData.ReadFileValid ){
            statusBar()->showMessage(tr("Reloading error"), 2000);
            return;}

        FileData.filename = QFileInfo(filePath).baseName();
        FileData.path = QFileInfo(filePath).absoluteDir().absolutePath();
        FileData.playmusic = GlobalSettings::autoPlayMusic;
        activeLvlEditWin()->LvlData.modified = false;
        activeLvlEditWin()->close();
        wnGeom = ui->centralWidget->activeSubWindow()->geometry();
        ui->centralWidget->activeSubWindow()->close();

        leveledit *child = createLvlChild();
        if ((bool) (child->loadFile(filePath, FileData, configs, GlobalSettings::LvlOpts))) {
            statusBar()->showMessage(tr("Level file reloaded"), 2000);
            child->show();
            ui->centralWidget->activeSubWindow()->setGeometry(wnGeom);
            updateMenus(true);
            SetCurrentLevelSection(0);

            if(GlobalSettings::autoPlayMusic) ui->actionPlayMusic->setChecked(true);
            LvlMusPlay::musicForceReset=true; //reset musics
            on_actionPlayMusic_triggered(ui->actionPlayMusic->isChecked());

        } else {
                WriteToLog(QtDebugMsg, ">>File loading aborted");
            child->show();
                WriteToLog(QtDebugMsg, ">>Window showed");
            if(activeChildWindow()==1) activeLvlEditWin()->LvlData.modified = false;
                WriteToLog(QtDebugMsg, ">>Option set");
            ui->centralWidget->activeSubWindow()->close();
                WriteToLog(QtDebugMsg, ">>Windows closed");
        }
    }

    clearFilter();
}
Exemplo n.º 6
0
//Paste
void MainWindow::on_actionPaste_triggered()
{
    if (activeChildWindow()==1)
    {
        LevelData tmp;
        QString raw=QApplication::clipboard()->text();
        if( FileFormats::ReadExtendedLvlFileRaw(raw, "<clipboard>", tmp) )
        {
            LvlBuffer = tmp;
        }

        if
        (   //if buffer is empty
                (LvlBuffer.blocks.size()==0)&&
                (LvlBuffer.bgo.size()==0)&&
                (LvlBuffer.npc.size()==0)&&
                (LvlBuffer.physez.size()==0)
        ) return;
    }
    else
    if (activeChildWindow()==3)
    {
        WorldData tmp;
        QString raw = QApplication::clipboard()->text();
        if( FileFormats::ReadExtendedWldFileRaw(raw, "<clipboard>", tmp) )
        {
            WldBuffer = tmp;
        }

        if
        (   //if buffer is empty
                (WldBuffer.tiles.size()==0)&&
                (WldBuffer.scenery.size()==0)&&
                (WldBuffer.paths.size()==0)&&
                (WldBuffer.levels.size()==0)&&
                (WldBuffer.music.size()==0)
        ) return;
    }

    resetEditmodeButtons();
    ui->actionSelect->setChecked(1);

    if (activeChildWindow()==1)
    {
       activeLvlEditWin()->scene->SwitchEditingMode(LvlScene::MODE_PasteFromClip);
       activeLvlEditWin()->scene->m_dataBuffer = LvlBuffer;
    }
    else
    if (activeChildWindow()==3)
    {
       activeWldEditWin()->scene->SwitchEditingMode(LvlScene::MODE_PasteFromClip);
       activeWldEditWin()->scene->WldBuffer = WldBuffer;
    }

}
Exemplo n.º 7
0
// //////////////////////////////////////////////////////////////
void MainWindow::on_actionGridEn_triggered(bool checked)
{
    if (activeChildWindow()==1)
    {
       activeLvlEditWin()->scene->grid = checked;
    }
    else
    if (activeChildWindow()==3)
    {
       activeWldEditWin()->scene->grid = checked;
    }
}
Exemplo n.º 8
0
void MainWindow::on_actionCollisions_triggered(bool checked)
{
    GlobalSettings::LvlOpts.collisionsEnabled = checked;
    if(activeChildWindow() == WND_Level)
    {
        activeLvlEditWin()->scene->m_opts.collisionsEnabled = GlobalSettings::LvlOpts.collisionsEnabled;
    }
    else
    if(activeChildWindow() == WND_World)
    {
        activeWldEditWin()->scene->m_opts.collisionsEnabled = GlobalSettings::LvlOpts.collisionsEnabled;
    }
}
Exemplo n.º 9
0
void MainWindow::on_actionResizeCancel_triggered()
{
    if (activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->resetResizers();;
    }
    else
    if (activeChildWindow()==3)
    {
        activeWldEditWin()->scene->resetResizers();
    }
    ui->ResizingToolbar->setVisible(false);
}
Exemplo n.º 10
0
void MainWindow::on_actionFlipVertical_triggered()
{
    if(activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->flipGroup(
                    activeLvlEditWin()->scene->selectedItems(), true  );
    }
    else
    if(activeChildWindow()==3)
    {
        activeWldEditWin()->scene->flipGroup(
                    activeWldEditWin()->scene->selectedItems(), true  );
    }
}
Exemplo n.º 11
0
void MainWindow::applyTextZoom()
{
    bool ok = false;
    int zoomPercent = 100;
    zoomPercent = zoom->text().toInt(&ok);
    if(!ok)
        return;

    if(activeChildWindow()==1){
        activeLvlEditWin()->setZoom(zoomPercent);
    }else if(activeChildWindow()==3){
        activeWldEditWin()->setZoom(zoomPercent);
    }
}
Exemplo n.º 12
0
void MainWindow::on_actionRotateRight_triggered()
{
    if(activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->rotateGroup(
                    activeLvlEditWin()->scene->selectedItems(), true  );
    }
    else
    if(activeChildWindow()==3)
    {
        activeWldEditWin()->scene->rotateGroup(
                    activeWldEditWin()->scene->selectedItems(), true   );
    }
}
Exemplo n.º 13
0
void MainWindow::on_actionLockDoors_triggered(bool checked)
{
    if (activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->setLocked(5, checked);
    }
}
Exemplo n.º 14
0
void MainWindow::on_actionExport_to_image_triggered()
{
    if(activeChildWindow()==1)
    {
        activeLvlEditWin()->ExportToImage_fn();
    }
}
Exemplo n.º 15
0
void MainWindow::on_action_doTestWld_triggered()
{
    /*
        FIXME!!! Implement the right world map testing via interprocess
        with ability to start player at absolutely any position on it
    */
    if(activeChildWindow() == WND_World)
    {
        WorldEdit *we = activeWldEditWin();
        if(!we->isUntitled() && we->isModified())
        {
            QMessageBox::StandardButton reply =
                QMessageBox::question(this,
                                      tr("World map testing of saved file"),
                                      tr("File is not saved!\n"
                                         "Do you want to save file or you want to run test "
                                         "of copy which is currently saved on the disk?"),
                                      QMessageBox::Yes | QMessageBox::No | QMessageBox::Abort);
            if(reply == QMessageBox::Yes)
            {
                if(!we->save())
                    return;
            }
            else if(reply != QMessageBox::No)
                return;
        }
        on_action_doSafeTest_triggered();
    }
}
Exemplo n.º 16
0
void MainWindow::on_actionReset_position_triggered()
{
    if (activeChildWindow()==1)
    {
       activeLvlEditWin()->ResetPosition();
    }
}
Exemplo n.º 17
0
void MainWindow::on_actionNewWorld_map_triggered()
{
    //Check if data configs are valid
    if( configs.check() )
    {
        WriteToLog(QtCriticalMsg, QString("Error! *.INI configs not loaded"));
        QMessageBox::warning(this, tr("Configuration is loaded with errors"),
                             tr("Cannot create world map file:\nConfiguration package loaded with errors.").arg(ConfStatus::configPath));
        //Show configuration status window
        on_actionCurConfig_triggered();
        return;
    }

    WorldEdit *child = createWldChild();
    if(child->newFile(configs, GlobalSettings::LvlOpts))
    {
        child->show();
        child->updateGeometry();
        child->ResetPosition();
        updateMenus(true);
        on_actionSelect_triggered();
    } else {
        child->show();
        if(activeChildWindow()==3) activeWldEditWin()->WldData.modified = false;
        ui->centralWidget->activeSubWindow()->close();
    }
}
Exemplo n.º 18
0
void MainWindow::on_actionNewLevel_triggered()
{
    //Check if data configs are valid
    if( configs.check() )
    {
        WriteToLog(QtCriticalMsg, QString("Error! *.INI configs not loaded"));
        QMessageBox::warning(this, tr("Configuration is loaded with errors"),
                             tr("Cannot create level file:\nConfiguration package loaded with errors.").arg(ConfStatus::configPath));
        //Show configuration status window
        on_actionCurConfig_triggered();
        return;
    }

    LevelEdit *child = createLvlChild();
    if(child->newFile(configs, GlobalSettings::LvlOpts))
    {
        child->show();
        child->updateGeometry();
        child->ResetPosition();
        updateMenus(true);
        SetCurrentLevelSection(0);
        on_actionSelect_triggered();
        dock_LvlWarpProps->init();
        dock_LvlLayers->setLayersBox();

        if(GlobalSettings::autoPlayMusic) ui->actionPlayMusic->setChecked(true);
        LvlMusPlay::musicForceReset=true; //reset musics
        on_actionPlayMusic_triggered(ui->actionPlayMusic->isChecked());
    } else {
        child->show();
        if(activeChildWindow()==1) activeLvlEditWin()->LvlData.modified = false;
        ui->centralWidget->activeSubWindow()->close();
    }
}
Exemplo n.º 19
0
void MainWindow::on_actionLockMusicBoxes_triggered(bool checked)
{
    if (activeChildWindow()==3)
    {
        activeWldEditWin()->scene->setLocked(5, checked);
    }
}
Exemplo n.º 20
0
// //////////////////////////////////////////////////////////////
void MainWindow::on_actionGridEn_triggered(bool checked)
{
    if(activeChildWindow() == WND_Level)
    {
        LevelEdit *e = activeLvlEditWin();
        assert(e);
        e->scene->m_opts.grid_snap = checked;
    }
    else
    if(activeChildWindow() == WND_World)
    {
        WorldEdit *e = activeWldEditWin();
        assert(e);
        e->scene->m_opts.grid_snap = checked;
    }
}
Exemplo n.º 21
0
void MainWindow::on_actionAlign_selected_triggered()
{

    if(activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->applyGridToEach(
                    activeLvlEditWin()->scene->selectedItems()   );
    }
    else
    if(activeChildWindow()==3)
    {
        activeWldEditWin()->scene->applyGridToEach(
                    activeWldEditWin()->scene->selectedItems()   );
    }

}
Exemplo n.º 22
0
void MainWindow::on_actionTileset_groups_editor_triggered()
{
    TilesetGroupEditor * groupDialog;
    if(activeChildWindow()==1)
        groupDialog = new TilesetGroupEditor(activeLvlEditWin()->scene, this);
    else if(activeChildWindow()==3)
        groupDialog = new TilesetGroupEditor(activeWldEditWin()->scene, this);
    else
        groupDialog = new TilesetGroupEditor(NULL, this);

    util::DialogToCenter(groupDialog);
    groupDialog->exec();
    delete groupDialog;

    configs.loadTilesets();
    setTileSetBox();
}
Exemplo n.º 23
0
void MainWindow::updateWindowsExtrasPixmap()
{
    if(QSysInfo::WindowsVersion<QSysInfo::WV_VISTA) return;
    QRect viewPort;

    if(!LastActiveSubWindow){
        drawWindowsDefaults();
        return;
    }

    if(activeChildWindow(LastActiveSubWindow) == 1){
        LevelEdit* edit = qobject_cast<LevelEdit*>(LastActiveSubWindow->widget());
        viewPort = edit->scene->getViewportRect();
    }else if(activeChildWindow(LastActiveSubWindow) == 3){
        WorldEdit* edit = qobject_cast<WorldEdit*>(LastActiveSubWindow->widget());
        viewPort = edit->scene->getViewportRect();
    }else{
        drawWindowsDefaults();
        return;
    }

    QPixmap thumbPixmap(viewPort.width(), viewPort.height());
    QPixmap livePreviewPixmap(size());
    QPainter thumbPainter(&thumbPixmap);
    QPainter livePreviewPainter(&livePreviewPixmap);

    if(activeChildWindow(LastActiveSubWindow) == 1){
        LevelEdit* edit = qobject_cast<LevelEdit*>(LastActiveSubWindow->widget());
        edit->scene->render(&thumbPainter, QRectF(0, 0, viewPort.width(), viewPort.height()), QRectF(viewPort));
        edit->scene->render(&livePreviewPainter, QRectF(0, 0, livePreviewPixmap.width(), livePreviewPixmap.height()), QRectF((qreal)viewPort.x(), (qreal)viewPort.y(), (qreal)livePreviewPixmap.width(), (qreal)livePreviewPixmap.height()));
    }else if(activeChildWindow(LastActiveSubWindow) == 3){
        WorldEdit* edit = qobject_cast<WorldEdit*>(LastActiveSubWindow->widget());
        edit->scene->render(&thumbPainter, QRectF(0, 0, viewPort.width(), viewPort.height()), QRectF(viewPort));
        edit->scene->render(&livePreviewPainter, QRectF(0, 0, livePreviewPixmap.width(), livePreviewPixmap.height()), QRectF((qreal)viewPort.x(), (qreal)viewPort.y(), (qreal)livePreviewPixmap.width(), (qreal)livePreviewPixmap.height()));
    }else{
        drawWindowsDefaults();
        return;
    }



    if(pge_thumbbar){
        pge_thumbbar->setIconicThumbnailPixmap(thumbPixmap);
        pge_thumbbar->setIconicLivePreviewPixmap(livePreviewPixmap);
    }
}
Exemplo n.º 24
0
void MainWindow::on_actionSelectOnly_triggered()
{
    resetEditmodeButtons();
    ui->actionSelectOnly->setChecked(1);

    ui->ItemProperties->hide();

    if ((activeChildWindow()==1) && (ui->actionSelectOnly->isChecked()))
    {
       activeLvlEditWin()->scene->SwitchEditingMode(LvlScene::MODE_SelectingOnly);
    }
    else
    if ((activeChildWindow()==3) && (ui->actionSelectOnly->isChecked()))
    {
       activeWldEditWin()->scene->SwitchEditingMode(WldScene::MODE_SelectingOnly);
    }
}
Exemplo n.º 25
0
void MainWindow::on_actionLockLevels_triggered(bool checked)
{
    if (activeChildWindow()==3)
    {
        WorldEdit *e=activeWldEditWin();
        if(e) e->scene->setLocked(4, checked);
    }
}
Exemplo n.º 26
0
void MainWindow::on_actionCollisions_triggered(bool checked)
{
    GlobalSettings::LvlOpts.collisionsEnabled = checked;
    if (activeChildWindow()==1)
    {
        activeLvlEditWin()->scene->opts.collisionsEnabled = GlobalSettings::LvlOpts.collisionsEnabled;
    }

}
Exemplo n.º 27
0
void MainWindow::on_actionAudioCvt_triggered()
{
    AudioCvt_Sox_gui sox_cvt(this);
    util::DialogToCenter(&sox_cvt, true);
    sox_cvt.exec();

    if(activeChildWindow()==1)
        dock_LvlSectionProps->refreshFileData();
}
Exemplo n.º 28
0
void MainWindow::on_actionGotoLeftBottom_triggered()
{
    if (activeChildWindow()==1)
    {
        LevelEdit* edit = activeLvlEditWin();
        if(!edit) return;
        int SectionId = edit->LvlData.CurSection;
        int xb = edit->LvlData.sections[SectionId].size_left;
        int yb = edit->LvlData.sections[SectionId].size_bottom -
                 edit->scene->_viewPort->viewport()->height() + 10;
        edit->goTo(xb, yb, false, QPoint(-10, 10));
    }
    else
    if (activeChildWindow()==3)
    {
        WorldEdit *e=activeWldEditWin();
        if(e) e->ResetPosition();
    }
}
Exemplo n.º 29
0
void MainWindow::on_actionShowGrid_triggered(bool checked)
{
    GlobalSettings::LvlOpts.grid_show = checked;
    if(activeChildWindow() == WND_Level)
    {
        LevelEdit *e = activeLvlEditWin();
        assert(e);
        e->scene->m_opts.grid_show = checked;
        e->scene->update();
    }
    else
    if(activeChildWindow() == WND_World)
    {
        WorldEdit *e = activeWldEditWin();
        assert(e);
        e->scene->m_opts.grid_show = checked;
        e->scene->update();
    }
}
Exemplo n.º 30
0
void MainWindow::on_actionSemi_transparent_paths_triggered(bool checked)
{
    GlobalSettings::LvlOpts.semiTransparentPaths = checked;
    if(activeChildWindow()==3)
    {
        activeWldEditWin()->scene->opts.semiTransparentPaths = GlobalSettings::LvlOpts.semiTransparentPaths;
        activeWldEditWin()->scene->setSemiTransparentPaths(GlobalSettings::LvlOpts.semiTransparentPaths);
    }

}