-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 120 | ||||
-rw-r--r-- | noncore/games/solitaire/opie-solitaire.control | 2 |
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 | |||
@@ -41,11 +41,11 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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 | ||
@@ -102,6 +102,7 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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 | ||
@@ -111,47 +112,49 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
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(); |
@@ -161,13 +164,14 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
161 | CanvasCardWindow::~CanvasCardWindow() | 164 | CanvasCardWindow::~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 | ||
@@ -184,7 +188,7 @@ void 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; |
@@ -200,7 +204,7 @@ void 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; |
@@ -215,7 +219,7 @@ void 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); |
@@ -230,7 +234,7 @@ void 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); |
@@ -268,15 +272,21 @@ void CanvasCardWindow::snapToggle() | |||
268 | 272 | ||
269 | void CanvasCardWindow::drawnToggle() | 273 | void 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 | ||
275 | void CanvasCardWindow::updateDraw() { | 284 | void 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 | ||
@@ -285,8 +295,8 @@ void CanvasCardWindow::setCardBacks() | |||
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 | ||
@@ -296,7 +306,7 @@ void CanvasCardWindow::changeCardBacks() | |||
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 | } |
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,4 +1,4 @@ | |||
1 | Files: bin/patience apps/Games/patience.desktop pics/cards | 1 | Files: bin/patience apps/Games/patience.desktop pics/cards |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/games | 3 | Section: opie/games |
4 | Maintainer: Martin Imobersteg <imm@gmx.ch> | 4 | Maintainer: Martin Imobersteg <imm@gmx.ch> |