summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp120
-rw-r--r--noncore/games/solitaire/opie-solitaire.control2
2 files changed, 66 insertions, 56 deletions
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index 450b4db..e836eb2 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -38,17 +38,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
38{ 38{
39 setIcon( Resource::loadPixmap( "cards" ) ); 39 setIcon( Resource::loadPixmap( "cards" ) );
40 40
41 // Create Playing Area for Games 41 // Create Playing Area for Games
42 if ( QPixmap::defaultDepth() < 12 ) { 42 if ( QPixmap::defaultDepth() < 12 ) {
43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); 43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B));
44 //canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); 44// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50));
45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); 45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D));
46 } else { 46 } else {
47 QPixmap bg; 47 QPixmap bg;
48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); 48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither );
49 canvas.setBackgroundPixmap(bg); 49 canvas.setBackgroundPixmap(bg);
50 } 50 }
51 51
52#if defined( QT_QWS_CASSIOPEIA ) 52#if defined( QT_QWS_CASSIOPEIA )
53 canvas.setAdvancePeriod(70); 53 canvas.setAdvancePeriod(70);
54#else 54#else
@@ -99,78 +99,82 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
99 settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks())); 99 settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks()));
100 snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle())); 100 snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle()));
101 QString m; 101 QString m;
102 102
103 drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle())); 103 drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle()));
104 menu->insertItem(tr("Settings"),settings); 104 menu->insertItem(tr("Settings"),settings);
105 settings->setCheckable(TRUE);
105 106
106#endif 107#endif
107 108
108 menu->show(); 109 menu->show();
109 110
110 Config cfg( "Patience" ); 111 Config cfg( "Patience" );
111 cfg.setGroup( "GlobalSettings" ); 112 cfg.setGroup( "GlobalSettings" );
112 snapOn = cfg.readBoolEntry( "SnapOn", TRUE); 113 snapOn = cfg.readBoolEntry( "SnapOn", TRUE);
113 settings->setItemChecked(snap_id, snapOn); 114 settings->setItemChecked(snap_id, snapOn);
115
114 gameType = cfg.readNumEntry( "GameType", -1 ); 116 gameType = cfg.readNumEntry( "GameType", -1 );
115 drawThree = cfg.readBoolEntry( "DrawThree", TRUE); 117 drawThree = cfg.readBoolEntry( "DrawThree", FALSE);
116 if ( gameType == 0 ) { 118 if ( gameType == 0 ) {
117 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 119 cardGame = new PatienceCardGame( &canvas, snapOn, this );
118 cardGame->setNumberToDraw(drawThree ? 3 : 1); 120 cardGame->setNumberToDraw(drawThree ? 3 : 1);
119 setCaption(tr("Patience")); 121
120 setCentralWidget(cardGame); 122 setCaption(tr("Patience"));
121 cardGame->readConfig( cfg ); 123 setCentralWidget(cardGame);
122 setCardBacks(); 124 cardGame->readConfig( cfg );
125 setCardBacks();
123 } else if ( gameType == 1 ) { 126 } else if ( gameType == 1 ) {
124 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 127 cardGame = new FreecellCardGame( &canvas, snapOn, this );
125 setCaption(tr("Freecell")); 128 setCaption(tr("Freecell"));
126 setCentralWidget(cardGame); 129 setCentralWidget(cardGame);
127 //cardGame->newGame(); // Until we know how to handle reading freecell config 130 //cardGame->newGame(); // Until we know how to handle reading freecell config
128 cardGame->readConfig( cfg ); 131 cardGame->readConfig( cfg );
129 setCardBacks(); 132 setCardBacks();
130 } else if ( gameType == 2 ) { 133 } else if ( gameType == 2 ) {
131 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 134 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
132 cardGame->setNumberToDraw(1); 135 cardGame->setNumberToDraw(1);
133 setCaption(tr("Chicane")); 136 setCaption(tr("Chicane"));
134 setCentralWidget(cardGame); 137 setCentralWidget(cardGame);
135 cardGame->readConfig( cfg ); 138 cardGame->readConfig( cfg );
136 setCardBacks(); 139 setCardBacks();
137 } else if ( gameType == 3 ) { 140 } else if ( gameType == 3 ) {
138 cardGame = new HarpCardGame( &canvas, snapOn, this ); 141 cardGame = new HarpCardGame( &canvas, snapOn, this );
139 cardGame->setNumberToDraw(1); 142 cardGame->setNumberToDraw(1);
140 setCaption(tr("Harp")); 143 setCaption(tr("Harp"));
141 setCentralWidget(cardGame); 144 setCentralWidget(cardGame);
142 cardGame->readConfig( cfg ); 145 cardGame->readConfig( cfg );
143 setCardBacks(); 146 setCardBacks();
144 } else if ( gameType == 4 ) { 147 } else if ( gameType == 4 ) {
145 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 148 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
146 cardGame->setNumberToDraw(1); 149 cardGame->setNumberToDraw(1);
147 setCaption(tr("Teeclub")); 150 setCaption(tr("Teeclub"));
148 setCentralWidget(cardGame); 151 setCentralWidget(cardGame);
149 cardGame->readConfig( cfg ); 152 cardGame->readConfig( cfg );
150 setCardBacks(); 153 setCardBacks();
151 } else { 154 } else {
152 // Probably there isn't a config file or it is broken 155 // Probably there isn't a config file or it is broken
153 // Start a new game 156 // Start a new game
154 initPatience(); 157 initPatience();
155 } 158 }
156 159
157 updateDraw(); 160 updateDraw();
158} 161}
159 162
160 163
161CanvasCardWindow::~CanvasCardWindow() 164CanvasCardWindow::~CanvasCardWindow()
162{ 165{
163 if (cardGame) { 166 if (cardGame) {
164 Config cfg("Patience"); 167 Config cfg("Patience");
165 cfg.setGroup( "GlobalSettings" ); 168 cfg.setGroup( "GlobalSettings" );
166 cfg.writeEntry( "GameType", gameType ); 169 cfg.writeEntry( "GameType", gameType );
167 cfg.writeEntry( "SnapOn", snapOn ); 170 cfg.writeEntry( "SnapOn", snapOn );
168 cfg.writeEntry( "DrawThree", drawThree); 171 cfg.writeEntry( "DrawThree", drawThree);
169 cardGame->writeConfig( cfg ); 172 cfg.write();
170 delete cardGame; 173 cardGame->writeConfig( cfg );
174 delete cardGame;
171 } 175 }
172} 176}
173 177
174 178
175void CanvasCardWindow::resizeEvent(QResizeEvent *) 179void CanvasCardWindow::resizeEvent(QResizeEvent *)
176{ 180{
@@ -181,13 +185,13 @@ void CanvasCardWindow::resizeEvent(QResizeEvent *)
181 185
182 186
183void CanvasCardWindow::initPatience() 187void CanvasCardWindow::initPatience()
184{ 188{
185 // Create New Game 189 // Create New Game
186 if ( cardGame ) 190 if ( cardGame )
187 delete cardGame; 191 delete cardGame;
188 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 192 cardGame = new PatienceCardGame( &canvas, snapOn, this );
189 cardGame->setNumberToDraw(drawThree ? 3 : 1); 193 cardGame->setNumberToDraw(drawThree ? 3 : 1);
190 gameType = 0; 194 gameType = 0;
191 setCaption(tr("Patience")); 195 setCaption(tr("Patience"));
192 setCentralWidget(cardGame); 196 setCentralWidget(cardGame);
193 cardGame->newGame(); 197 cardGame->newGame();
@@ -197,13 +201,13 @@ void CanvasCardWindow::initPatience()
197 201
198 202
199void CanvasCardWindow::initFreecell() 203void CanvasCardWindow::initFreecell()
200{ 204{
201 // Create New Game 205 // Create New Game
202 if ( cardGame ) { 206 if ( cardGame ) {
203 delete cardGame; 207 delete cardGame;
204 } 208 }
205 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 209 cardGame = new FreecellCardGame( &canvas, snapOn, this );
206 gameType = 1; 210 gameType = 1;
207 setCaption(tr("Freecell")); 211 setCaption(tr("Freecell"));
208 setCentralWidget(cardGame); 212 setCentralWidget(cardGame);
209 cardGame->newGame(); 213 cardGame->newGame();
@@ -212,13 +216,13 @@ void CanvasCardWindow::initFreecell()
212 216
213 217
214void CanvasCardWindow::initChicane() 218void CanvasCardWindow::initChicane()
215{ 219{
216 // Create New Game 220 // Create New Game
217 if ( cardGame ) { 221 if ( cardGame ) {
218 delete cardGame; 222 delete cardGame;
219 } 223 }
220 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 224 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
221 cardGame->setNumberToDraw(1); 225 cardGame->setNumberToDraw(1);
222 gameType = 2; 226 gameType = 2;
223 setCaption(tr("Chicane")); 227 setCaption(tr("Chicane"));
224 setCentralWidget(cardGame); 228 setCentralWidget(cardGame);
@@ -227,13 +231,13 @@ void CanvasCardWindow::initChicane()
227} 231}
228 232
229void CanvasCardWindow::initHarp() 233void CanvasCardWindow::initHarp()
230{ 234{
231 // Create New Game 235 // Create New Game
232 if ( cardGame ) { 236 if ( cardGame ) {
233 delete cardGame; 237 delete cardGame;
234 } 238 }
235 cardGame = new HarpCardGame( &canvas, snapOn, this ); 239 cardGame = new HarpCardGame( &canvas, snapOn, this );
236 cardGame->setNumberToDraw(1); 240 cardGame->setNumberToDraw(1);
237 gameType = 3; 241 gameType = 3;
238 setCaption(tr("Harp")); 242 setCaption(tr("Harp"));
239 setCentralWidget(cardGame); 243 setCentralWidget(cardGame);
@@ -265,40 +269,46 @@ void CanvasCardWindow::snapToggle()
265 cardGame->toggleSnap(); 269 cardGame->toggleSnap();
266} 270}
267 271
268 272
269void CanvasCardWindow::drawnToggle() 273void CanvasCardWindow::drawnToggle()
270{ 274{
275 drawThree=!drawThree;
276 Config cfg( "Patience" );
277 cfg.setGroup( "GlobalSettings" );
271 cardGame->toggleCardsDrawn(); 278 cardGame->toggleCardsDrawn();
272 updateDraw(); 279 updateDraw();
280 cfg.writeEntry( "DrawThree", drawThree);
281 cfg.write();
273} 282}
274 283
275void CanvasCardWindow::updateDraw() { 284void CanvasCardWindow::updateDraw() {
276 if(cardGame->cardsDrawn() == 3) 285 if(cardGame->cardsDrawn() == 3){
277 settings->changeItem(drawId, tr("Turn One Card")); 286 settings->changeItem(drawId, tr("Turn One Card"));
278 else 287 } else {
279 settings->changeItem(drawId, tr("Turn Three Cards")); 288 settings->changeItem(drawId, tr("Turn Three Cards"));
289 }
280} 290}
281 291
282 292
283void CanvasCardWindow::setCardBacks() 293void CanvasCardWindow::setCardBacks()
284{ 294{
285 QCanvasItemList l = canvas.allItems(); 295 QCanvasItemList l = canvas.allItems();
286 296
287 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { 297 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
288 if ( (*it)->rtti() == canvasCardId ) 298 if ( (*it)->rtti() == canvasCardId )
289 ((CanvasCard *)(*it))->setCardBack( cardBack ); 299 ((CanvasCard *)(*it))->setCardBack( cardBack );
290 } 300 }
291} 301}
292 302
293 303
294void CanvasCardWindow::changeCardBacks() 304void CanvasCardWindow::changeCardBacks()
295{ 305{
296 cardBack++; 306 cardBack++;
297 307
298 if (cardBack == 5) 308 if (cardBack == 5)
299 cardBack = 0; 309 cardBack = 0;
300 310
301 setCardBacks(); 311 setCardBacks();
302} 312}
303 313
304 314
diff --git a/noncore/games/solitaire/opie-solitaire.control b/noncore/games/solitaire/opie-solitaire.control
index f70fefa..4389360 100644
--- a/noncore/games/solitaire/opie-solitaire.control
+++ b/noncore/games/solitaire/opie-solitaire.control
@@ -1,7 +1,7 @@
1Files: bin/patience apps/Games/patience.desktop pics/cards 1Files: bin/patience apps/Games/patience.desktop pics/cards
2Priority: optional 2Priority: optional
3Section: opie/games 3Section: opie/games
4Maintainer: Martin Imobersteg <imm@gmx.ch> 4Maintainer: Martin Imobersteg <imm@gmx.ch>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)