Commit 611544b8 authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

bounds checking for card movement

parent 2fbfddf8
...@@ -81,8 +81,7 @@ void LibraryZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -81,8 +81,7 @@ void LibraryZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
} }
void LibraryZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void LibraryZone::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
{ {
Q_UNUSED(event);
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
} }
...@@ -14,10 +14,8 @@ QRectF TableZone::boundingRect() const ...@@ -14,10 +14,8 @@ QRectF TableZone::boundingRect() const
return QRectF(0, 0, width, height); return QRectF(0, 0, width, height);
} }
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{ {
Q_UNUSED(option);
Q_UNUSED(widget);
painter->fillRect(boundingRect(), QColor(0, 0, 100)); painter->fillRect(boundingRect(), QColor(0, 0, 100));
} }
...@@ -38,7 +36,17 @@ void TableZone::addCardImpl(CardItem *card, int x, int y) ...@@ -38,7 +36,17 @@ void TableZone::addCardImpl(CardItem *card, int x, int y)
void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown) void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
{ {
player->client->moveCard(cardId, startZone->getName(), getName(), dropPoint.x(), dropPoint.y(), faceDown); int x = dropPoint.x();
int y = dropPoint.y();
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (x > width - CARD_WIDTH)
x = width - CARD_WIDTH;
if (y > height - CARD_HEIGHT)
y = height - CARD_HEIGHT;
player->client->moveCard(cardId, startZone->getName(), getName(), x, y, faceDown);
} }
void TableZone::reorganizeCards() void TableZone::reorganizeCards()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment