-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 | |||
@@ -18,24 +18,25 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "cardgame.h" | 21 | #include "cardgame.h" |
22 | #include "canvascard.h" | 22 | #include "canvascard.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qimage.h> | 27 | #include <qimage.h> |
28 | #include <qpaintdevice.h> | 28 | #include <qpaintdevice.h> |
29 | #include <qbitmap.h> | 29 | #include <qbitmap.h> |
30 | #include <qgfx_qws.h> // Needed to get the device's width | ||
30 | 31 | ||
31 | #include <math.h> | 32 | #include <math.h> |
32 | 33 | ||
33 | #if defined( QT_QWS_CASSIOPEIA ) | 34 | #if defined( QT_QWS_CASSIOPEIA ) |
34 | #define SLOW_HARDWARE | 35 | #define SLOW_HARDWARE |
35 | #endif | 36 | #endif |
36 | 37 | ||
37 | // Seems to be fast enough to me even without Transformations in the library | 38 | // Seems to be fast enough to me even without Transformations in the library |
38 | //#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) | 39 | //#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) |
39 | //#define SLOW_HARDWARE | 40 | //#define SLOW_HARDWARE |
40 | //#endif | 41 | //#endif |
41 | 42 | ||
@@ -93,60 +94,82 @@ QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) | |||
93 | QPixmap *CanvasCard::cardsFaces = NULL; | 94 | QPixmap *CanvasCard::cardsFaces = NULL; |
94 | QPixmap *CanvasCard::cardsBacks = NULL; | 95 | QPixmap *CanvasCard::cardsBacks = NULL; |
95 | QBitmap *CanvasCard::cardsChars = NULL; | 96 | QBitmap *CanvasCard::cardsChars = NULL; |
96 | QBitmap *CanvasCard::cardsSuits = NULL; | 97 | QBitmap *CanvasCard::cardsSuits = NULL; |
97 | QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; | 98 | QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; |
98 | QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; | 99 | QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; |
99 | 100 | ||
100 | 101 | ||
101 | CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : | 102 | CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : |
102 | Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) | 103 | Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) |
103 | { | 104 | { |
104 | if ( !cardsFaces ) { | 105 | if ( !cardsFaces ) { |
106 | if ( qt_screen->deviceWidth() < 200 ) { | ||
107 | cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) ); | ||
108 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); | ||
109 | cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) ); | ||
110 | cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) ); | ||
111 | } else { | ||
105 | cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); | 112 | cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); |
106 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); | 113 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); |
107 | cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); | 114 | cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); |
108 | cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); | 115 | cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); |
116 | } | ||
109 | cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); | 117 | cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); |
110 | cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); | 118 | cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); |
111 | } | 119 | } |
112 | xOff = cardsFaces->width() / 2; | 120 | xOff = cardsFaces->width() / 2; |
113 | yOff = cardsFaces->height() / 2; | 121 | yOff = cardsFaces->height() / 2; |
114 | setSize( cardsFaces->width(), cardsFaces->height() ); | 122 | setSize( cardsFaces->width(), cardsFaces->height() ); |
115 | setPen( NoPen ); | 123 | setPen( NoPen ); |
116 | flipping = FALSE; | 124 | flipping = FALSE; |
117 | } | 125 | } |
118 | 126 | ||
119 | 127 | ||
120 | void CanvasCard::setCardBack(int b) | 128 | void CanvasCard::setCardBack(int b) |
121 | { | 129 | { |
122 | if ( cardBack != b ) { | 130 | if ( cardBack != b ) { |
123 | 131 | ||
124 | cardBack = b; | 132 | cardBack = b; |
125 | 133 | ||
126 | if ( cardsBacks ) | 134 | if ( cardsBacks ) |
127 | delete cardsBacks; | 135 | delete cardsBacks; |
128 | 136 | ||
137 | if ( qt_screen->deviceWidth() < 200 ) { | ||
138 | switch (cardBack) { | ||
139 | case 0: | ||
140 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break; | ||
141 | case 1: | ||
142 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break; | ||
143 | case 2: | ||
144 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break; | ||
145 | case 3: | ||
146 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break; | ||
147 | case 4: | ||
148 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break; | ||
149 | } | ||
150 | } else { | ||
129 | switch (cardBack) { | 151 | switch (cardBack) { |
130 | case 0: | 152 | case 0: |
131 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; | 153 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; |
132 | case 1: | 154 | case 1: |
133 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; | 155 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; |
134 | case 2: | 156 | case 2: |
135 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; | 157 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; |
136 | case 3: | 158 | case 3: |
137 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; | 159 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; |
138 | case 4: | 160 | case 4: |
139 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; | 161 | cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; |
140 | } | 162 | } |
163 | } | ||
141 | 164 | ||
142 | if ( !isFacing() ) | 165 | if ( !isFacing() ) |
143 | redraw(); | 166 | redraw(); |
144 | } | 167 | } |
145 | } | 168 | } |
146 | 169 | ||
147 | 170 | ||
148 | void CanvasCard::draw(QPainter &painter) | 171 | void CanvasCard::draw(QPainter &painter) |
149 | { | 172 | { |
150 | int ix = (int)x(), iy = (int)y(); | 173 | int ix = (int)x(), iy = (int)y(); |
151 | 174 | ||
152 | QPainter *p = &painter; | 175 | QPainter *p = &painter; |
@@ -172,29 +195,37 @@ void CanvasCard::draw(QPainter &painter) | |||
172 | */ | 195 | */ |
173 | 196 | ||
174 | int w = cardsFaces->width(), h = cardsFaces->height(); | 197 | int w = cardsFaces->width(), h = cardsFaces->height(); |
175 | 198 | ||
176 | //p->setBrush( NoBrush ); | 199 | //p->setBrush( NoBrush ); |
177 | p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); | 200 | p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); |
178 | 201 | ||
179 | if ( isRed() == TRUE ) | 202 | if ( isRed() == TRUE ) |
180 | p->setPen( QColor( 0xFF, 0, 0 ) ); | 203 | p->setPen( QColor( 0xFF, 0, 0 ) ); |
181 | else | 204 | else |
182 | p->setPen( QColor( 0, 0, 0 ) ); | 205 | p->setPen( QColor( 0, 0, 0 ) ); |
183 | 206 | ||
207 | if ( qt_screen->deviceWidth() < 200 ) { | ||
208 | p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); | ||
209 | p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 ); | ||
210 | p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 ); | ||
211 | p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 ); | ||
212 | p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 ); | ||
213 | } else { | ||
184 | p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); | 214 | p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); |
185 | p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); | 215 | p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); |
186 | p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); | 216 | p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); |
187 | p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); | 217 | p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); |
188 | p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); | 218 | p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); |
219 | } | ||
189 | 220 | ||
190 | } else { | 221 | } else { |
191 | 222 | ||
192 | p->drawPixmap( ix, iy, *cardsBacks ); | 223 | p->drawPixmap( ix, iy, *cardsBacks ); |
193 | 224 | ||
194 | } | 225 | } |
195 | 226 | ||
196 | if (p != &painter) | 227 | if (p != &painter) |
197 | { | 228 | { |
198 | p->end(); | 229 | p->end(); |
199 | QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); | 230 | QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); |
200 | int xoff = scaledCard->width() / 2; | 231 | int xoff = scaledCard->width() / 2; |
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 | |||
@@ -10,44 +10,48 @@ | |||
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 <qpainter.h> | 20 | #include <qpainter.h> |
21 | #include <qcanvas.h> | 21 | #include <qcanvas.h> |
22 | #include <qgfx_qws.h> | ||
22 | #include "canvasshapes.h" | 23 | #include "canvasshapes.h" |
23 | 24 | ||
24 | 25 | ||
25 | CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : | 26 | CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : |
26 | QCanvasRectangle( x, y, 23, 36, canvas) | 27 | QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas) |
27 | { | 28 | { |
28 | setZ(0); | 29 | setZ(0); |
29 | show(); | 30 | show(); |
30 | } | 31 | } |
31 | 32 | ||
32 | 33 | ||
33 | void CanvasRoundRect::redraw() | 34 | void CanvasRoundRect::redraw() |
34 | { | 35 | { |
35 | hide(); | 36 | hide(); |
36 | show(); | 37 | show(); |
37 | } | 38 | } |
38 | 39 | ||
39 | 40 | ||
40 | void CanvasRoundRect::drawShape(QPainter &p) | 41 | void CanvasRoundRect::drawShape(QPainter &p) |
41 | { | 42 | { |
43 | if ( qt_screen->deviceWidth() < 200 ) | ||
44 | p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25); | ||
45 | else | ||
42 | p.drawRoundRect( (int)x(), (int)y(), 23, 36); | 46 | p.drawRoundRect( (int)x(), (int)y(), 23, 36); |
43 | } | 47 | } |
44 | 48 | ||
45 | 49 | ||
46 | CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) : | 50 | CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) : |
47 | QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE) | 51 | QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE) |
48 | { | 52 | { |
49 | show(); | 53 | show(); |
50 | } | 54 | } |
51 | 55 | ||
52 | 56 | ||
53 | void CanvasCircleOrCross::redraw() | 57 | void CanvasCircleOrCross::redraw() |
@@ -64,29 +68,47 @@ void CanvasCircleOrCross::setCircle() | |||
64 | } | 68 | } |
65 | 69 | ||
66 | 70 | ||
67 | void CanvasCircleOrCross::setCross() | 71 | void CanvasCircleOrCross::setCross() |
68 | { | 72 | { |
69 | circleShape = FALSE; | 73 | circleShape = FALSE; |
70 | redraw(); | 74 | redraw(); |
71 | } | 75 | } |
72 | 76 | ||
73 | 77 | ||
74 | void CanvasCircleOrCross::drawShape(QPainter &p) | 78 | void CanvasCircleOrCross::drawShape(QPainter &p) |
75 | { | 79 | { |
80 | if ( qt_screen->deviceWidth() < 200 ) { | ||
81 | int x1 = (int)x(), y1 = (int)y(); | ||
82 | // Green circle | ||
83 | if (circleShape == TRUE) { | ||
84 | p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); | ||
85 | p.drawEllipse( x1 - 1, y1 - 1, 17, 17); | ||
86 | p.drawEllipse( x1 - 1, y1 - 0, 17, 15); | ||
87 | p.drawEllipse( x1 + 0, y1 + 0, 15, 15); | ||
88 | p.drawEllipse( x1 + 1, y1 + 0, 13, 15); | ||
89 | p.drawEllipse( x1 + 1, y1 + 1, 13, 13); | ||
90 | // Red cross | ||
91 | } else { | ||
92 | p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) ); | ||
93 | p.drawLine( x1, y1, x1 + 14, y1 + 14); | ||
94 | p.drawLine( x1 + 14, y1, x1, y1 + 14); | ||
95 | } | ||
96 | } else { | ||
76 | int x1 = (int)x(), y1 = (int)y(); | 97 | int x1 = (int)x(), y1 = (int)y(); |
77 | // Green circle | 98 | // Green circle |
78 | if (circleShape == TRUE) { | 99 | if (circleShape == TRUE) { |
79 | p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); | 100 | p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); |
80 | p.drawEllipse( x1 - 1, y1 - 1, 21, 21); | 101 | p.drawEllipse( x1 - 1, y1 - 1, 21, 21); |
81 | p.drawEllipse( x1 - 1, y1 - 0, 21, 19); | 102 | p.drawEllipse( x1 - 1, y1 - 0, 21, 19); |
82 | p.drawEllipse( x1 + 0, y1 + 0, 19, 19); | 103 | p.drawEllipse( x1 + 0, y1 + 0, 19, 19); |
83 | p.drawEllipse( x1 + 1, y1 + 0, 17, 19); | 104 | p.drawEllipse( x1 + 1, y1 + 0, 17, 19); |
84 | p.drawEllipse( x1 + 1, y1 + 1, 17, 17); | 105 | p.drawEllipse( x1 + 1, y1 + 1, 17, 17); |
85 | // Red cross | 106 | // Red cross |
86 | } else { | 107 | } else { |
87 | p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) ); | 108 | p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) ); |
88 | p.drawLine( x1, y1, x1 + 20, y1 + 20); | 109 | p.drawLine( x1, y1, x1 + 20, y1 + 20); |
89 | p.drawLine( x1 + 20, y1, x1, y1 + 20); | 110 | p.drawLine( x1 + 20, y1, x1, y1 + 20); |
90 | } | 111 | } |
91 | } | 112 | } |
113 | } | ||
92 | 114 | ||
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 | |||
@@ -8,46 +8,51 @@ | |||
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++) { |
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) |
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 | |||
@@ -16,24 +16,25 @@ | |||
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 | #ifndef PATIENCE_CARD_GAME_H | 20 | #ifndef PATIENCE_CARD_GAME_H |
21 | #define PATIENCE_CARD_GAME_H | 21 | #define PATIENCE_CARD_GAME_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qintdict.h> | 26 | #include <qintdict.h> |
27 | #include <qcanvas.h> | 27 | #include <qcanvas.h> |
28 | #include <qgfx_qws.h> | ||
28 | // #include "canvascardshapes.h" | 29 | // #include "canvascardshapes.h" |
29 | // #include "canvascard.h" | 30 | // #include "canvascard.h" |
30 | #include "canvascardgame.h" | 31 | #include "canvascardgame.h" |
31 | 32 | ||
32 | 33 | ||
33 | class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect | 34 | class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect |
34 | { | 35 | { |
35 | public: | 36 | public: |
36 | PatienceFaceDownDeck(int x, int y, QCanvas *canvas) | 37 | PatienceFaceDownDeck(int x, int y, QCanvas *canvas) |
37 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } | 38 | : CardPile(x, y), CanvasRoundRect(x, y, canvas) { } |
38 | virtual bool isAllowedOnTop(Card *card) { | 39 | virtual bool isAllowedOnTop(Card *card) { |
39 | Q_UNUSED(card); | 40 | Q_UNUSED(card); |
@@ -121,40 +122,42 @@ public: | |||
121 | Q_UNUSED(card); | 122 | Q_UNUSED(card); |
122 | 123 | ||
123 | Card *newTopCard = cardOnTop(); | 124 | Card *newTopCard = cardOnTop(); |
124 | 125 | ||
125 | if ( !newTopCard ) { | 126 | if ( !newTopCard ) { |
126 | top = QPoint( pileX, pileY ); | 127 | top = QPoint( pileX, pileY ); |
127 | setNextX( pileX ); | 128 | setNextX( pileX ); |
128 | setNextY( pileY ); | 129 | setNextY( pileY ); |
129 | return; | 130 | return; |
130 | } else { | 131 | } else { |
131 | top = getCardPos(NULL); | 132 | top = getCardPos(NULL); |
132 | if ( newTopCard->isFacing() == FALSE ) { | 133 | if ( newTopCard->isFacing() == FALSE ) { |
134 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; | ||
133 | // correct the position taking in to account the card is not | 135 | // correct the position taking in to account the card is not |
134 | // yet flipped, but will become flipped | 136 | // yet flipped, but will become flipped |
135 | top = QPoint( top.x() - 1, top.y() - 3 ); | 137 | top = QPoint( top.x() - 1, top.y() - 3 ); |
136 | newTopCard->flipTo( top.x(), top.y() ); | 138 | newTopCard->flipTo( top.x(), top.y() ); |
137 | top = QPoint( top.x(), top.y() + 13 ); | 139 | top = QPoint( top.x(), top.y() + offsetDown ); |
138 | } | 140 | } |
139 | setNextX( top.x() ); | 141 | setNextX( top.x() ); |
140 | setNextY( top.y() ); | 142 | setNextY( top.y() ); |
141 | } | 143 | } |
142 | } | 144 | } |
143 | virtual QPoint getCardPos(Card *c) { | 145 | virtual QPoint getCardPos(Card *c) { |
144 | int x = pileX, y = pileY; | 146 | int x = pileX, y = pileY; |
145 | Card *card = cardOnBottom(); | 147 | Card *card = cardOnBottom(); |
146 | while ((card != c) && (card != NULL)) { | 148 | while ((card != c) && (card != NULL)) { |
147 | if (card->isFacing()) { | 149 | if (card->isFacing()) { |
148 | y += 13; | 150 | int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; |
151 | y += offsetDown; | ||
149 | } else { | 152 | } else { |
150 | x += 1; | 153 | x += 1; |
151 | y += 3; | 154 | y += 3; |
152 | } | 155 | } |
153 | card = cardInfront(card); | 156 | card = cardInfront(card); |
154 | } | 157 | } |
155 | return QPoint( x, y ); | 158 | return QPoint( x, y ); |
156 | } | 159 | } |
157 | virtual QPoint getHypertheticalNextCardPos(void) { | 160 | virtual QPoint getHypertheticalNextCardPos(void) { |
158 | return top; | 161 | return top; |
159 | // return QPoint( getNextX(), getNextY() ); | 162 | // return QPoint( getNextX(), getNextY() ); |
160 | } | 163 | } |