From 55e7feeebe34b1ba7c92e862e50d2b25abeb0fb2 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Tue, 9 Nov 2010 17:11:13 +0100 Subject: [PATCH] fix --- cockatrice/src/gamescene.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/cockatrice/src/gamescene.cpp b/cockatrice/src/gamescene.cpp index 17100533..8225ffc5 100644 --- a/cockatrice/src/gamescene.cpp +++ b/cockatrice/src/gamescene.cpp @@ -153,21 +153,31 @@ bool GameScene::event(QEvent *event) } QList itemList = items(mouseEvent->scenePos()); - qreal maxZ = 0; - CardItem *maxZCard = 0; - QList cardList; - for (int i = 0; i < itemList.size(); ++i) { - CardItem *card = qgraphicsitem_cast(itemList[i]); - if (!card) - continue; - cardList.append(card); - if (card->getRealZValue() > maxZ) { - maxZ = card->getRealZValue(); - maxZCard = card; + + // Search for the topmost zone and ignore all cards not belonging to that zone. + CardZone *zone = 0; + for (int i = 0; i < itemList.size(); ++i) + if ((zone = qgraphicsitem_cast(itemList[i]))) + break; + if (zone) { + qreal maxZ = -1; + CardItem *maxZCard = 0; + QList cardList; + for (int i = 0; i < itemList.size(); ++i) { + CardItem *card = qgraphicsitem_cast(itemList[i]); + if (!card) + continue; + if (card->getZone() != zone) + continue; + cardList.append(card); + if (card->getRealZValue() > maxZ) { + maxZ = card->getRealZValue(); + maxZCard = card; + } } + for (int i = 0; i < cardList.size(); ++i) + cardList[i]->setZValue(cardList[i] == maxZCard ? 2000000004 : cardList[i]->getRealZValue()); } - for (int i = 0; i < cardList.size(); ++i) - cardList[i]->setZValue(cardList[i] == maxZCard ? 2000000004 : cardList[i]->getRealZValue()); } return QGraphicsScene::event(event); }