Пример #1
0
void LVL_ModeFill::mouseMove(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    s->clearSelection();

    if((!LvlPlacingItems::layer.isEmpty() && LvlPlacingItems::layer!="Default")||
         (mouseEvent->modifiers() & Qt::ControlModifier) )
        s->setMessageBoxItem(true, mouseEvent->scenePos(),
         ((!LvlPlacingItems::layer.isEmpty() && LvlPlacingItems::layer!="Default")?
            LvlPlacingItems::layer + ", ":"") +
                                   (s->cursor?
                                        (
                                   QString::number( s->cursor->scenePos().toPoint().x() ) + "x" +
                                   QString::number( s->cursor->scenePos().toPoint().y() )
                                        )
                                            :"")
                                   );
    else
        s->setMessageBoxItem(false);

    if(s->cursor)
    {
               s->cursor->setPos( QPointF(s->applyGrid( QPointF(mouseEvent->scenePos()-
                                                   QPointF(LvlPlacingItems::c_offset_x,
                                                          LvlPlacingItems::c_offset_y)).toPoint(),
                                                 LvlPlacingItems::gridSz,
                                                 LvlPlacingItems::gridOffset)));
               s->cursor->show();
    }
}
void LVL_ModeResize::mouseMove(QGraphicsSceneMouseEvent *mouseEvent)
{
    Q_UNUSED(mouseEvent);
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);
    s->clearSelection();

    s->m_skipChildMouseMoveEvent = true;
    s->mouseMoveEvent(mouseEvent);
    dontCallEvent = true;
}
void LVL_ModeResize::set()
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    s->clearSelection();
    s->resetCursor();

    s->m_eraserIsEnabled=false;
    s->m_pastingMode=false;
    s->m_busyMode=true;
    s->m_disableMoveItems=true;

    s->m_viewPort->setInteractive(true);
    s->m_viewPort->setCursor(Themes::Cursor(Themes::cursor_resizing));
    s->m_viewPort->setDragMode(QGraphicsView::NoDrag);
}
Пример #4
0
void LVL_ModeResize::set()
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    s->EraserEnabled=false;
    s->PasteFromBuffer=false;
    s->DrawMode=true;
    s->disableMoveItems=true;

    s->clearSelection();
    s->resetCursor();

    s->_viewPort->setInteractive(true);
    s->_viewPort->setCursor(Themes::Cursor(Themes::cursor_resizing));
    s->_viewPort->setDragMode(QGraphicsView::NoDrag);
}
Пример #5
0
void LVL_ModePlace::set()
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    s->EraserEnabled=false;
    s->PasteFromBuffer=false;
    s->DrawMode=true;
    s->disableMoveItems=false;

    s->clearSelection();
    s->resetResizers();

    s->_viewPort->setInteractive(true);
    s->_viewPort->setCursor(Themes::Cursor(Themes::cursor_placing));
    s->_viewPort->setDragMode(QGraphicsView::NoDrag);
    s->_viewPort->setRenderHint(QPainter::Antialiasing, true);
    s->_viewPort->viewport()->setMouseTracking(true);
}
Пример #6
0
void LVL_ModeCircle::set()
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    s->clearSelection();
    s->resetResizers();

    s->m_eraserIsEnabled=false;
    s->m_pastingMode=false;
    s->m_busyMode=true;
    s->m_disableMoveItems=false;

    s->m_viewPort->setInteractive(true);
    s->m_viewPort->setCursor(Themes::Cursor(Themes::cursor_square_fill));
    s->m_viewPort->setDragMode(QGraphicsView::NoDrag);
    s->m_viewPort->setRenderHint(QPainter::Antialiasing, true);
    s->m_viewPort->viewport()->setMouseTracking(true);
}
void MainWindow::on_actionClear_NPC_garbadge_triggered()
{
    if(activeChildWindow() != WND_Level) return;
    LevelEdit *box = activeLvlEditWin();
    if(!box) return;
    if(!box->sceneCreated) return;

    QList<LevelNPC> _fine_npcs;
    QList<LevelNPC> _found_garbage;
    for(int i = 0; i < box->LvlData.npc.size(); i++)
    {
        LevelNPC npc = box->LvlData.npc[i];
        bool fine = true;
        for(int j = 0; j < _fine_npcs.size(); j++)
        {
            if(npc.id != _fine_npcs[j].id) continue;
            if(npc.x != _fine_npcs[j].x) continue;
            if(npc.y != _fine_npcs[j].y) continue;
            if(npc.layer != _fine_npcs[j].layer) continue;
            if(npc.generator != _fine_npcs[j].generator) continue;
            if(npc.msg != _fine_npcs[j].msg) continue;
            if(npc.event_activate != _fine_npcs[j].event_activate) continue;
            if(npc.event_die != _fine_npcs[j].event_die) continue;
            if(npc.event_talk != _fine_npcs[j].event_talk) continue;
            if(npc.event_emptylayer != _fine_npcs[j].event_emptylayer) continue;

            fine = false;
            _found_garbage.push_back(npc);
            break;
        }
        if(fine) _fine_npcs.push_back(npc);
    }

    if(_found_garbage.isEmpty())
        QMessageBox::information(this, tr("NPC garbage clean-up"), tr("Everything is fine, level has no NPC garbage!"), QMessageBox::Ok);
    else
    {
        QMessageBox::StandardButton x = QMessageBox::question(this, tr("NPC garbage clean-up"), tr("Found %1 junk NPC's. Do you want to remove them?\nPress \"Help\" to show info about the junk NPCs we found.").arg(_found_garbage.size()), QMessageBox::Yes | QMessageBox::No | QMessageBox::Help);
        if((x != QMessageBox::Yes) && (x != QMessageBox::Help)) return;
        bool help = (x == QMessageBox::Help);
        LvlScene *sc = box->scene;
        sc->clearSelection();
        LvlScene::PGE_ItemList items = sc->items();
        LevelData removedItems;
        QPointF jumpTo;

        for(int i = 0; i < items.size(); i++)
        {
            if(items[i]->data(ITEM_TYPE).toString() == "NPC")
            {
                ItemNPC *npc = qgraphicsitem_cast<ItemNPC *>(items[i]);
                if(!npc) continue;
                for(int j = 0; j < _found_garbage.size(); j++)
                {
                    if(npc->m_data.meta.array_id == _found_garbage[j].meta.array_id)
                    {
                        if(help) //Select & jump
                        {
                            npc->setSelected(true);
                            jumpTo = npc->scenePos();
                        }
                        else     //Delete actual NPC
                        {
                            removedItems.npc.push_back(npc->m_data);
                            npc->removeFromArray();
                            delete npc;
                        }
                        break;
                    }
                }
            }
        }

        if(!help)
        {
            if(!removedItems.npc.isEmpty())
                sc->m_history->addRemove(removedItems);
            QMessageBox::information(this, tr("NPC garbage clean-up"), tr("NPC garbabe has been removed!\nThis operation can be undone with Ctrl+Z or Edit/Undo action."), QMessageBox::Ok);
        }
        else
        {
            box->goTo(jumpTo.x(), jumpTo.y(), true, QPoint(0, 0), true);
        }
    }
}