summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardgame.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp
index 32635a0..ef35287 100644
--- a/noncore/games/solitaire/canvascardgame.cpp
+++ b/noncore/games/solitaire/canvascardgame.cpp
@@ -16,32 +16,33 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "cardgame.h"
#include "canvasshapes.h"
#include "canvascard.h"
#include "canvascardgame.h"
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qmainwindow.h>
#include <qpe/qpemenubar.h>
#include <qpainter.h>
+#include <qgfx_qws.h>
#include <stdlib.h>
#include <limits.h>
#include <time.h>
#include <math.h>
extern int highestZ;
class CanvasCardPile : public QCanvasRectangle
{
public:
CanvasCardPile( CanvasCardGame *ccg, QCanvas *canvas ) : QCanvasRectangle( canvas ), parent( ccg ) {
pile = new QPixmap( 0, 0 );
pileHeight = 0;
@@ -58,95 +59,99 @@ protected:
virtual void draw( QPainter& p );
private:
CanvasCardGame *parent;
QPixmap *pile;
QImage tempImage32;
CanvasCard *firstCard;
int pileHeight;
int destX, destY;
int savedX, savedY;
int animSteps;
};
void CanvasCardPile::addCard( CanvasCard *card )
{
+ int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
+ int cardHeight = ( qt_screen->deviceWidth() < 200 ) ? 27 : 36;
+ int cardWidth = ( qt_screen->deviceWidth() < 200 ) ? 20 : 23;
+
if ( !firstCard )
firstCard = card;
- int height = 36 + pileHeight * 13;
- setSize( 23, height );
- pile->resize( 23, height );
+ int height = cardHeight + pileHeight * offsetDown;
+ setSize( cardWidth, height );
+ pile->resize( cardWidth, height );
QPainter p( pile );
- p.translate( -card->x(), -card->y() + pileHeight * 13 );
+ p.translate( -card->x(), -card->y() + pileHeight * offsetDown );
card->draw( p );
pileHeight++;
QImage tempImage;
tempImage = *pile;
tempImage32 = tempImage.convertDepth( 32 );
tempImage32.setAlphaBuffer( TRUE );
for ( int i = 0; i < tempImage32.width(); i++ )
for ( int j = 0; j < tempImage32.height(); j++ ) {
QRgb col = tempImage32.pixel( i, j );
int a = 255-j*220/tempImage32.height();
QRgb alpha = qRgba( qRed( col ), qGreen( col ), qBlue( col ), a );
tempImage32.setPixel( i, j, alpha );
}
QRgb alpha = qRgba( 0, 0, 0, 0 );
tempImage32.setPixel( 1, 0, alpha );
tempImage32.setPixel( 0, 0, alpha );
tempImage32.setPixel( 0, 1, alpha );
- tempImage32.setPixel( 21, 0, alpha );
- tempImage32.setPixel( 22, 0, alpha );
- tempImage32.setPixel( 22, 1, alpha );
+ tempImage32.setPixel( cardWidth - 2, 0, alpha );
+ tempImage32.setPixel( cardWidth - 1, 0, alpha );
+ tempImage32.setPixel( cardWidth - 1, 1, alpha );
height--;
tempImage32.setPixel( 1, height, alpha );
tempImage32.setPixel( 0, height - 1, alpha );
tempImage32.setPixel( 0, height, alpha );
- tempImage32.setPixel( 21, height, alpha );
- tempImage32.setPixel( 22, height, alpha );
- tempImage32.setPixel( 22, height - 1, alpha );
+ tempImage32.setPixel( cardWidth - 2, height, alpha );
+ tempImage32.setPixel( cardWidth - 1, height, alpha );
+ tempImage32.setPixel( cardWidth - 1, height - 1, alpha );
}
void CanvasCardPile::advance(int stage)
{
if ( stage==1 ) {
if ( animSteps-- <= 0 ) {
CanvasCard *item = firstCard;
while (item) {
item->show();
item = (CanvasCard *)item->getCardPile()->cardInfront(item);
}
setVelocity(0,0);
setAnimated(FALSE);
parent->cancelMoving();
hide();
move(destX,destY); // exact
}
}
QCanvasRectangle::advance(stage);
}
-void CanvasCardPile::animatedMove(int x2, int y2, int steps = 7 )
+void CanvasCardPile::animatedMove(int x2, int y2, int steps )
{
destX = x2;
destY = y2;
double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1;
// Ensure a good speed
while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 )
steps--;
setAnimated(TRUE);
setVelocity(dx/steps, dy/steps);
animSteps = steps;
}