author | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
commit | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (side-by-side diff) | |
tree | 9a784686c1795f8b1f81eb344598f3b549d43467 /noncore/games/solitaire | |
parent | dfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff) | |
download | opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2 |
Backing out unintentional merge from TT branch.
-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 @@ -14,32 +14,33 @@ ** 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 @@ -89,68 +90,90 @@ QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) } // 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 ) { + 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; + 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)) { @@ -168,37 +191,45 @@ void CanvasCard::draw(QPainter &painter) 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 ) ); + 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; 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 @@ -6,52 +6,56 @@ ** 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) { + 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(); } @@ -60,33 +64,51 @@ void CanvasCircleOrCross::redraw() void CanvasCircleOrCross::setCircle() { circleShape = TRUE; redraw(); } void CanvasCircleOrCross::setCross() { circleShape = FALSE; redraw(); } 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(); // 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 @@ -4,54 +4,59 @@ ** 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] ); 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 @@ -4,57 +4,74 @@ ** 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; + 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() ); 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() ); } +} PatienceCardGame::~PatienceCardGame() { delete circleCross; delete rectangle; delete faceDownDealingPile; delete faceUpDealingPile; } void PatienceCardGame::deal(void) { highestZ = 1; int t = 0; @@ -160,54 +177,60 @@ void PatienceCardGame::writeConfig( Config& cfg ) 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 ); + 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 ); + 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) ) { 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 @@ -12,32 +12,33 @@ ** 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) { @@ -117,48 +118,50 @@ public: 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; }; |