summaryrefslogtreecommitdiff
path: root/noncore/games/solitaire
Unidiff
Diffstat (limited to 'noncore/games/solitaire') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp15
-rw-r--r--noncore/games/solitaire/canvascardwindow.h1
-rw-r--r--noncore/games/solitaire/carddeck.cpp2
-rw-r--r--noncore/games/solitaire/main.cpp14
-rwxr-xr-xnoncore/games/solitaire/solitaire.pro5
5 files changed, 14 insertions, 23 deletions
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index dec5591..c12344a 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -28,79 +28,80 @@
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 setCaption(tr("Patience"));
40 41
41 // Create Playing Area for Games 42 // Create Playing Area for Games
42 if ( QPixmap::defaultDepth() < 12 ) { 43 if ( QPixmap::defaultDepth() < 12 ) {
43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); 44// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B));
44// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); 45// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50));
45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); 46 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D));
46 } else { 47 } else {
47 QPixmap bg; 48 QPixmap bg;
48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); 49 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither );
49 canvas.setBackgroundPixmap(bg); 50 canvas.setBackgroundPixmap(bg);
50 } 51 }
51 52
52#if defined( QT_QWS_CASSIOPEIA ) 53#if defined( QT_QWS_CASSIOPEIA )
53 canvas.setAdvancePeriod(70); 54 canvas.setAdvancePeriod(70);
54#else 55#else
55 canvas.setAdvancePeriod(30); 56 canvas.setAdvancePeriod(30);
56#endif 57#endif
57 58
58 59
59#ifdef _PATIENCE_USE_ACCELS_ 60#ifdef _PATIENCE_USE_ACCELS_
60 QMenuBar* menu = menuBar(); 61 QMenuBar* menu = menuBar();
61 62
62 QPopupMenu* file = new QPopupMenu; 63 QPopupMenu* file = new QPopupMenu;
63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 64 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 65 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
65 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); 66 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
66 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); 67 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
67 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); 68 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F);
68 menu->insertItem(tr("&Game"), file); 69 menu->insertItem(tr("&Game"), file);
69 70
70 menu->insertSeparator(); 71 menu->insertSeparator();
71 72
72 settings = new QPopupMenu; 73 settings = new QPopupMenu;
73 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); 74 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2);
74 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); 75 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3);
75 settings->setCheckable(TRUE); 76 settings->setCheckable(TRUE);
76 menu->insertItem(tr("&Settings"),settings); 77 menu->insertItem(tr("&Settings"),settings);
77 78
78 menu->insertSeparator(); 79 menu->insertSeparator();
79 80
80 QPopupMenu* help = new QPopupMenu; 81 QPopupMenu* help = new QPopupMenu;
81 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); 82 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1);
82 help->setItemChecked(dbf_id, TRUE); 83 help->setItemChecked(dbf_id, TRUE);
83 menu->insertItem(tr("&Help"),help); 84 menu->insertItem(tr("&Help"),help);
84#else 85#else
85 QMenuBar* menu = menuBar(); 86 QMenuBar* menu = menuBar();
86 87
87 QPopupMenu* file = new QPopupMenu; 88 QPopupMenu* file = new QPopupMenu;
88 file->insertItem(tr("Patience"), this, SLOT(initPatience())); 89 file->insertItem(tr("Patience"), this, SLOT(initPatience()));
89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 90 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
90 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 91 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
91 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 92 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); 93 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
93 menu->insertItem(tr("Play"), file); 94 menu->insertItem(tr("Play"), file);
94 95
95 menu->insertSeparator(); 96 menu->insertSeparator();
96 97
97 settings = new QPopupMenu; 98 settings = new QPopupMenu;
98 settings->setCheckable(TRUE); 99 settings->setCheckable(TRUE);
99 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); 100 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks()));
100 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); 101 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle()));
101 QString m; 102 QString m;
102 103
103 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle())); 104 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle()));
104 menu->insertItem(tr("Settings"),settings); 105 menu->insertItem(tr("Settings"),settings);
105 settings->setCheckable(TRUE); 106 settings->setCheckable(TRUE);
106 107
@@ -109,25 +110,25 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f)
109 menu->show(); 110 menu->show();
110 111
111 Config cfg( "Patience" ); 112 Config cfg( "Patience" );
112 cfg.setGroup( "GlobalSettings" ); 113 cfg.setGroup( "GlobalSettings" );
113 snapOn = cfg.readBoolEntry( "SnapOn", TRUE); 114 snapOn = cfg.readBoolEntry( "SnapOn", TRUE);
114 settings->setItemChecked(snap_id, snapOn); 115 settings->setItemChecked(snap_id, snapOn);
115 116
116 gameType = cfg.readNumEntry( "GameType", -1 ); 117 gameType = cfg.readNumEntry( "GameType", -1 );
117 drawThree = cfg.readBoolEntry( "DrawThree", FALSE); 118 drawThree = cfg.readBoolEntry( "DrawThree", FALSE);
118 if ( gameType == 0 ) { 119 if ( gameType == 0 ) {
119 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 120 cardGame = new PatienceCardGame( &canvas, snapOn, this );
120 cardGame->setNumberToDraw(drawThree ? 3 : 1); 121 cardGame->setNumberToDraw(drawThree ? 3 : 1);
121 122
122 setCaption(tr("Patience")); 123 setCaption(tr("Patience"));
123 setCentralWidget(cardGame); 124 setCentralWidget(cardGame);
124 cardGame->readConfig( cfg ); 125 cardGame->readConfig( cfg );
125 setCardBacks(); 126 setCardBacks();
126 } else if ( gameType == 1 ) { 127 } else if ( gameType == 1 ) {
127 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 128 cardGame = new FreecellCardGame( &canvas, snapOn, this );
128 setCaption(tr("Freecell")); 129 setCaption(tr("Freecell"));
129 setCentralWidget(cardGame); 130 setCentralWidget(cardGame);
130 //cardGame->newGame(); // Until we know how to handle reading freecell config 131 //cardGame->newGame(); // Until we know how to handle reading freecell config
131 cardGame->readConfig( cfg ); 132 cardGame->readConfig( cfg );
132 setCardBacks(); 133 setCardBacks();
133 } else if ( gameType == 2 ) { 134 } else if ( gameType == 2 ) {
@@ -177,25 +178,25 @@ CanvasCardWindow::~CanvasCardWindow()
177 178
178 179
179void CanvasCardWindow::resizeEvent(QResizeEvent *) 180void CanvasCardWindow::resizeEvent(QResizeEvent *)
180{ 181{
181 QSize s = centralWidget()->size(); 182 QSize s = centralWidget()->size();
182 int fw = style().defaultFrameWidth(); 183 int fw = style().defaultFrameWidth();
183 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 184 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
184} 185}
185 186
186 187
187void CanvasCardWindow::initPatience() 188void CanvasCardWindow::initPatience()
188{ 189{
189 // Create New Game 190 // Create New Game
190 if ( cardGame ) 191 if ( cardGame )
191 delete cardGame; 192 delete cardGame;
192 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 193 cardGame = new PatienceCardGame( &canvas, snapOn, this );
193 cardGame->setNumberToDraw(drawThree ? 3 : 1); 194 cardGame->setNumberToDraw(drawThree ? 3 : 1);
194 gameType = 0; 195 gameType = 0;
195 setCaption(tr("Patience")); 196 setCaption(tr("Patience"));
196 setCentralWidget(cardGame); 197 setCentralWidget(cardGame);
197 cardGame->newGame(); 198 cardGame->newGame();
198 setCardBacks(); 199 setCardBacks();
199 updateDraw(); 200 updateDraw();
200} 201}
201 202
@@ -244,31 +245,31 @@ void CanvasCardWindow::initHarp()
244 cardGame->newGame(); 245 cardGame->newGame();
245 setCardBacks(); 246 setCardBacks();
246} 247}
247 248
248 249
249void CanvasCardWindow::initTeeclub() 250void CanvasCardWindow::initTeeclub()
250{ 251{
251 // Create New Game 252 // Create New Game
252 if ( cardGame ) { 253 if ( cardGame ) {
253 delete cardGame; 254 delete cardGame;
254 } 255 }
255 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 256 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
256 cardGame->setNumberToDraw(1); 257 cardGame->setNumberToDraw(1);
257 gameType = 4; 258 gameType = 4;
258 setCaption(tr("Teeclub")); 259 setCaption(tr("Teeclub"));
259 setCentralWidget(cardGame); 260 setCentralWidget(cardGame);
260 cardGame->newGame(); 261 cardGame->newGame();
261 setCardBacks(); 262 setCardBacks();
262} 263}
263 264
264 265
265void CanvasCardWindow::snapToggle() 266void CanvasCardWindow::snapToggle()
266{ 267{
267 snapOn = !snapOn; 268 snapOn = !snapOn;
268 settings->setItemChecked(snap_id, snapOn); 269 settings->setItemChecked(snap_id, snapOn);
269 cardGame->toggleSnap(); 270 cardGame->toggleSnap();
270} 271}
271 272
272 273
273void CanvasCardWindow::drawnToggle() 274void CanvasCardWindow::drawnToggle()
274{ 275{
diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h
index eddb184..abd6af6 100644
--- a/noncore/games/solitaire/canvascardwindow.h
+++ b/noncore/games/solitaire/canvascardwindow.h
@@ -24,24 +24,25 @@
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qcanvas.h> 25#include <qcanvas.h>
26 26
27 27
28class CanvasCardGame; 28class CanvasCardGame;
29class QPopupMenu; 29class QPopupMenu;
30 30
31 31
32class CanvasCardWindow : public QMainWindow { 32class CanvasCardWindow : public QMainWindow {
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 static QString appName() { return QString::fromLatin1("patience"); }
36 CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0); 37 CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0);
37 virtual ~CanvasCardWindow(); 38 virtual ~CanvasCardWindow();
38 39
39public slots: 40public slots:
40 void setCardBacks(); 41 void setCardBacks();
41 void changeCardBacks(); 42 void changeCardBacks();
42 void snapToggle(); 43 void snapToggle();
43 void drawnToggle(); 44 void drawnToggle();
44 45
45private slots: 46private slots:
46 void initFreecell(); 47 void initFreecell();
47 void initPatience(); 48 void initPatience();
diff --git a/noncore/games/solitaire/carddeck.cpp b/noncore/games/solitaire/carddeck.cpp
index a2d0076..b130131 100644
--- a/noncore/games/solitaire/carddeck.cpp
+++ b/noncore/games/solitaire/carddeck.cpp
@@ -16,25 +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#include <stdlib.h> 20#include <stdlib.h>
21#include <time.h> 21#include <time.h>
22#include "card.h" 22#include "card.h"
23#include "carddeck.h" 23#include "carddeck.h"
24 24
25 25
26CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE) 26CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE)
27{ 27{
28 cards = new (Card *)[getNumberOfCards()]; 28 cards = new Card *[getNumberOfCards()];
29} 29}
30 30
31 31
32CardDeck::~CardDeck() 32CardDeck::~CardDeck()
33{ 33{
34 for (int i = 0; i < getNumberOfCards(); i++) 34 for (int i = 0; i < getNumberOfCards(); i++)
35 delete cards[i]; 35 delete cards[i];
36 delete cards; 36 delete cards;
37} 37}
38 38
39 39
40void CardDeck::createDeck() 40void CardDeck::createDeck()
diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp
index f81aa3c..bd3cf8b 100644
--- a/noncore/games/solitaire/main.cpp
+++ b/noncore/games/solitaire/main.cpp
@@ -12,25 +12,15 @@
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 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25 26OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file
26int main( int argc, char ** argv )
27{
28 QPEApplication a( argc, argv );
29
30 CanvasCardWindow m;
31 m.setCaption( CanvasCardWindow::tr("Patience") );
32 a.showMainWidget( &m );
33
34 return a.exec();
35}
36
diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro
index 1ac62c3..b1b8bda 100755
--- a/noncore/games/solitaire/solitaire.pro
+++ b/noncore/games/solitaire/solitaire.pro
@@ -1,21 +1,20 @@
1TEMPLATE = app
2 1
3CONFIG += qt warn_on release 2CONFIG += qt warn_on release quick-app
4DESTDIR = $(OPIEDIR)/bin
5 3
6HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \ 4HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \
7 canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \ 5 canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \
8 patiencecardgame.h canvascardwindow.h 6 patiencecardgame.h canvascardwindow.h
9 7
10SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \ 8SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \
11 cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp \ 9 cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp \
12 chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp \ 10 chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp \
13 patiencecardgame.cpp canvascardwindow.cpp main.cpp 11 patiencecardgame.cpp canvascardwindow.cpp main.cpp
14 12
15TARGET = patience 13TARGET = patience
16 14
17INCLUDEPATH += $(OPIEDIR)/include 15INCLUDEPATH += $(OPIEDIR)/include
18DEPENDPATH += $(OPIEDIR)/include 16DEPENDPATH += $(OPIEDIR)/include
19LIBS += -lqpe 17LIBS += -lqpe
20 18
19
21include ( $(OPIEDIR)/include.pro ) 20include ( $(OPIEDIR)/include.pro )