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
@@ -28,37 +28,37 @@
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30#include <qmainwindow.h> 30#include <qmainwindow.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qstyle.h> 32#include <qstyle.h>
33 33
34 34
35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : 35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) :
36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), 36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0),
37 cardGame(NULL) 37 cardGame(NULL)
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
55 canvas.setAdvancePeriod(30); 55 canvas.setAdvancePeriod(30);
56#endif 56#endif
57 57
58 58
59#ifdef _PATIENCE_USE_ACCELS_ 59#ifdef _PATIENCE_USE_ACCELS_
60 QPEMenuBar* menu = menuBar(); 60 QPEMenuBar* menu = menuBar();
61 61
62 QPopupMenu* file = new QPopupMenu; 62 QPopupMenu* file = new QPopupMenu;
63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
@@ -89,161 +89,165 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
90 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 90 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
91 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 91 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); 92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
93 menu->insertItem(tr("Play"), file); 93 menu->insertItem(tr("Play"), file);
94 94
95 menu->insertSeparator(); 95 menu->insertSeparator();
96 96
97 settings = new QPopupMenu; 97 settings = new QPopupMenu;
98 settings->setCheckable(TRUE); 98 settings->setCheckable(TRUE);
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{
177 QSize s = centralWidget()->size(); 181 QSize s = centralWidget()->size();
178 int fw = style().defaultFrameWidth(); 182 int fw = style().defaultFrameWidth();
179 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 183 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
180} 184}
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();
194 setCardBacks(); 198 setCardBacks();
195 updateDraw(); 199 updateDraw();
196} 200}
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();
210 setCardBacks(); 214 setCardBacks();
211} 215}
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);
225 cardGame->newGame(); 229 cardGame->newGame();
226 setCardBacks(); 230 setCardBacks();
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);
240 cardGame->newGame(); 244 cardGame->newGame();
241 setCardBacks(); 245 setCardBacks();
242} 246}
243 247
244 248
245void CanvasCardWindow::initTeeclub() 249void CanvasCardWindow::initTeeclub()
246{ 250{
247 // Create New Game 251 // Create New Game
248 if ( cardGame ) { 252 if ( cardGame ) {
249 delete cardGame; 253 delete cardGame;
@@ -255,50 +259,56 @@ void CanvasCardWindow::initTeeclub()
255 setCentralWidget(cardGame); 259 setCentralWidget(cardGame);
256 cardGame->newGame(); 260 cardGame->newGame();
257 setCardBacks(); 261 setCardBacks();
258} 262}
259 263
260 264
261void CanvasCardWindow::snapToggle() 265void CanvasCardWindow::snapToggle()
262{ 266{
263 snapOn = !snapOn; 267 snapOn = !snapOn;
264 settings->setItemChecked(snap_id, snapOn); 268 settings->setItemChecked(snap_id, snapOn);
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,9 +1,9 @@
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)
8Description: Game: solitaire card games 8Description: Game: solitaire card games
9 A solitaire game for the Opie environment. 9 A solitaire game for the Opie environment.