summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire
Side-by-side diff
Diffstat (limited to 'noncore/games/solitaire') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascard.cpp71
-rw-r--r--noncore/games/solitaire/canvasshapes.cpp52
-rw-r--r--noncore/games/solitaire/freecellcardgame.cpp11
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp49
-rw-r--r--noncore/games/solitaire/patiencecardgame.h7
5 files changed, 137 insertions, 53 deletions
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index ae3c859..7c4a5ba 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -6,48 +6,49 @@
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "cardgame.h"
#include "canvascard.h"
#include <qpe/resource.h>
#include <qpainter.h>
#include <qimage.h>
#include <qpaintdevice.h>
#include <qbitmap.h>
+#include <qgfx_qws.h> // Needed to get the device's width
#include <math.h>
#if defined( QT_QWS_CASSIOPEIA )
#define SLOW_HARDWARE
#endif
// Seems to be fast enough to me even without Transformations in the library
//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ )
//#define SLOW_HARDWARE
//#endif
QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap)
{
#ifdef QT_NO_TRANSFORMATIONS
int w = srcBitmap->width();
int h = srcBitmap->height();
QBitmap *dstBitmap = new QBitmap( w, h );
// ### this is very poorly implemented and probably could be much faster
for (int i = 0; i < w; i++)
for (int j = 0; j < h; j++)
bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 );
return dstBitmap;
@@ -81,132 +82,162 @@ QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY)
}
}
return dstPixmap;
#else
QWMatrix s;
s.scale( scaleX, scaleY );
return new QPixmap( srcPixmap->xForm( s ) );
#endif
}
// Initialise static member variables to NULL
QPixmap *CanvasCard::cardsFaces = NULL;
QPixmap *CanvasCard::cardsBacks = NULL;
QBitmap *CanvasCard::cardsChars = NULL;
QBitmap *CanvasCard::cardsSuits = NULL;
QBitmap *CanvasCard::cardsCharsUpsideDown = NULL;
QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
{
if ( !cardsFaces ) {
- cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
- cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
- cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
+ if ( qt_screen->deviceWidth() < 200 ) {
+ cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) );
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) );
+ cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) );
+ cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) );
+ } else {
+ cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
+ cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
+ cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
+ }
cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
}
xOff = cardsFaces->width() / 2;
yOff = cardsFaces->height() / 2;
setSize( cardsFaces->width(), cardsFaces->height() );
setPen( NoPen );
flipping = FALSE;
}
void CanvasCard::setCardBack(int b)
{
if ( cardBack != b ) {
cardBack = b;
if ( cardsBacks )
delete cardsBacks;
- switch (cardBack) {
- case 0:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break;
- case 1:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break;
- case 2:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break;
- case 3:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break;
- case 4:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break;
+ if ( qt_screen->deviceWidth() < 200 ) {
+ switch (cardBack) {
+ case 0:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break;
+ case 1:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break;
+ case 2:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break;
+ case 3:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break;
+ case 4:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break;
+ }
+ } else {
+ switch (cardBack) {
+ case 0:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break;
+ case 1:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break;
+ case 2:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break;
+ case 3:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break;
+ case 4:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break;
+ }
}
if ( !isFacing() )
redraw();
}
}
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() ) {
/*
// Now add the joker and card backs to the list of pixmaps
QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) );
QPoint *newBackHotspot = new QPoint( 0, 0 );
pixmaps->append((const QPixmap *)CardsBack);
hotspots->append((const QPoint *)newBackHotspot);
*/
int w = cardsFaces->width(), h = cardsFaces->height();
// p->setBrush( NoBrush );
p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) );
if ( isRed() == TRUE )
p->setPen( QColor( 0xFF, 0, 0 ) );
else
p->setPen( QColor( 0, 0, 0 ) );
- 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 );
+ 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)
{
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;
diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp
index 28d0b4e..6ccd4a4 100644
--- a/noncore/games/solitaire/canvasshapes.cpp
+++ b/noncore/games/solitaire/canvasshapes.cpp
@@ -1,92 +1,114 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qpainter.h>
#include <qcanvas.h>
+#include <qgfx_qws.h>
#include "canvasshapes.h"
CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
- QCanvasRectangle( x, y, 23, 36, canvas)
+ QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas)
{
setZ(0);
show();
}
void CanvasRoundRect::redraw()
{
hide();
show();
}
void CanvasRoundRect::drawShape(QPainter &p)
{
- p.drawRoundRect( (int)x(), (int)y(), 23, 36);
+ if ( qt_screen->deviceWidth() < 200 )
+ p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
+ else
+ p.drawRoundRect( (int)x(), (int)y(), 23, 36);
}
CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
{
show();
}
void CanvasCircleOrCross::redraw()
{
hide();
show();
}
void CanvasCircleOrCross::setCircle()
{
circleShape = TRUE;
redraw();
}
void CanvasCircleOrCross::setCross()
{
circleShape = FALSE;
redraw();
}
void CanvasCircleOrCross::drawShape(QPainter &p)
{
- int x1 = (int)x(), y1 = (int)y();
- // Green circle
- if (circleShape == TRUE) {
- p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
- p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
- p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
- p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
- p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
- p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
- // Red cross
+ if ( qt_screen->deviceWidth() < 200 ) {
+ int x1 = (int)x(), y1 = (int)y();
+ // Green circle
+ if (circleShape == TRUE) {
+ p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
+ p.drawEllipse( x1 - 1, y1 - 1, 17, 17);
+ p.drawEllipse( x1 - 1, y1 - 0, 17, 15);
+ p.drawEllipse( x1 + 0, y1 + 0, 15, 15);
+ p.drawEllipse( x1 + 1, y1 + 0, 13, 15);
+ p.drawEllipse( x1 + 1, y1 + 1, 13, 13);
+ // Red cross
+ } else {
+ p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) );
+ p.drawLine( x1, y1, x1 + 14, y1 + 14);
+ p.drawLine( x1 + 14, y1, x1, y1 + 14);
+ }
} else {
- p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
- p.drawLine( x1, y1, x1 + 20, y1 + 20);
- p.drawLine( x1 + 20, y1, x1, y1 + 20);
+ int x1 = (int)x(), y1 = (int)y();
+ // Green circle
+ if (circleShape == TRUE) {
+ p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
+ p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
+ p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
+ p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
+ p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
+ p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
+ // Red cross
+ } else {
+ p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
+ p.drawLine( x1, y1, x1 + 20, y1 + 20);
+ p.drawLine( x1 + 20, y1, x1, y1 + 20);
+ }
}
}
diff --git a/noncore/games/solitaire/freecellcardgame.cpp b/noncore/games/solitaire/freecellcardgame.cpp
index e82afd4..98415aa 100644
--- a/noncore/games/solitaire/freecellcardgame.cpp
+++ b/noncore/games/solitaire/freecellcardgame.cpp
@@ -1,65 +1,70 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "freecellcardgame.h"
extern int highestZ;
int numberOfFreeCells = 4;
FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
{
numberOfFreeCells = 4;
highestZ = 0;
+ int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28;
+ int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5;
+ int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0;
+
for (int i = 0; i < 4; i++) {
- freecellPiles[i] = new FreecellFreecellPile( 5 + i * 28, 10, canvas() );
+ freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() );
addCardPile(freecellPiles[i]);
}
for (int i = 0; i < 4; i++) {
- discardPiles[i] = new FreecellDiscardPile( 125 + i * 28, 10, canvas() );
+ discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() );
addCardPile(discardPiles[i]);
}
for (int i = 0; i < 8; i++) {
- workingPiles[i] = new FreecellWorkingPile( 10 + i * 28, 50, canvas() );
+ workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() );
addCardPile(workingPiles[i]);
}
}
void FreecellCardGame::deal(void)
{
highestZ = 1;
beginDealing();
for (int i = 0; i < 52; i++) {
Card *card = cards[i];
card->setFace( TRUE );
card->setPos( 0, 0, highestZ );
card->setCardPile( workingPiles[i%8] );
workingPiles[i%8]->addCardToTop( card );
card->move( workingPiles[i%8]->getCardPos( card ) );
card->showCard();
highestZ++;
}
endDealing();
}
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp
index 5a9326a..1501d2f 100644
--- a/noncore/games/solitaire/patiencecardgame.cpp
+++ b/noncore/games/solitaire/patiencecardgame.cpp
@@ -1,67 +1,84 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "patiencecardgame.h"
int highestZ = 0;
PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
{
numberOfTimesThroughDeck = 0;
highestZ = 0;
- circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
- rectangle = new CanvasRoundRect( 35, 10, canvas() );
+ if ( qt_screen->deviceWidth() < 200 ) {
+ circleCross = new CanvasCircleOrCross( 7, 16, canvas() );
+ rectangle = new CanvasRoundRect( 30, 10, canvas() );
- for (int i = 0; i < 4; i++) {
- discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
- addCardPile(discardPiles[i]);
- }
- for (int i = 0; i < 7; i++) {
- workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
- addCardPile(workingPiles[i]);
+ for (int i = 0; i < 4; i++) {
+ discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 7; i++) {
+ workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
+ faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() );
+ } else {
+ circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
+ rectangle = new CanvasRoundRect( 35, 10, canvas() );
+
+ for (int i = 0; i < 4; i++) {
+ discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 7; i++) {
+ workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
+ faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
}
- faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
- faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
}
PatienceCardGame::~PatienceCardGame()
{
delete circleCross;
delete rectangle;
delete faceDownDealingPile;
delete faceUpDealingPile;
}
void PatienceCardGame::deal(void)
{
highestZ = 1;
int t = 0;
beginDealing();
for (int i = 0; i < 7; i++) {
cards[t]->setFace(TRUE);
for (int k = i; k < 7; k++, t++) {
Card *card = cards[t];
workingPiles[k]->addCardToTop(card);
@@ -152,71 +169,77 @@ void PatienceCardGame::writeConfig( Config& cfg )
pile.sprintf( "DiscardPile%i", i );
discardPiles[i]->writeConfig( cfg, pile );
}
faceDownDealingPile->writeConfig( cfg, "FaceDownDealingPile" );
faceUpDealingPile->writeConfig( cfg, "FaceUpDealingPile" );
}
bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
{
Q_UNUSED(p);
CanvasCard *item = (CanvasCard *)card;
if (item->isFacing() != TRUE) {
// From facedown stack
if ((item->x() == 5) && ((int)item->y() == 10)) {
item->setZ(highestZ);
highestZ++;
// Added Code
faceDownDealingPile->removeCard(item);
faceUpDealingPile->addCardToTop(item);
item->setCardPile( faceUpDealingPile );
- item->flipTo( 35, (int)item->y() );
+ if ( qt_screen->deviceWidth() < 200 )
+ item->flipTo( 30, (int)item->y() );
+ else
+ item->flipTo( 35, (int)item->y() );
}
moving = NULL;
moved = FALSE;
// move two other cards if we flip three at a time
int flipped = 1;
QCanvasItemList l = canvas()->collisions( p );
for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) {
if ( (*it)->rtti() == canvasCardId ) {
CanvasCard *item = (CanvasCard *)*it;
if (item->animated())
continue;
item->setZ(highestZ);
highestZ++;
flipped++;
// Added Code
faceDownDealingPile->removeCard(item);
faceUpDealingPile->addCardToTop(item);
item->setCardPile( faceUpDealingPile );
- item->flipTo( 35, (int)item->y(), 8 * flipped );
+ if ( qt_screen->deviceWidth() < 200 )
+ item->flipTo( 30, (int)item->y(), 8 * flipped );
+ else
+ item->flipTo( 35, (int)item->y(), 8 * flipped );
}
}
return TRUE;
}
return FALSE;
}
void PatienceCardGame::mousePress(QPoint p)
{
if ( canTurnOverDeck() &&
(p.x() > 5) && (p.x() < 28) &&
(p.y() > 10) && (p.y() < 46) ) {
beginDealing();
Card *card = faceUpDealingPile->cardOnTop();
while ( card ) {
card->setPos( 5, 10, highestZ );
card->setFace( FALSE );
faceUpDealingPile->removeCard( card );
faceDownDealingPile->addCardToTop( card );
card->setCardPile( faceDownDealingPile );
diff --git a/noncore/games/solitaire/patiencecardgame.h b/noncore/games/solitaire/patiencecardgame.h
index c4f6c48..0d0e3d5 100644
--- a/noncore/games/solitaire/patiencecardgame.h
+++ b/noncore/games/solitaire/patiencecardgame.h
@@ -4,48 +4,49 @@
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef PATIENCE_CARD_GAME_H
#define PATIENCE_CARD_GAME_H
#include <qpopupmenu.h>
#include <qmainwindow.h>
#include <qintdict.h>
#include <qcanvas.h>
+#include <qgfx_qws.h>
// #include "canvascardshapes.h"
// #include "canvascard.h"
#include "canvascardgame.h"
class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect
{
public:
PatienceFaceDownDeck(int x, int y, QCanvas *canvas)
: CardPile(x, y), CanvasRoundRect(x, y, canvas) { }
virtual bool isAllowedOnTop(Card *card) {
Q_UNUSED(card);
// Need to check it is from the faceUpDealingPile
return TRUE;
}
virtual bool isAllowedToBeMoved(Card *card) {
Q_UNUSED(card);
//if ( ( !card->isFacing() ) && ( card == cardOnTop() ) )
if ( card == cardOnTop() )
return TRUE;
return FALSE;
}
};
@@ -109,64 +110,66 @@ public:
virtual bool isAllowedToBeMoved(Card *card) {
if ( card->isFacing() )
return TRUE;
return FALSE;
}
virtual void cardAddedToTop(Card *card) {
Q_UNUSED(card);
top = getCardPos(NULL);
setNextX( top.x() );
setNextY( top.y() );
}
virtual void cardRemoved(Card *card) {
Q_UNUSED(card);
Card *newTopCard = cardOnTop();
if ( !newTopCard ) {
top = QPoint( pileX, pileY );
setNextX( pileX );
setNextY( pileY );
return;
} else {
top = getCardPos(NULL);
if ( newTopCard->isFacing() == FALSE ) {
+ int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
// correct the position taking in to account the card is not
// yet flipped, but will become flipped
top = QPoint( top.x() - 1, top.y() - 3 );
newTopCard->flipTo( top.x(), top.y() );
- top = QPoint( top.x(), top.y() + 13 );
+ top = QPoint( top.x(), top.y() + offsetDown );
}
setNextX( top.x() );
setNextY( top.y() );
}
}
virtual QPoint getCardPos(Card *c) {
int x = pileX, y = pileY;
Card *card = cardOnBottom();
while ((card != c) && (card != NULL)) {
if (card->isFacing()) {
- y += 13;
+ int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
+ y += offsetDown;
} else {
x += 1;
y += 3;
}
card = cardInfront(card);
}
return QPoint( x, y );
}
virtual QPoint getHypertheticalNextCardPos(void) {
return top;
// return QPoint( getNextX(), getNextY() );
}
private:
QPoint top;
};
class PatienceCardGame : public CanvasCardGame
{
public:
PatienceCardGame(QCanvas *c, bool snap, QWidget *parent = 0);
virtual ~PatienceCardGame();
virtual void deal(void);