summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire
authorkergoth <kergoth>2002-06-07 18:53:14 (UTC)
committer kergoth <kergoth>2002-06-07 18:53:14 (UTC)
commit640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (side-by-side diff)
tree9a784686c1795f8b1f81eb344598f3b549d43467 /noncore/games/solitaire
parentdfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff)
downloadopie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2
Backing out unintentional merge from TT branch.
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
@@ -27,6 +27,7 @@
#include <qimage.h>
#include <qpaintdevice.h>
#include <qbitmap.h>
+#include <qgfx_qws.h> // Needed to get the device's width
#include <math.h>
@@ -102,10 +103,17 @@ 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 );
}
@@ -126,17 +134,32 @@ void CanvasCard::setCardBack(int 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() )
@@ -181,11 +204,19 @@ void CanvasCard::draw(QPainter &painter)
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 {
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
@@ -19,11 +19,12 @@
**********************************************************************/
#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();
@@ -39,7 +40,10 @@ void CanvasRoundRect::redraw()
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);
}
@@ -73,20 +77,38 @@ void CanvasCircleOrCross::setCross()
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
@@ -17,6 +17,7 @@
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "freecellcardgame.h"
@@ -29,16 +30,20 @@ FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : Can
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]);
}
}
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
@@ -17,6 +17,7 @@
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "patiencecardgame.h"
@@ -28,19 +29,35 @@ PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : Can
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() );
}
@@ -173,7 +190,10 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
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;
@@ -195,7 +215,10 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
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 );
}
}
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
@@ -25,6 +25,7 @@
#include <qmainwindow.h>
#include <qintdict.h>
#include <qcanvas.h>
+#include <qgfx_qws.h>
// #include "canvascardshapes.h"
// #include "canvascard.h"
#include "canvascardgame.h"
@@ -130,11 +131,12 @@ public:
} 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() );
@@ -145,7 +147,8 @@ public:
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;