-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.h | 1 | ||||
-rw-r--r-- | noncore/games/solitaire/carddeck.cpp | 2 | ||||
-rw-r--r-- | noncore/games/solitaire/main.cpp | 14 | ||||
-rwxr-xr-x | noncore/games/solitaire/solitaire.pro | 5 |
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 | ||
35 | CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : | 35 | CanvasCardWindow::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 | ||
179 | void CanvasCardWindow::resizeEvent(QResizeEvent *) | 180 | void 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 | ||
187 | void CanvasCardWindow::initPatience() | 188 | void 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 | ||
249 | void CanvasCardWindow::initTeeclub() | 250 | void 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 | ||
265 | void CanvasCardWindow::snapToggle() | 266 | void 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 | ||
273 | void CanvasCardWindow::drawnToggle() | 274 | void 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 | ||
28 | class CanvasCardGame; | 28 | class CanvasCardGame; |
29 | class QPopupMenu; | 29 | class QPopupMenu; |
30 | 30 | ||
31 | 31 | ||
32 | class CanvasCardWindow : public QMainWindow { | 32 | class CanvasCardWindow : public QMainWindow { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
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 | ||
39 | public slots: | 40 | public 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 | ||
45 | private slots: | 46 | private 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 | ||
26 | CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE) | 26 | CardDeck::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 | ||
32 | CardDeck::~CardDeck() | 32 | CardDeck::~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 | ||
40 | void CardDeck::createDeck() | 40 | void 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 | 26 | OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file | |
26 | int 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 @@ | |||
1 | TEMPLATE = app | ||
2 | 1 | ||
3 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release quick-app |
4 | DESTDIR = $(OPIEDIR)/bin | ||
5 | 3 | ||
6 | HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \ | 4 | HEADERS = 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 | ||
10 | SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \ | 8 | SOURCES = 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 | ||
15 | TARGET = patience | 13 | TARGET = patience |
16 | 14 | ||
17 | INCLUDEPATH += $(OPIEDIR)/include | 15 | INCLUDEPATH += $(OPIEDIR)/include |
18 | DEPENDPATH += $(OPIEDIR)/include | 16 | DEPENDPATH += $(OPIEDIR)/include |
19 | LIBS += -lqpe | 17 | LIBS += -lqpe |
20 | 18 | ||
19 | |||
21 | include ( $(OPIEDIR)/include.pro ) | 20 | include ( $(OPIEDIR)/include.pro ) |