-rw-r--r-- | noncore/games/solitaire/canvascard.cpp | 31 | ||||
-rw-r--r-- | noncore/games/solitaire/canvasshapes.cpp | 24 | ||||
-rw-r--r-- | noncore/games/solitaire/freecellcardgame.cpp | 11 | ||||
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 23 | ||||
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.h | 7 |
5 files changed, 90 insertions, 6 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 @@ -29,2 +29,3 @@ #include <qbitmap.h> +#include <qgfx_qws.h> // Needed to get the device's width @@ -104,2 +105,8 @@ CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : if ( !cardsFaces ) { + 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" ) ); @@ -108,2 +115,3 @@ CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); + } cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); @@ -128,2 +136,16 @@ void CanvasCard::setCardBack(int b) + 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) { @@ -140,2 +162,3 @@ void CanvasCard::setCardBack(int b) } + } @@ -183,2 +206,9 @@ void CanvasCard::draw(QPainter &painter) + 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 ); @@ -188,2 +218,3 @@ void CanvasCard::draw(QPainter &painter) p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); + } 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 @@ -21,2 +21,3 @@ #include <qcanvas.h> +#include <qgfx_qws.h> #include "canvasshapes.h" @@ -25,3 +26,3 @@ 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) { @@ -41,2 +42,5 @@ void CanvasRoundRect::drawShape(QPainter &p) { + if ( qt_screen->deviceWidth() < 200 ) + p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25); + else p.drawRoundRect( (int)x(), (int)y(), 23, 36); @@ -75,2 +79,19 @@ void CanvasCircleOrCross::drawShape(QPainter &p) { + 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 { int x1 = (int)x(), y1 = (int)y(); @@ -91,2 +112,3 @@ void CanvasCircleOrCross::drawShape(QPainter &p) } +} 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 @@ -19,2 +19,3 @@ **********************************************************************/ +#include <qgfx_qws.h> #include "freecellcardgame.h" @@ -31,4 +32,8 @@ FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : Can + 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]); @@ -36,3 +41,3 @@ FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : Can 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]); @@ -40,3 +45,3 @@ FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : Can 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 @@ -19,2 +19,3 @@ **********************************************************************/ +#include <qgfx_qws.h> #include "patiencecardgame.h" @@ -30,2 +31,17 @@ PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : Can + 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( 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() ); @@ -44,2 +60,3 @@ PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : Can } +} @@ -175,2 +192,5 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) + if ( qt_screen->deviceWidth() < 200 ) + item->flipTo( 30, (int)item->y() ); + else item->flipTo( 35, (int)item->y() ); @@ -197,2 +217,5 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) + 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 @@ -27,2 +27,3 @@ #include <qcanvas.h> +#include <qgfx_qws.h> // #include "canvascardshapes.h" @@ -132,2 +133,3 @@ public: if ( newTopCard->isFacing() == FALSE ) { + int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; // correct the position taking in to account the card is not @@ -136,3 +138,3 @@ public: newTopCard->flipTo( top.x(), top.y() ); - top = QPoint( top.x(), top.y() + 13 ); + top = QPoint( top.x(), top.y() + offsetDown ); } @@ -147,3 +149,4 @@ public: if (card->isFacing()) { - y += 13; + int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; + y += offsetDown; } else { |