Diffstat (limited to 'noncore/games/solitaire/freecellcardgame.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/solitaire/freecellcardgame.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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 | |||
@@ -1,65 +1,70 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
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 "freecellcardgame.h" | 21 | #include "freecellcardgame.h" |
21 | 22 | ||
22 | 23 | ||
23 | extern int highestZ; | 24 | extern int highestZ; |
24 | int numberOfFreeCells = 4; | 25 | int numberOfFreeCells = 4; |
25 | 26 | ||
26 | 27 | ||
27 | FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) | 28 | FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) |
28 | { | 29 | { |
29 | numberOfFreeCells = 4; | 30 | numberOfFreeCells = 4; |
30 | highestZ = 0; | 31 | highestZ = 0; |
31 | 32 | ||
33 | int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28; | ||
34 | int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5; | ||
35 | int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0; | ||
36 | |||
32 | for (int i = 0; i < 4; i++) { | 37 | for (int i = 0; i < 4; i++) { |
33 | freecellPiles[i] = new FreecellFreecellPile( 5 + i * 28, 10, canvas() ); | 38 | freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() ); |
34 | addCardPile(freecellPiles[i]); | 39 | addCardPile(freecellPiles[i]); |
35 | } | 40 | } |
36 | for (int i = 0; i < 4; i++) { | 41 | for (int i = 0; i < 4; i++) { |
37 | discardPiles[i] = new FreecellDiscardPile( 125 + i * 28, 10, canvas() ); | 42 | discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() ); |
38 | addCardPile(discardPiles[i]); | 43 | addCardPile(discardPiles[i]); |
39 | } | 44 | } |
40 | for (int i = 0; i < 8; i++) { | 45 | for (int i = 0; i < 8; i++) { |
41 | workingPiles[i] = new FreecellWorkingPile( 10 + i * 28, 50, canvas() ); | 46 | workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() ); |
42 | addCardPile(workingPiles[i]); | 47 | addCardPile(workingPiles[i]); |
43 | } | 48 | } |
44 | } | 49 | } |
45 | 50 | ||
46 | 51 | ||
47 | void FreecellCardGame::deal(void) | 52 | void FreecellCardGame::deal(void) |
48 | { | 53 | { |
49 | highestZ = 1; | 54 | highestZ = 1; |
50 | 55 | ||
51 | beginDealing(); | 56 | beginDealing(); |
52 | 57 | ||
53 | for (int i = 0; i < 52; i++) { | 58 | for (int i = 0; i < 52; i++) { |
54 | Card *card = cards[i]; | 59 | Card *card = cards[i]; |
55 | card->setFace( TRUE ); | 60 | card->setFace( TRUE ); |
56 | card->setPos( 0, 0, highestZ ); | 61 | card->setPos( 0, 0, highestZ ); |
57 | card->setCardPile( workingPiles[i%8] ); | 62 | card->setCardPile( workingPiles[i%8] ); |
58 | workingPiles[i%8]->addCardToTop( card ); | 63 | workingPiles[i%8]->addCardToTop( card ); |
59 | card->move( workingPiles[i%8]->getCardPos( card ) ); | 64 | card->move( workingPiles[i%8]->getCardPos( card ) ); |
60 | card->showCard(); | 65 | card->showCard(); |
61 | highestZ++; | 66 | highestZ++; |
62 | } | 67 | } |
63 | 68 | ||
64 | endDealing(); | 69 | endDealing(); |
65 | } | 70 | } |