Expose related cards in card menu

This commit is contained in:
Fabio Bas 2015-06-11 12:45:25 +02:00
parent da84bb33e1
commit 946598375f
2 changed files with 32 additions and 1 deletions

View file

@ -676,7 +676,7 @@ void Player::retranslateUi()
for (int i = 0; i < allPlayersActions.size(); ++i)
allPlayersActions[i]->setText(tr("&All players"));
}
aPlay->setText(tr("&Play"));
aHide->setText(tr("&Hide"));
aPlayFacedown->setText(tr("Play &Face Down"));
@ -1076,6 +1076,25 @@ void Player::actCreatePredefinedToken()
actCreateAnotherToken();
}
void Player::actCreateRelatedCard()
{
// get he target card name
QAction *action = static_cast<QAction *>(sender());
CardInfo *cardInfo = db->getCard(action->text());
// create the token for the related card
Command_CreateToken cmd;
cmd.set_zone("table");
cmd.set_card_name(cardInfo->getName().toStdString());
cmd.set_color(cardInfo->getColors().isEmpty() ? QString().toStdString() : cardInfo->getColors().first().toLower().toStdString());
cmd.set_pt(cardInfo->getPowTough().toStdString());
cmd.set_destroy_on_zone_change(true);
cmd.set_x(-1);
cmd.set_y(0);
sendGameCommand(cmd);
}
void Player::actSayMessage()
{
QAction *a = qobject_cast<QAction *>(sender());
@ -2247,6 +2266,17 @@ void Player::updateCardMenu(CardItem *card)
cardMenu->addAction(aFlip);
if (card->getFaceDown())
cardMenu->addAction(aPeek);
QStringList relatedCards = card->getInfo()->getRelatedCards();
if(relatedCards.size())
{
QMenu * createRelatedCardMenu = cardMenu->addMenu(tr("Cr&eate related card"));
for (int i = 0; i < relatedCards.size(); ++i) {
QAction *a = createRelatedCardMenu->addAction(relatedCards.at(i));
connect(a, SIGNAL(triggered()), this, SLOT(actCreateRelatedCard()));
}
}
cardMenu->addSeparator();
cardMenu->addAction(aAttach);
if (card->getAttachedTo())

View file

@ -141,6 +141,7 @@ private slots:
void actOpenDeckInDeckEditor();
void actCreatePredefinedToken();
void actCreateRelatedCard();
void cardMenuAction();
void actCardCounterTrigger();
void actAttach();