diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..616ad480 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tags +*.qm diff --git a/cockatrice/src/cardinfowidget.cpp b/cockatrice/src/cardinfowidget.cpp index 19873363..3a234806 100644 --- a/cockatrice/src/cardinfowidget.cpp +++ b/cockatrice/src/cardinfowidget.cpp @@ -43,6 +43,8 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag cardtypeLabel2->setWordWrap(true); powtoughLabel1 = new QLabel; powtoughLabel2 = new QLabel; + loyaltyLabel1 = new QLabel; + loyaltyLabel2 = new QLabel; textLabel = new QTextEdit(); textLabel->setReadOnly(true); @@ -60,6 +62,8 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag grid->addWidget(cardtypeLabel2, row++, 1); grid->addWidget(powtoughLabel1, row, 0); grid->addWidget(powtoughLabel2, row++, 1); + grid->addWidget(loyaltyLabel1, row, 0); + grid->addWidget(loyaltyLabel2, row++, 1); grid->addWidget(textLabel, row, 0, -1, 2); grid->setRowStretch(row, 1); grid->setColumnStretch(1, 1); @@ -86,12 +90,24 @@ void CardInfoWidget::minimizeClicked(int newMinimized) settingsCache->setCardInfoMinimized(newMinimized); } +bool CardInfoWidget::shouldShowPowTough() +{ + return (!info->getPowTough().isEmpty()); +} + +bool CardInfoWidget::shouldShowLoyalty() +{ + return (info->getMainCardType() == "Planeswalker"); +} + void CardInfoWidget::setMinimized(int _minimized) { minimized = _minimized; // Toggle oracle fields according to selected view. bool showAll = ((minimized == 1) || (minimized == 2)); + bool showPowTough = showAll && shouldShowPowTough(); + bool showLoyalty = showAll && shouldShowLoyalty(); if (mode == ModeGameTab) { nameLabel1->setVisible(showAll); nameLabel2->setVisible(showAll); @@ -99,8 +115,10 @@ void CardInfoWidget::setMinimized(int _minimized) manacostLabel2->setVisible(showAll); cardtypeLabel1->setVisible(showAll); cardtypeLabel2->setVisible(showAll); - powtoughLabel1->setVisible(showAll); - powtoughLabel2->setVisible(showAll); + powtoughLabel1->setVisible(showPowTough); + powtoughLabel2->setVisible(showPowTough); + loyaltyLabel1->setVisible(showLoyalty); + loyaltyLabel2->setVisible(showLoyalty); textLabel->setVisible(showAll); } @@ -133,7 +151,13 @@ void CardInfoWidget::setCard(CardInfo *card) manacostLabel2->setText(card->getManaCost()); cardtypeLabel2->setText(card->getCardType()); powtoughLabel2->setText(card->getPowTough()); + loyaltyLabel2->setText(QString::number(card->getLoyalty())); textLabel->setText(card->getText()); + + powtoughLabel1->setVisible(shouldShowPowTough()); + powtoughLabel2->setVisible(shouldShowPowTough()); + loyaltyLabel1->setVisible(shouldShowLoyalty()); + loyaltyLabel2->setVisible(shouldShowLoyalty()); } void CardInfoWidget::setCard(const QString &cardName) @@ -166,6 +190,7 @@ void CardInfoWidget::retranslateUi() manacostLabel1->setText(tr("Mana cost:")); cardtypeLabel1->setText(tr("Card type:")); powtoughLabel1->setText(tr("P / T:")); + loyaltyLabel1->setText(tr("Loyalty:")); } void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/) @@ -180,4 +205,4 @@ void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/) QString CardInfoWidget::getCardName() const { return nameLabel2->text(); -} \ No newline at end of file +} diff --git a/cockatrice/src/cardinfowidget.h b/cockatrice/src/cardinfowidget.h index 7ceab5dc..bb68bf46 100644 --- a/cockatrice/src/cardinfowidget.h +++ b/cockatrice/src/cardinfowidget.h @@ -23,6 +23,7 @@ private: int pixmapWidth; qreal cardHeightOffset; qreal aspectRatio; + // XXX: Why isn't this an eunm? int minimized; // 0 - card, 1 - oracle only, 2 - full ResizeMode mode; @@ -32,8 +33,12 @@ private: QLabel *manacostLabel1, *manacostLabel2; QLabel *cardtypeLabel1, *cardtypeLabel2; QLabel *powtoughLabel1, *powtoughLabel2; + QLabel *loyaltyLabel1, *loyaltyLabel2; QTextEdit *textLabel; + bool shouldShowPowTough(); + bool shouldShowLoyalty(); + CardInfo *info; void setMinimized(int _minimized); diff --git a/cockatrice/src/dlg_creategame.cpp b/cockatrice/src/dlg_creategame.cpp index 0d5b69f4..4e9c6397 100644 --- a/cockatrice/src/dlg_creategame.cpp +++ b/cockatrice/src/dlg_creategame.cpp @@ -49,6 +49,7 @@ DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMapsetChecked(true); QGridLayout *joinRestrictionsLayout = new QGridLayout; joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);