From edde8bec0771fa7eeb9ff5186d7229dda18b2469 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Sat, 3 Dec 2011 20:20:43 -0500 Subject: [PATCH 1/3] Add Planeswalker loyalty to CardInfoWidget CIW will also dynamically hide/show power/toughness as well as loyalty. --- cockatrice/src/cardinfowidget.cpp | 31 ++++++++++++++++++++++++++++--- cockatrice/src/cardinfowidget.h | 5 +++++ 2 files changed, 33 insertions(+), 3 deletions(-) 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); From 4fbd6e0a9f3fe8d6e5c62c725b8604dcafe37f53 Mon Sep 17 00:00:00 2001 From: Daenyth Date: Sat, 3 Dec 2011 20:29:58 -0500 Subject: [PATCH 2/3] .gitignore: Ignore ctags * translation build files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..616ad480 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tags +*.qm From 1dd7695e9a12fe6576d0462137fcc258b04d687f Mon Sep 17 00:00:00 2001 From: Daenyth Date: Thu, 15 Dec 2011 18:01:23 -0500 Subject: [PATCH 3/3] Make games created reg-only by default. --- cockatrice/src/dlg_creategame.cpp | 1 + 1 file changed, 1 insertion(+) 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);