Esempio n. 1
0
//------------------------------------------------------------------------------//
void InventoryReceiver::onDragDropItemDropped(DragDropEventArgs &e)
{
    InventoryItem* item = dynamic_cast<InventoryItem*>(e.dragDropItem);

    if (!item)
        return;

    const Sizef square_size(squarePixelSize());

    Rectf item_area(item->getUnclippedOuterRect().get());
    item_area.offset(Vector2f(square_size.d_width / 2, square_size.d_height / 2));

    const int drop_x = gridXLocationFromPixelPosition(item_area.left());
    const int drop_y = gridYLocationFromPixelPosition(item_area.top());

    addItemAtLocation(*item, drop_x, drop_y);
}