void Dashboard::addCardItem(CardItem *card_item){ card_item->filter(filter); if(ClientInstance->getStatus() == Client::Playing) card_item->setEnabled(card_item->getFilteredCard()->isAvailable(Self)); else{ card_item->setEnabled(true); card_item->setEnabled(false); } card_item->setPos(mapFromScene(card_item->pos())); card_item->setParentItem(this); card_item->setRotation(0.0); card_item->setFlags(ItemIsFocusable); card_item->setZValue(0.1); card_items << card_item; connect(card_item, SIGNAL(clicked()), this, SLOT(onCardItemClicked())); connect(card_item, SIGNAL(thrown()), this, SLOT(onCardItemThrown())); connect(card_item, SIGNAL(enter_hover()), this, SLOT(onCardItemHover())); connect(card_item, SIGNAL(leave_hover()), this, SLOT(onCardItemLeaveHover())); sortCards(sort_type); handcard_num->setText(QString::number(Self->getHandcardNum())); //handcard_num->parentItem()->show(); }
void ChooseGeneralBox::chooseGeneral(QStringList generals) { //嶷仟紙崙嘘尚 if (generals.contains("anjiang(lord)")) generals.removeAll("anjiang(lord)"); general_number = generals.length(); update(); items.clear(); selected.clear(); foreach(QString general, generals) { if (general.endsWith("(lord)")) continue; GeneralCardItem *general_item = new GeneralCardItem(general); general_item->setFlag(QGraphicsItem::ItemIsFocusable); if (single_result) general_item->setFlag(QGraphicsItem::ItemIsMovable, false); else { general_item->setAutoBack(true); connect(general_item, SIGNAL(released()), this, SLOT(_adjust())); } connect(general_item, SIGNAL(clicked()), this, SLOT(_onItemClicked())); connect(general_item, SIGNAL(enter_hover()), this, SLOT(_onCardItemHover())); connect(general_item, SIGNAL(leave_hover()), this, SLOT(_onCardItemLeaveHover())); connect(general_item, SIGNAL(general_changed()), this, SLOT(adjustItems())); if (!single_result) { const General *hero = Sanguosha->getGeneral(general); foreach (QString other, generals) { if (other.endsWith("(lord)")) continue; if (general != other && hero->isCompanionWith(other)) { general_item->showCompanion(); break; } } } items << general_item; general_item->setParentItem(this); } setPos(RoomSceneInstance->tableCenterPos() - QPointF(boundingRect().width() / 2, boundingRect().height() / 2)); show(); int card_width = G_COMMON_LAYOUT.m_cardNormalWidth; int card_height = G_COMMON_LAYOUT.m_cardNormalHeight; int first_row = (general_number < 6) ? general_number : ((general_number + 1) / 2); for (int i = 0; i < items.length(); ++ i) { GeneralCardItem *card_item = items.at(i); QPointF pos; if (i < first_row) { pos.setX(left_blank_width + (card_width + card_to_center_line) * i + card_width / 2); pos.setY(top_blank_width + card_height / 2); } else { if (items.length() % 2 == 1) pos.setX(left_blank_width + card_width / 2 + card_to_center_line / 2 + (card_width + card_to_center_line) * (i - first_row) + card_width / 2); else pos.setX(left_blank_width + (card_width + card_to_center_line) * (i - first_row) + card_width / 2); pos.setY(top_blank_width + card_height + card_to_center_line + card_height / 2); } card_item->setPos(25, 45); if (!single_result) //委厘社優廖峽贋和栖�契峭指音栖 card_item->setData(S_DATA_INITIAL_HOME_POS, pos); card_item->setHomePos(pos); card_item->goBack(true); } if (single_result) confirm->hide(); else { confirm->setPos(boundingRect().center().x() - confirm->boundingRect().width() / 2, boundingRect().height() - 60); confirm->show(); } _initializeItems(); if (ServerInfo.OperationTimeout != 0) { if (!progress_bar) { progress_bar = new QSanCommandProgressBar(); progress_bar->setMinimumWidth(200); progress_bar->setMaximumHeight(12); progress_bar->setTimerEnabled(true); progress_bar_item = new QGraphicsProxyWidget(this); progress_bar_item->setWidget(progress_bar); progress_bar_item->setPos(boundingRect().center().x() - progress_bar_item->boundingRect().width() / 2, boundingRect().height() - 30); connect(progress_bar, SIGNAL(timedOut()), this, SLOT(reply())); } progress_bar->setCountdown(QSanProtocol::S_COMMAND_CHOOSE_GENERAL); progress_bar->show(); } }