removed unnecessary repaint when destroying token

This commit is contained in:
Max-Wilhelm Bruker 2010-10-27 19:54:48 +02:00
parent 51f9f34e8b
commit a029994437
5 changed files with 15 additions and 11 deletions

View file

@ -129,7 +129,7 @@ CardItem *CardZone::getCard(int cardId, const QString &cardName)
return c;
}
CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName, bool /*canResize*/)
CardItem *CardZone::takeCard(int position, int cardId, bool /*canResize*/)
{
if (position == -1) {
// position == -1 means either that the zone is indexed by card id
@ -151,7 +151,6 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
view->removeCard(position);
c->setId(cardId);
c->setName(cardName);
reorganizeCards();
emit cardCountChanged();

View file

@ -52,7 +52,7 @@ public:
// getCard() finds a card by id.
CardItem *getCard(int cardId, const QString &cardName);
// takeCard() finds a card by position and removes it from the zone and from all of its views.
virtual CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
virtual CardItem *takeCard(int position, int cardId, bool canResize = true);
ZoneViewZone *getView() const { return view; }
void setView(ZoneViewZone *_view) { view = _view; }
virtual void reorganizeCards() = 0;

View file

@ -696,9 +696,10 @@ void Player::eventMoveCard(Event_MoveCard *event)
int logX = x;
if (x == -1)
x = 0;
CardItem *card = startZone->takeCard(position, event->getCardId(), event->getCardName(), startZone != targetZone);
CardItem *card = startZone->takeCard(position, event->getCardId(), startZone != targetZone);
if (!card)
return;
card->setName(event->getCardName());
if (card->getAttachedTo() && (startZone != targetZone))
card->setAttachedTo(0);
@ -761,7 +762,7 @@ void Player::eventDestroyCard(Event_DestroyCard *event)
return;
emit logDestroyCard(this, card->getName());
zone->takeCard(-1, event->getCardId(), QString(), true);
zone->takeCard(-1, event->getCardId(), true);
card->deleteLater();
}
@ -813,11 +814,15 @@ void Player::eventDrawCards(Event_DrawCards *event)
CardZone *hand = zones.value("hand");
const QList<ServerInfo_Card *> &cardList = event->getCardList();
if (!cardList.isEmpty())
for (int i = 0; i < cardList.size(); ++i)
hand->addCard(deck->takeCard(0, cardList[i]->getId(), cardList[i]->getName()), false, -1);
for (int i = 0; i < cardList.size(); ++i) {
CardItem *card = deck->takeCard(0, cardList[i]->getId());
card->setName(cardList[i]->getName());
hand->addCard(card, false, -1);
}
else
for (int i = 0; i < event->getNumberCards(); ++i)
hand->addCard(deck->takeCard(0, -1, QString()), false, -1);
hand->addCard(deck->takeCard(0, -1), false, -1);
hand->reorganizeCards();
deck->reorganizeCards();

View file

@ -174,9 +174,9 @@ void TableZone::toggleTapped()
player->sendCommandContainer(new CommandContainer(cmdList));
}
CardItem *TableZone::takeCard(int position, int cardId, const QString &cardName, bool canResize)
CardItem *TableZone::takeCard(int position, int cardId, bool canResize)
{
CardItem *result = CardZone::takeCard(position, cardId, cardName);
CardItem *result = CardZone::takeCard(position, cardId);
if (canResize)
resizeToContents();
return result;

View file

@ -35,7 +35,7 @@ public:
QPointF mapFromGrid(const QPoint &gridPoint) const;
QPoint mapToGrid(const QPointF &mapPoint) const;
QPointF closestGridPoint(const QPointF &point);
CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
CardItem *takeCard(int position, int cardId, bool canResize = true);
void resizeToContents();
int getMinimumWidth() const { return currentMinimumWidth; }
void setWidth(qreal _width);