summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire/patiencecardgame.cpp
Unidiff
Diffstat (limited to 'noncore/games/solitaire/patiencecardgame.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp23
1 files changed, 23 insertions, 0 deletions
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
@@ -12,41 +12,58 @@
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qgfx_qws.h>
20#include "patiencecardgame.h" 21#include "patiencecardgame.h"
21 22
22 23
23int highestZ = 0; 24int highestZ = 0;
24 25
25 26
26PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) 27PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
27{ 28{
28 numberOfTimesThroughDeck = 0; 29 numberOfTimesThroughDeck = 0;
29 highestZ = 0; 30 highestZ = 0;
30 31
32 if ( qt_screen->deviceWidth() < 200 ) {
33 circleCross = new CanvasCircleOrCross( 7, 16, canvas() );
34 rectangle = new CanvasRoundRect( 30, 10, canvas() );
35
36 for (int i = 0; i < 4; i++) {
37 discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() );
38 addCardPile(discardPiles[i]);
39 }
40 for (int i = 0; i < 7; i++) {
41 workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() );
42 addCardPile(workingPiles[i]);
43 }
44 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
45 faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() );
46 } else {
31 circleCross = new CanvasCircleOrCross( 7, 18, canvas() ); 47 circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
32 rectangle = new CanvasRoundRect( 35, 10, canvas() ); 48 rectangle = new CanvasRoundRect( 35, 10, canvas() );
33 49
34 for (int i = 0; i < 4; i++) { 50 for (int i = 0; i < 4; i++) {
35 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() ); 51 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
36 addCardPile(discardPiles[i]); 52 addCardPile(discardPiles[i]);
37 } 53 }
38 for (int i = 0; i < 7; i++) { 54 for (int i = 0; i < 7; i++) {
39 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() ); 55 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
40 addCardPile(workingPiles[i]); 56 addCardPile(workingPiles[i]);
41 } 57 }
42 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() ); 58 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
43 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() ); 59 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
44} 60}
61}
45 62
46 63
47PatienceCardGame::~PatienceCardGame() 64PatienceCardGame::~PatienceCardGame()
48{ 65{
49 delete circleCross; 66 delete circleCross;
50 delete rectangle; 67 delete rectangle;
51 delete faceDownDealingPile; 68 delete faceDownDealingPile;
52 delete faceUpDealingPile; 69 delete faceUpDealingPile;
@@ -168,16 +185,19 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
168 item->setZ(highestZ); 185 item->setZ(highestZ);
169 highestZ++; 186 highestZ++;
170 187
171 // Added Code 188 // Added Code
172 faceDownDealingPile->removeCard(item); 189 faceDownDealingPile->removeCard(item);
173 faceUpDealingPile->addCardToTop(item); 190 faceUpDealingPile->addCardToTop(item);
174 item->setCardPile( faceUpDealingPile ); 191 item->setCardPile( faceUpDealingPile );
175 192
193 if ( qt_screen->deviceWidth() < 200 )
194 item->flipTo( 30, (int)item->y() );
195 else
176 item->flipTo( 35, (int)item->y() ); 196 item->flipTo( 35, (int)item->y() );
177 } 197 }
178 moving = NULL; 198 moving = NULL;
179 moved = FALSE; 199 moved = FALSE;
180 200
181 // move two other cards if we flip three at a time 201 // move two other cards if we flip three at a time
182 int flipped = 1; 202 int flipped = 1;
183 QCanvasItemList l = canvas()->collisions( p ); 203 QCanvasItemList l = canvas()->collisions( p );
@@ -190,16 +210,19 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
190 highestZ++; 210 highestZ++;
191 flipped++; 211 flipped++;
192 212
193 // Added Code 213 // Added Code
194 faceDownDealingPile->removeCard(item); 214 faceDownDealingPile->removeCard(item);
195 faceUpDealingPile->addCardToTop(item); 215 faceUpDealingPile->addCardToTop(item);
196 item->setCardPile( faceUpDealingPile ); 216 item->setCardPile( faceUpDealingPile );
197 217
218 if ( qt_screen->deviceWidth() < 200 )
219 item->flipTo( 30, (int)item->y(), 8 * flipped );
220 else
198 item->flipTo( 35, (int)item->y(), 8 * flipped ); 221 item->flipTo( 35, (int)item->y(), 8 * flipped );
199 } 222 }
200 } 223 }
201 224
202 return TRUE; 225 return TRUE;
203 } 226 }
204 227
205 return FALSE; 228 return FALSE;