bool DiscardPile::_addCardItems(QList<CardItem*> &card_items, Player::Place place) { _m_mutex_pileCards.lock(); m_visibleCards.append(card_items); int numAdded = card_items.size(); int numRemoved = m_visibleCards.size() - qMax(m_numCardsVisible, numAdded + 1); for (int i = 0; i < numRemoved; i++) { CardItem* toRemove = m_visibleCards.first(); toRemove->setZValue(0.0); toRemove->setHomeOpacity(0.0); connect(toRemove, SIGNAL(movement_animation_finished()), this, SLOT(_destroyCard())); toRemove->goBack(true); m_visibleCards.removeFirst(); } foreach (CardItem* card_item, m_visibleCards) { card_item->setHomeOpacity(0.7); }
void PindianBox::doPindian(const QString &requestor, const QString &reason, const QStringList &targets) { _m_mutex_pindian.lock(); zhuge = requestor; this->targets = targets; this->reason = reason; upItems.clear(); downItems.clear(); scene_width = RoomSceneInstance->sceneRect().width(); for (int i = 1; i <= targets.length(); i++) { card_ids << -1; CardItem *cardItem = new CardItem(Sanguosha->getCard(-1)); cardItem->setFlag(QGraphicsItem::ItemIsFocusable); cardItem->setFlag(ItemIsMovable, false); cardItem->setAutoBack(false); upItems << cardItem; cardItem->setParentItem(this); } CardItem *card = new CardItem(Sanguosha->getCard(-1)); card->setFlag(QGraphicsItem::ItemIsFocusable); card->setFlag(ItemIsMovable, false); card->setAutoBack(false); card->setParentItem(this); downItems << card; itemCount = upItems.length(); int cardWidth = G_COMMON_LAYOUT.m_cardNormalWidth; int cardHeight = G_COMMON_LAYOUT.m_cardNormalHeight; int count = (itemCount >= 2) ? itemCount : 2; int width = (cardWidth + cardInterval + 20) * count - cardInterval + 50; this->width = width; int first = (width - targets.length() * cardWidth - (targets.length() - 1) * (cardInterval + 20)) / 2; for (int i = 0; i < upItems.length(); i++) { CardItem *cardItem = upItems.at(i); QPointF pos; int X, Y; X = first + (cardWidth + cardInterval + 20) * i; Y = 45; pos.setX(X); pos.setY(Y); cardItem->resetTransform(); cardItem->setOuterGlowEffectEnabled(true); cardItem->setPos(pos); cardItem->setHomePos(pos); cardItem->goBack(true); cardItem->hide(); } QPointF pos; pos.setX((width - cardWidth) / 2); pos.setY(45 + cardHeight + cardInterval); card->resetTransform(); card->setOuterGlowEffectEnabled(true); card->setPos(pos); card->setHomePos(pos); card->goBack(true); card->hide(); prepareGeometryChange(); GraphicsBox::moveToCenter(this); show(); _m_mutex_pindian.unlock(); }