From 8efe15a2015d75e7a9d35d5e7a4c2cf86ee8395f Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Fri, 26 Jun 2009 23:25:51 +0200 Subject: [PATCH] card back svg --- cockatrice/cockatrice.pro | 3 +- cockatrice/cockatrice.qrc | 5 + cockatrice/resources/back.svg | 156 ++++++++++++++++++++++++++++++ cockatrice/src/carddatabase.cpp | 17 +++- cockatrice/src/cardinfowidget.cpp | 9 +- 5 files changed, 182 insertions(+), 8 deletions(-) create mode 100644 cockatrice/cockatrice.qrc create mode 100644 cockatrice/resources/back.svg diff --git a/cockatrice/cockatrice.pro b/cockatrice/cockatrice.pro index 019fbcc6d..d8b7f1a0c 100644 --- a/cockatrice/cockatrice.pro +++ b/cockatrice/cockatrice.pro @@ -8,9 +8,10 @@ DEPENDPATH += . src INCLUDEPATH += . src MOC_DIR = build OBJECTS_DIR = build +RESOURCES = cockatrice.qrc # CONFIG += qt debug -QT += network +QT += network svg #QT += opengl #QTPLUGIN += qjpeg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc new file mode 100644 index 000000000..332bf56a2 --- /dev/null +++ b/cockatrice/cockatrice.qrc @@ -0,0 +1,5 @@ + + + resources/back.svg + + diff --git a/cockatrice/resources/back.svg b/cockatrice/resources/back.svg new file mode 100644 index 000000000..e28bdd547 --- /dev/null +++ b/cockatrice/resources/back.svg @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 33657a330..3ac3d0311 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include CardSet::CardSet(const QString &_shortName, const QString &_longName) : shortName(_shortName), longName(_longName) @@ -142,9 +144,18 @@ QPixmap *CardInfo::getPixmap(QSize size) if (cachedPixmap) return cachedPixmap; QPixmap *bigPixmap = loadPixmap(); - if (bigPixmap->isNull()) - return 0; - QPixmap *result = new QPixmap(bigPixmap->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + QPixmap *result; + if (bigPixmap->isNull()) { + if (!getName().isEmpty()) + return 0; + else { + result = new QPixmap(size); + QSvgRenderer svg(QString(":/back.svg")); + QPainter painter(result); + svg.render(&painter, QRectF(0, 0, size.width(), size.height())); + } + } else + result = new QPixmap(bigPixmap->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); scaledPixmapCache.insert(size.width(), result); return result; } diff --git a/cockatrice/src/cardinfowidget.cpp b/cockatrice/src/cardinfowidget.cpp index 29474b2a3..6ce175ed9 100644 --- a/cockatrice/src/cardinfowidget.cpp +++ b/cockatrice/src/cardinfowidget.cpp @@ -1,4 +1,5 @@ #include "cardinfowidget.h" +#include "carditem.h" #include #include #include @@ -12,7 +13,7 @@ CardInfoWidget::CardInfoWidget(CardDatabase *_db, QWidget *parent) QFont f; f.setPixelSize(11); - + nameLabel1 = new QLabel(tr("Name:")); nameLabel1->setFont(f); nameLabel2 = new QLabel(); @@ -54,11 +55,11 @@ CardInfoWidget::CardInfoWidget(CardDatabase *_db, QWidget *parent) CardInfo *cardBack = db->getCard(); QPixmap *bigPixmap = cardBack->loadPixmap(); if (bigPixmap->isNull()) - QMessageBox::critical(this, tr("Error"), tr("Unable to load pixmap for card back.")); + pixmapHeight = pixmapWidth * CARD_HEIGHT / CARD_WIDTH; else pixmapHeight = pixmapWidth * bigPixmap->height() / bigPixmap->width(); setCard(cardBack); - + setFrameStyle(QFrame::Panel | QFrame::Raised); setFixedSize(sizeHint()); } @@ -73,7 +74,7 @@ void CardInfoWidget::setCard(CardInfo *card) cardPicture->setPixmap(*resizedPixmap); else cardPicture->setPixmap(*(db->getCard()->getPixmap(QSize(pixmapWidth, pixmapHeight)))); - + nameLabel2->setText(card->getName()); manacostLabel2->setText(card->getManacost()); cardtypeLabel2->setText(card->getCardType());