card back svg

This commit is contained in:
Max-Wilhelm Bruker 2009-06-26 23:25:51 +02:00
parent fb03c5cdbb
commit 8efe15a201
5 changed files with 182 additions and 8 deletions

View file

@ -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

View file

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file alias="back.svg">resources/back.svg</file>
</qresource>
</RCC>

View file

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="240"
height="340"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
sodipodi:docname="hintergrund.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0">
<defs
id="defs4">
<linearGradient
id="linearGradient4766">
<stop
style="stop-color:#784421;stop-opacity:1;"
offset="0"
id="stop4768" />
<stop
style="stop-color:#3d2210;stop-opacity:0;"
offset="1"
id="stop4770" />
</linearGradient>
<linearGradient
id="linearGradient4758">
<stop
style="stop-color:#a05a2c;stop-opacity:1;"
offset="0"
id="stop4760" />
<stop
style="stop-color:#3d2210;stop-opacity:1;"
offset="1"
id="stop4762" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2484"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 526.18109 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4758"
id="linearGradient4764"
x1="466.09601"
y1="485.96021"
x2="715.14801"
y2="485.96021"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4766"
id="linearGradient4772"
x1="496.548"
y1="485.26816"
x2="683.31201"
y2="485.26816"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4758"
id="linearGradient5374"
gradientUnits="userSpaceOnUse"
x1="590.62201"
y1="434.7522"
x2="698.54004"
y2="517.79218" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4766"
id="linearGradient5376"
gradientUnits="userSpaceOnUse"
x1="661.24402"
y1="602.90814"
x2="431.5"
y2="201.5482" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.0399859"
inkscape:cx="266.11903"
inkscape:cy="191.87768"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1280"
inkscape:window-height="725"
inkscape:window-x="0"
inkscape:window-y="25" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g5369"
transform="matrix(0.9650128,0,0,0.9948433,-449.70565,-312.80927)">
<rect
y="324.3782"
x="476.09601"
height="323.164"
width="229.052"
id="rect2490"
style="fill:url(#linearGradient5374);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:20;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
y="345.83017"
x="497.548"
height="278.87601"
width="184.76401"
id="rect3302"
style="fill:url(#linearGradient5376);fill-opacity:1;stroke:#000000;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
transform="matrix(1.1813093,0,0,1.0234202,-106.20504,-16.66044)"
d="M 661.55199,489.76617 A 71.968002,128.71201 0 1 1 517.61598,489.76617 A 71.968002,128.71201 0 1 1 661.55199,489.76617 z"
sodipodi:ry="128.71201"
sodipodi:rx="71.968002"
sodipodi:cy="489.76617"
sodipodi:cx="589.58398"
id="path3304"
style="fill:#a05a2c;stroke:#000000;stroke-width:2;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:type="arc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -4,6 +4,8 @@
#include <QFile>
#include <QTextStream>
#include <QSettings>
#include <QSvgRenderer>
#include <QPainter>
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;
}

View file

@ -1,4 +1,5 @@
#include "cardinfowidget.h"
#include "carditem.h"
#include <QGridLayout>
#include <QLabel>
#include <QTextEdit>
@ -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());