Merge branch 'master' of git://github.com/mbruker/Cockatrice

This commit is contained in:
Max-Wilhelm Bruker 2012-01-29 16:56:50 +01:00
commit ccfdc0a084
4 changed files with 35 additions and 2 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
tags
*.qm

View file

@ -43,6 +43,8 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag
cardtypeLabel2->setWordWrap(true); cardtypeLabel2->setWordWrap(true);
powtoughLabel1 = new QLabel; powtoughLabel1 = new QLabel;
powtoughLabel2 = new QLabel; powtoughLabel2 = new QLabel;
loyaltyLabel1 = new QLabel;
loyaltyLabel2 = new QLabel;
textLabel = new QTextEdit(); textLabel = new QTextEdit();
textLabel->setReadOnly(true); textLabel->setReadOnly(true);
@ -60,6 +62,8 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, QWidget *parent, Qt::WindowFlag
grid->addWidget(cardtypeLabel2, row++, 1); grid->addWidget(cardtypeLabel2, row++, 1);
grid->addWidget(powtoughLabel1, row, 0); grid->addWidget(powtoughLabel1, row, 0);
grid->addWidget(powtoughLabel2, row++, 1); grid->addWidget(powtoughLabel2, row++, 1);
grid->addWidget(loyaltyLabel1, row, 0);
grid->addWidget(loyaltyLabel2, row++, 1);
grid->addWidget(textLabel, row, 0, -1, 2); grid->addWidget(textLabel, row, 0, -1, 2);
grid->setRowStretch(row, 1); grid->setRowStretch(row, 1);
grid->setColumnStretch(1, 1); grid->setColumnStretch(1, 1);
@ -86,12 +90,24 @@ void CardInfoWidget::minimizeClicked(int newMinimized)
settingsCache->setCardInfoMinimized(newMinimized); settingsCache->setCardInfoMinimized(newMinimized);
} }
bool CardInfoWidget::shouldShowPowTough()
{
return (!info->getPowTough().isEmpty());
}
bool CardInfoWidget::shouldShowLoyalty()
{
return (info->getMainCardType() == "Planeswalker");
}
void CardInfoWidget::setMinimized(int _minimized) void CardInfoWidget::setMinimized(int _minimized)
{ {
minimized = _minimized; minimized = _minimized;
// Toggle oracle fields according to selected view. // Toggle oracle fields according to selected view.
bool showAll = ((minimized == 1) || (minimized == 2)); bool showAll = ((minimized == 1) || (minimized == 2));
bool showPowTough = showAll && shouldShowPowTough();
bool showLoyalty = showAll && shouldShowLoyalty();
if (mode == ModeGameTab) { if (mode == ModeGameTab) {
nameLabel1->setVisible(showAll); nameLabel1->setVisible(showAll);
nameLabel2->setVisible(showAll); nameLabel2->setVisible(showAll);
@ -99,8 +115,10 @@ void CardInfoWidget::setMinimized(int _minimized)
manacostLabel2->setVisible(showAll); manacostLabel2->setVisible(showAll);
cardtypeLabel1->setVisible(showAll); cardtypeLabel1->setVisible(showAll);
cardtypeLabel2->setVisible(showAll); cardtypeLabel2->setVisible(showAll);
powtoughLabel1->setVisible(showAll); powtoughLabel1->setVisible(showPowTough);
powtoughLabel2->setVisible(showAll); powtoughLabel2->setVisible(showPowTough);
loyaltyLabel1->setVisible(showLoyalty);
loyaltyLabel2->setVisible(showLoyalty);
textLabel->setVisible(showAll); textLabel->setVisible(showAll);
} }
@ -133,7 +151,13 @@ void CardInfoWidget::setCard(CardInfo *card)
manacostLabel2->setText(card->getManaCost()); manacostLabel2->setText(card->getManaCost());
cardtypeLabel2->setText(card->getCardType()); cardtypeLabel2->setText(card->getCardType());
powtoughLabel2->setText(card->getPowTough()); powtoughLabel2->setText(card->getPowTough());
loyaltyLabel2->setText(QString::number(card->getLoyalty()));
textLabel->setText(card->getText()); textLabel->setText(card->getText());
powtoughLabel1->setVisible(shouldShowPowTough());
powtoughLabel2->setVisible(shouldShowPowTough());
loyaltyLabel1->setVisible(shouldShowLoyalty());
loyaltyLabel2->setVisible(shouldShowLoyalty());
} }
void CardInfoWidget::setCard(const QString &cardName) void CardInfoWidget::setCard(const QString &cardName)
@ -166,6 +190,7 @@ void CardInfoWidget::retranslateUi()
manacostLabel1->setText(tr("Mana cost:")); manacostLabel1->setText(tr("Mana cost:"));
cardtypeLabel1->setText(tr("Card type:")); cardtypeLabel1->setText(tr("Card type:"));
powtoughLabel1->setText(tr("P / T:")); powtoughLabel1->setText(tr("P / T:"));
loyaltyLabel1->setText(tr("Loyalty:"));
} }
void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/) void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/)

View file

@ -23,6 +23,7 @@ private:
int pixmapWidth; int pixmapWidth;
qreal cardHeightOffset; qreal cardHeightOffset;
qreal aspectRatio; qreal aspectRatio;
// XXX: Why isn't this an eunm?
int minimized; // 0 - card, 1 - oracle only, 2 - full int minimized; // 0 - card, 1 - oracle only, 2 - full
ResizeMode mode; ResizeMode mode;
@ -32,8 +33,12 @@ private:
QLabel *manacostLabel1, *manacostLabel2; QLabel *manacostLabel1, *manacostLabel2;
QLabel *cardtypeLabel1, *cardtypeLabel2; QLabel *cardtypeLabel1, *cardtypeLabel2;
QLabel *powtoughLabel1, *powtoughLabel2; QLabel *powtoughLabel1, *powtoughLabel2;
QLabel *loyaltyLabel1, *loyaltyLabel2;
QTextEdit *textLabel; QTextEdit *textLabel;
bool shouldShowPowTough();
bool shouldShowLoyalty();
CardInfo *info; CardInfo *info;
void setMinimized(int _minimized); void setMinimized(int _minimized);

View file

@ -52,6 +52,7 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join")); onlyBuddiesCheckBox = new QCheckBox(tr("Only &buddies can join"));
onlyRegisteredCheckBox = new QCheckBox(tr("Only &registered users can join")); onlyRegisteredCheckBox = new QCheckBox(tr("Only &registered users can join"));
onlyRegisteredCheckBox->setChecked(true);
QGridLayout *joinRestrictionsLayout = new QGridLayout; QGridLayout *joinRestrictionsLayout = new QGridLayout;
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0); joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);