void LVL_ModeFill::mousePress(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);
    if( mouseEvent->buttons() & Qt::RightButton )
    {
        MainWinConnect::pMainWin->on_actionSelect_triggered();
        dontCallEvent = true;
        s->IsMoved = true;
        return;
    }
    if(! mouseEvent->buttons() & Qt::LeftButton)
        return;

    if(s->cursor)
    {
        attemptFlood(s);
        s->Debugger_updateItemList();
    }

}
void LVL_ModePlace::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();
    }
    if( mouseEvent->buttons() & Qt::LeftButton )
    {
        s->placeItemUnderCursor();
        s->Debugger_updateItemList();
    }
}
void LVL_ModePlace::mousePress(QGraphicsSceneMouseEvent *mouseEvent)
{
    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    if( mouseEvent->buttons() & Qt::RightButton )
    {
        item_rectangles::clearArray();
        MainWinConnect::pMainWin->on_actionSelect_triggered();
        dontCallEvent = true;
        s->IsMoved = true;
        return;
    }

    s->last_block_arrayID=s->LvlData->blocks_array_id;
    s->last_bgo_arrayID=s->LvlData->bgo_array_id;
    s->last_npc_arrayID=s->LvlData->npc_array_id;

    if(LvlPlacingItems::npcSpecialAutoIncrement)
        s->IncrementingNpcSpecialSpin = LvlPlacingItems::npcSpecialAutoIncrement_begin;

    if(s->cursor)
    {
        s->cursor->setPos( QPointF(s->applyGrid( mouseEvent->scenePos().toPoint()-
                                           QPoint(LvlPlacingItems::c_offset_x,
                                                  LvlPlacingItems::c_offset_y),
                                           LvlPlacingItems::gridSz,
                                           LvlPlacingItems::gridOffset)));
    }

    s->placeItemUnderCursor();
    s->Debugger_updateItemList();

    s->MousePressEventOnly = true;
    s->mousePressEvent(mouseEvent);
    dontCallEvent = true;
}
Exemple #4
0
void LVL_ModeCircle::mouseRelease(QGraphicsSceneMouseEvent *mouseEvent)
{
    Q_UNUSED(mouseEvent);

    if(!scene) return;
    LvlScene *s = dynamic_cast<LvlScene *>(scene);

    if(s->m_cursorItemImg)
    {
        QGraphicsEllipseItem * cur = dynamic_cast<QGraphicsEllipseItem *>(s->m_cursorItemImg);

        // /////////// Don't draw with zero width or height //////////////
        if( (cur->rect().width()==0) || (cur->rect().height()==0))
        {
            s->m_cursorItemImg->hide();
            dontCallEvent = true;
            return;
        }
        // ///////////////////////////////////////////////////////////////

        if( ((s->m_placingItemType==LvlScene::PLC_Block)&&(!LvlPlacingItems::sizableBlock))||
                (s->m_placingItemType==LvlScene::PLC_BGO))
        {
            item_rectangles::drawRound(s, QRect(cur->x(), cur->y(), cur->rect().width(), cur->rect().height()),
                                                QSize(LvlPlacingItems::itemW, LvlPlacingItems::itemH) );
        }

        switch(s->m_placingItemType)
        {
        case LvlScene::PLC_Block:
            {
                //LvlPlacingItems::waterSet.quicksand = (LvlPlacingItems::waterType==1);
                if(LvlPlacingItems::sizableBlock)
                {
                    LvlPlacingItems::blockSet.x = s->m_cursorItemImg->scenePos().x();
                    LvlPlacingItems::blockSet.y = s->m_cursorItemImg->scenePos().y();
                    LvlPlacingItems::blockSet.w = cur->rect().width();
                    LvlPlacingItems::blockSet.h = cur->rect().height();
                    //here define placing water item.
                    s->m_data->blocks_array_id++;

                    LvlPlacingItems::blockSet.meta.array_id = s->m_data->blocks_array_id;
                    s->m_data->blocks.push_back(LvlPlacingItems::blockSet);

                    s->placeBlock(LvlPlacingItems::blockSet, true);
                    LevelData plSzBlock;
                    plSzBlock.blocks.push_back(LvlPlacingItems::blockSet);
                    s->m_history->addPlace(plSzBlock);
                    s->Debugger_updateItemList();
                    break;
                }
                else
                {
                    s->placeItemsByRectArray();
                    //LogDebug("clear collision buffer");
                    s->m_emptyCollisionCheck = false;
                    s->collisionCheckBuffer.clear();
                    #ifdef _DEBUG_
                    LogDebug("Done");
                    #endif
                    s->Debugger_updateItemList();
                    break;
                }
            }
        case LvlScene::PLC_BGO:
            {
                s->placeItemsByRectArray();

                s->m_emptyCollisionCheck = false;
                s->collisionCheckBuffer.clear();

                s->Debugger_updateItemList();
             break;
            }
        }
        s->m_data->meta.modified = true;

        s->m_cursorItemImg->hide();
    }
}