Diffstat (limited to 'noncore/games/solitaire/canvascard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/solitaire/canvascard.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp index cd298ef..3ed9ea0 100644 --- a/noncore/games/solitaire/canvascard.cpp +++ b/noncore/games/solitaire/canvascard.cpp @@ -169,97 +169,97 @@ void CanvasCard::setCardBack(int b) void CanvasCard::draw(QPainter &painter) { int ix = (int)x(), iy = (int)y(); QPainter *p = &painter; QPixmap *unscaledCard = NULL; if ((scaleX <= 0.98) || (scaleY <= 0.98)) { p = new QPainter(); unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); p->begin(unscaledCard); ix = 0; iy = 0; } if ( isFacing() ) { int w = cardsFaces->width(), h = cardsFaces->height(); p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); if ( isRed() == TRUE ) p->setPen( QColor( 0xFF, 0, 0 ) ); else p->setPen( QColor( 0, 0, 0 ) ); if ( qt_screen->deviceWidth() < 200 ) { p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 ); p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 ); p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 ); p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 ); } else { p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); } } else { p->drawPixmap( ix, iy, *cardsBacks ); } - if (p != &painter) + if (p != &painter && unscaledCard) { p->end(); QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); int xoff = scaledCard->width() / 2; int yoff = scaledCard->height() / 2; painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard ); delete p; delete unscaledCard; delete scaledCard; } } static const double flipLift = 1.5; void CanvasCard::flipTo(int x2, int y2, int steps) { flipSteps = steps; #ifdef SLOW_HARDWARE move(x2,y2); Card::flipTo(x2,y2,steps); #else int x1 = (int)x(); int y1 = (int)y(); double dx = x2 - x1; double dy = y2 - y1; flipping = TRUE; destX = x2; destY = y2; animSteps = flipSteps; setVelocity(dx/animSteps, dy/animSteps-flipLift); setAnimated(TRUE); #endif } void CanvasCard::advance(int stage) { if ( stage==1 ) { if ( animSteps-- <= 0 ) { scaleX = 1.0; scaleY = 1.0; flipping = FALSE; setVelocity(0,0); setAnimated(FALSE); |