Diffstat (limited to 'noncore/games/solitaire/patiencecardgame.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/solitaire/patiencecardgame.cpp | 23 |
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 | |||
@@ -8,49 +8,66 @@ | |||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
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 | ||
23 | int highestZ = 0; | 24 | int highestZ = 0; |
24 | 25 | ||
25 | 26 | ||
26 | PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) | 27 | PatienceCardGame::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 | ||
47 | PatienceCardGame::~PatienceCardGame() | 64 | PatienceCardGame::~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; |
53 | } | 70 | } |
54 | 71 | ||
55 | 72 | ||
56 | void PatienceCardGame::deal(void) | 73 | void PatienceCardGame::deal(void) |
@@ -164,46 +181,52 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p ) | |||
164 | CanvasCard *item = (CanvasCard *)card; | 181 | CanvasCard *item = (CanvasCard *)card; |
165 | if (item->isFacing() != TRUE) { | 182 | if (item->isFacing() != TRUE) { |
166 | // From facedown stack | 183 | // From facedown stack |
167 | if ((item->x() == 5) && ((int)item->y() == 10)) { | 184 | if ((item->x() == 5) && ((int)item->y() == 10)) { |
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 ); |
184 | for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) { | 204 | for (QCanvasItemList::Iterator it = l.begin(); (it != l.end()) && (flipped != cardsDrawn()); ++it) { |
185 | if ( (*it)->rtti() == canvasCardId ) { | 205 | if ( (*it)->rtti() == canvasCardId ) { |
186 | CanvasCard *item = (CanvasCard *)*it; | 206 | CanvasCard *item = (CanvasCard *)*it; |
187 | if (item->animated()) | 207 | if (item->animated()) |
188 | continue; | 208 | continue; |
189 | item->setZ(highestZ); | 209 | item->setZ(highestZ); |
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; |
206 | } | 229 | } |
207 | 230 | ||
208 | 231 | ||
209 | void PatienceCardGame::mousePress(QPoint p) | 232 | void PatienceCardGame::mousePress(QPoint p) |