-rw-r--r-- | noncore/games/minesweep/main.cpp | 11 | ||||
-rw-r--r-- | noncore/games/minesweep/minefield.cpp | 2 | ||||
-rw-r--r-- | noncore/games/minesweep/minesweep.cpp | 26 | ||||
-rw-r--r-- | noncore/games/minesweep/minesweep.h | 1 | ||||
-rw-r--r-- | noncore/games/minesweep/minesweep.pro | 28 | ||||
-rw-r--r-- | noncore/games/minesweep/opie-minesweep.control | 2 |
6 files changed, 32 insertions, 38 deletions
diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp index 83de9a3..bd70f7c 100644 --- a/noncore/games/minesweep/main.cpp +++ b/noncore/games/minesweep/main.cpp | |||
@@ -1,34 +1,27 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
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 "minesweep.h" | 21 | #include "minesweep.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <opie/oapplicationfactory.h> | ||
24 | 25 | ||
25 | int main( int argc, char** argv ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) |
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | 27 | ||
29 | MineSweep ms; | ||
30 | QPEApplication::setInputMethodHint( &ms, QPEApplication::AlwaysOff ); | ||
31 | a.showMainWidget( &ms ); | ||
32 | |||
33 | return a.exec(); | ||
34 | } | ||
diff --git a/noncore/games/minesweep/minefield.cpp b/noncore/games/minesweep/minefield.cpp index eca1a36..04cfb97 100644 --- a/noncore/games/minesweep/minefield.cpp +++ b/noncore/games/minesweep/minefield.cpp | |||
@@ -292,129 +292,129 @@ MineField::MineField( QWidget* parent, const char* name ) | |||
292 | holdTimer = new QTimer( this ); | 292 | holdTimer = new QTimer( this ); |
293 | connect( holdTimer, SIGNAL( timeout() ), this, SLOT( held() ) ); | 293 | connect( holdTimer, SIGNAL( timeout() ), this, SLOT( held() ) ); |
294 | 294 | ||
295 | flagAction = NoAction; | 295 | flagAction = NoAction; |
296 | ignoreClick = FALSE; | 296 | ignoreClick = FALSE; |
297 | currRow = currCol = -1; | 297 | currRow = currCol = -1; |
298 | minecount=0; | 298 | minecount=0; |
299 | mineguess=0; | 299 | mineguess=0; |
300 | nonminecount=0; | 300 | nonminecount=0; |
301 | cellSize = -1; | 301 | cellSize = -1; |
302 | mines = 0; | 302 | mines = 0; |
303 | } | 303 | } |
304 | 304 | ||
305 | MineField::~MineField() | 305 | MineField::~MineField() |
306 | { | 306 | { |
307 | int i; | 307 | int i; |
308 | if ( mines ) | 308 | if ( mines ) |
309 | { | 309 | { |
310 | for ( i = 0; i < numCols*numRows; i++ ) | 310 | for ( i = 0; i < numCols*numRows; i++ ) |
311 | { | 311 | { |
312 | delete mines[i]; | 312 | delete mines[i]; |
313 | } | 313 | } |
314 | delete[] mines; | 314 | delete[] mines; |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | void MineField::setState( State st ) | 318 | void MineField::setState( State st ) |
319 | { | 319 | { |
320 | stat = st; | 320 | stat = st; |
321 | } | 321 | } |
322 | 322 | ||
323 | void MineField::setup( int level ) | 323 | void MineField::setup( int level ) |
324 | { | 324 | { |
325 | lev = level; | 325 | lev = level; |
326 | setState( Waiting ); | 326 | setState( Waiting ); |
327 | //viewport()->setUpdatesEnabled( FALSE ); | 327 | //viewport()->setUpdatesEnabled( FALSE ); |
328 | 328 | ||
329 | int i; | 329 | int i; |
330 | if ( mines ) | 330 | if ( mines ) |
331 | { | 331 | { |
332 | for ( i = 0; i < numCols*numRows; i++ ) | 332 | for ( i = 0; i < numCols*numRows; i++ ) |
333 | { | 333 | { |
334 | delete mines[i]; | 334 | delete mines[i]; |
335 | } | 335 | } |
336 | delete[] mines; | 336 | delete[] mines; |
337 | } | 337 | } |
338 | 338 | ||
339 | switch( lev ) { | 339 | switch( lev ) { |
340 | case 1: | 340 | case 1: |
341 | numRows = 9 ; | 341 | numRows = 9 ; |
342 | numCols = 9 ; | 342 | numCols = 9 ; |
343 | minecount = 12; | 343 | minecount = 12; |
344 | break; | 344 | break; |
345 | case 2: | 345 | case 2: |
346 | numRows = 16; | 346 | numRows = 16; |
347 | numCols = 16; | 347 | numCols = 16; |
348 | minecount = 45; | 348 | minecount = 45; |
349 | break; | 349 | break; |
350 | case 3: | 350 | case 3: |
351 | numCols = 18; | 351 | numCols = 18; |
352 | numRows = 18; | 352 | numRows = 18; |
353 | minecount = 66 ; | 353 | minecount = 66 ; |
354 | break; | 354 | break; |
355 | } | 355 | } |
356 | mines = new (Mine*)[numRows*numCols]; | 356 | mines = new Mine*[numRows*numCols]; |
357 | for ( i = 0; i < numCols*numRows; i++ ) | 357 | for ( i = 0; i < numCols*numRows; i++ ) |
358 | mines[i] = new Mine( this ); | 358 | mines[i] = new Mine( this ); |
359 | 359 | ||
360 | 360 | ||
361 | nonminecount = numRows*numCols - minecount; | 361 | nonminecount = numRows*numCols - minecount; |
362 | mineguess = minecount; | 362 | mineguess = minecount; |
363 | emit mineCount( mineguess ); | 363 | emit mineCount( mineguess ); |
364 | Mine::paletteChange(); | 364 | Mine::paletteChange(); |
365 | 365 | ||
366 | if ( availableRect.isValid() ) | 366 | if ( availableRect.isValid() ) |
367 | setCellSize(findCellSize()); | 367 | setCellSize(findCellSize()); |
368 | // viewport()->setUpdatesEnabled( TRUE ); | 368 | // viewport()->setUpdatesEnabled( TRUE ); |
369 | //viewport()->repaint( TRUE ); | 369 | //viewport()->repaint( TRUE ); |
370 | updateContents( 0, 0, numCols*cellSize, numRows*cellSize ); | 370 | updateContents( 0, 0, numCols*cellSize, numRows*cellSize ); |
371 | updateGeometry(); | 371 | updateGeometry(); |
372 | } | 372 | } |
373 | 373 | ||
374 | void MineField::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph ) | 374 | void MineField::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph ) |
375 | { | 375 | { |
376 | int c1 = clipx / cellSize; | 376 | int c1 = clipx / cellSize; |
377 | int c2 = ( clipx + clipw - 1 ) / cellSize; | 377 | int c2 = ( clipx + clipw - 1 ) / cellSize; |
378 | int r1 = clipy / cellSize; | 378 | int r1 = clipy / cellSize; |
379 | int r2 = ( clipy + cliph - 1 ) / cellSize; | 379 | int r2 = ( clipy + cliph - 1 ) / cellSize; |
380 | 380 | ||
381 | for ( int c = c1; c <= c2 ; c++ ) { | 381 | for ( int c = c1; c <= c2 ; c++ ) { |
382 | for ( int r = r1; r <= r2 ; r++ ) { | 382 | for ( int r = r1; r <= r2 ; r++ ) { |
383 | int x = c * cellSize; | 383 | int x = c * cellSize; |
384 | int y = r * cellSize; | 384 | int y = r * cellSize; |
385 | Mine *m = mine( r, c ); | 385 | Mine *m = mine( r, c ); |
386 | if ( m ) | 386 | if ( m ) |
387 | m->paint( p, colorGroup(), QRect(x, y, cellSize, cellSize ) ); | 387 | m->paint( p, colorGroup(), QRect(x, y, cellSize, cellSize ) ); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | // Chicken and egg problem: We need to know how big the parent is | 393 | // Chicken and egg problem: We need to know how big the parent is |
394 | // before we can decide how big to make the table. | 394 | // before we can decide how big to make the table. |
395 | 395 | ||
396 | void MineField::setAvailableRect( const QRect &r ) | 396 | void MineField::setAvailableRect( const QRect &r ) |
397 | { | 397 | { |
398 | availableRect = r; | 398 | availableRect = r; |
399 | int newCellSize = findCellSize(); | 399 | int newCellSize = findCellSize(); |
400 | if ( newCellSize != cellSize ) { | 400 | if ( newCellSize != cellSize ) { |
401 | viewport()->setUpdatesEnabled( FALSE ); | 401 | viewport()->setUpdatesEnabled( FALSE ); |
402 | setCellSize( newCellSize ); | 402 | setCellSize( newCellSize ); |
403 | viewport()->setUpdatesEnabled( TRUE ); | 403 | viewport()->setUpdatesEnabled( TRUE ); |
404 | viewport()->repaint( TRUE ); | 404 | viewport()->repaint( TRUE ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | int MineField::findCellSize() | 408 | int MineField::findCellSize() |
409 | { | 409 | { |
410 | int w = availableRect.width() - 1; | 410 | int w = availableRect.width() - 1; |
411 | int h = availableRect.height() - 1; | 411 | int h = availableRect.height() - 1; |
412 | int cellsize; | 412 | int cellsize; |
413 | 413 | ||
414 | cellsize = QMIN( w/numCols, h/numRows ); | 414 | cellsize = QMIN( w/numCols, h/numRows ); |
415 | cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid ); | 415 | cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid ); |
416 | return cellsize; | 416 | return cellsize; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void MineField::setCellSize( int cellsize ) | 420 | void MineField::setCellSize( int cellsize ) |
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp index 48644b3..7214a73 100644 --- a/noncore/games/minesweep/minesweep.cpp +++ b/noncore/games/minesweep/minesweep.cpp | |||
@@ -1,87 +1,88 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
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 "minesweep.h" | 21 | #include "minesweep.h" |
22 | #include "minefield.h" | 22 | #include "minefield.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
26 | 27 | ||
27 | #include <qpe/qpetoolbar.h> | 28 | #include <qpe/qpetoolbar.h> |
28 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
29 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
30 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
31 | #include <qlcdnumber.h> | 32 | #include <qlcdnumber.h> |
32 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
33 | #include <qtimer.h> | 34 | #include <qtimer.h> |
34 | #include <qpalette.h> | 35 | #include <qpalette.h> |
35 | #include <qapplication.h> | 36 | #include <qapplication.h> |
36 | #include <qlayout.h> | 37 | #include <qlayout.h> |
37 | #include <qlabel.h> | 38 | #include <qlabel.h> |
38 | 39 | ||
39 | #include <stdlib.h> | 40 | #include <stdlib.h> |
40 | #include <time.h> | 41 | #include <time.h> |
41 | 42 | ||
42 | 43 | ||
43 | 44 | ||
44 | 45 | ||
45 | static const char *pix_new[]={ | 46 | static const char *pix_new[]={ |
46 | "20 20 3 1", | 47 | "20 20 3 1", |
47 | " c None", | 48 | " c None", |
48 | "# c #00FF00", | 49 | "# c #00FF00", |
49 | ". c #000000", | 50 | ". c #000000", |
50 | " ", | 51 | " ", |
51 | " ...... ", | 52 | " ...... ", |
52 | " ..######.. ", | 53 | " ..######.. ", |
53 | " .##########. ", | 54 | " .##########. ", |
54 | " .############. ", | 55 | " .############. ", |
55 | " .##############. ", | 56 | " .##############. ", |
56 | " .##############. ", | 57 | " .##############. ", |
57 | " .################. ", | 58 | " .################. ", |
58 | " .################. ", | 59 | " .################. ", |
59 | " .################. ", | 60 | " .################. ", |
60 | " .################. ", | 61 | " .################. ", |
61 | " .################. ", | 62 | " .################. ", |
62 | " .################. ", | 63 | " .################. ", |
63 | " .##############. ", | 64 | " .##############. ", |
64 | " .##############. ", | 65 | " .##############. ", |
65 | " .############. ", | 66 | " .############. ", |
66 | " .##########. ", | 67 | " .##########. ", |
67 | " ..######.. ", | 68 | " ..######.. ", |
68 | " ...... ", | 69 | " ...... ", |
69 | " "}; | 70 | " "}; |
70 | 71 | ||
71 | 72 | ||
72 | /* XPM */ | 73 | /* XPM */ |
73 | static const char * happy_xpm[] = { | 74 | static const char * happy_xpm[] = { |
74 | "20 20 3 1", | 75 | "20 20 3 1", |
75 | " c None", | 76 | " c None", |
76 | ".c #ffff3f ", | 77 | ".c #ffff3f ", |
77 | "#c #000000", | 78 | "#c #000000", |
78 | " ", | 79 | " ", |
79 | " ###### ", | 80 | " ###### ", |
80 | " ##......## ", | 81 | " ##......## ", |
81 | " #..........# ", | 82 | " #..........# ", |
82 | " #............# ", | 83 | " #............# ", |
83 | " #..............# ", | 84 | " #..............# ", |
84 | " #..............# ", | 85 | " #..............# ", |
85 | " #....##....##....# ", | 86 | " #....##....##....# ", |
86 | " #....##....##....# ", | 87 | " #....##....##....# ", |
87 | " #................# ", | 88 | " #................# ", |
@@ -94,270 +95,271 @@ static const char * happy_xpm[] = { | |||
94 | " #..........# ", | 95 | " #..........# ", |
95 | " ##......## ", | 96 | " ##......## ", |
96 | " ###### ", | 97 | " ###### ", |
97 | " "}; | 98 | " "}; |
98 | 99 | ||
99 | 100 | ||
100 | /* XPM */ | 101 | /* XPM */ |
101 | static const char * worried_xpm[] = { | 102 | static const char * worried_xpm[] = { |
102 | "20 20 3 1", | 103 | "20 20 3 1", |
103 | " c None", | 104 | " c None", |
104 | ".c #ffff3f", | 105 | ".c #ffff3f", |
105 | "#c #000000", | 106 | "#c #000000", |
106 | " ", | 107 | " ", |
107 | " ###### ", | 108 | " ###### ", |
108 | " ##......## ", | 109 | " ##......## ", |
109 | " #..........# ", | 110 | " #..........# ", |
110 | " #............# ", | 111 | " #............# ", |
111 | " #..............# ", | 112 | " #..............# ", |
112 | " #..............# ", | 113 | " #..............# ", |
113 | " #....##....##....# ", | 114 | " #....##....##....# ", |
114 | " #....##....##....# ", | 115 | " #....##....##....# ", |
115 | " #................# ", | 116 | " #................# ", |
116 | " #................# ", | 117 | " #................# ", |
117 | " #................# ", | 118 | " #................# ", |
118 | " #................# ", | 119 | " #................# ", |
119 | " #....######....# ", | 120 | " #....######....# ", |
120 | " #..............# ", | 121 | " #..............# ", |
121 | " #............# ", | 122 | " #............# ", |
122 | " #..........# ", | 123 | " #..........# ", |
123 | " ##......## ", | 124 | " ##......## ", |
124 | " ###### ", | 125 | " ###### ", |
125 | " "}; | 126 | " "}; |
126 | 127 | ||
127 | 128 | ||
128 | /* XPM */ | 129 | /* XPM */ |
129 | static const char * dead_xpm[] = { | 130 | static const char * dead_xpm[] = { |
130 | "20 20 3 1", | 131 | "20 20 3 1", |
131 | " c None", | 132 | " c None", |
132 | ".c #ffff3f", | 133 | ".c #ffff3f", |
133 | "#c #000000", | 134 | "#c #000000", |
134 | " ", | 135 | " ", |
135 | " ###### ", | 136 | " ###### ", |
136 | " ##......## ", | 137 | " ##......## ", |
137 | " #..........# ", | 138 | " #..........# ", |
138 | " #............# ", | 139 | " #............# ", |
139 | " #..............# ", | 140 | " #..............# ", |
140 | " #..#.#...#.#...# ", | 141 | " #..#.#...#.#...# ", |
141 | " #....#.....#.....# ", | 142 | " #....#.....#.....# ", |
142 | " #...#.#...#.#....# ", | 143 | " #...#.#...#.#....# ", |
143 | " #................# ", | 144 | " #................# ", |
144 | " #................# ", | 145 | " #................# ", |
145 | " #................# ", | 146 | " #................# ", |
146 | " #......####......# ", | 147 | " #......####......# ", |
147 | " #....# #....# ", | 148 | " #....# #....# ", |
148 | " #...#......#...# ", | 149 | " #...#......#...# ", |
149 | " #............# ", | 150 | " #............# ", |
150 | " #..........# ", | 151 | " #..........# ", |
151 | " ##......## ", | 152 | " ##......## ", |
152 | " ###### ", | 153 | " ###### ", |
153 | " "}; | 154 | " "}; |
154 | 155 | ||
155 | 156 | ||
156 | class ResultIndicator : private QLabel | 157 | class ResultIndicator : private QLabel |
157 | { | 158 | { |
158 | public: | 159 | public: |
159 | static void showResult( QWidget *ref, bool won ); | 160 | static void showResult( QWidget *ref, bool won ); |
160 | private: | 161 | private: |
161 | ResultIndicator( QWidget *parent, const char *name, WFlags f) | 162 | ResultIndicator( QWidget *parent, const char *name, WFlags f) |
162 | :QLabel( parent, name, f ) {} | 163 | :QLabel( parent, name, f ) {} |
163 | 164 | ||
164 | void timerEvent( QTimerEvent *); | 165 | void timerEvent( QTimerEvent *); |
165 | void center(); | 166 | void center(); |
166 | bool twoStage; | 167 | bool twoStage; |
167 | int timerId; | 168 | int timerId; |
168 | }; | 169 | }; |
169 | 170 | ||
170 | void ResultIndicator::showResult( QWidget *ref, bool won ) | 171 | void ResultIndicator::showResult( QWidget *ref, bool won ) |
171 | { | 172 | { |
172 | ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); | 173 | ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); |
173 | 174 | ||
174 | r->setAlignment( AlignCenter ); | 175 | r->setAlignment( AlignCenter ); |
175 | r->setFrameStyle( Sunken|StyledPanel ); | 176 | r->setFrameStyle( Sunken|StyledPanel ); |
176 | if ( won ) { | 177 | if ( won ) { |
177 | r->setText( MineSweep::tr("You won!") ); | 178 | r->setText( MineSweep::tr("You won!") ); |
178 | r->center(); | 179 | r->center(); |
179 | r->show(); | 180 | r->show(); |
180 | r->twoStage = FALSE; | 181 | r->twoStage = FALSE; |
181 | r->timerId = r->startTimer(1500); | 182 | r->timerId = r->startTimer(1500); |
182 | } else { | 183 | } else { |
183 | QPalette p( red ); | 184 | QPalette p( red ); |
184 | r->setPalette( p ); | 185 | r->setPalette( p ); |
185 | r->setText( MineSweep::tr("You exploded!") ); | 186 | r->setText( MineSweep::tr("You exploded!") ); |
186 | r->resize( ref->size() ); | 187 | r->resize( ref->size() ); |
187 | r->move( ref->mapToGlobal(QPoint(0,0)) ); | 188 | r->move( ref->mapToGlobal(QPoint(0,0)) ); |
188 | r->show(); | 189 | r->show(); |
189 | r->twoStage = TRUE; | 190 | r->twoStage = TRUE; |
190 | r->timerId =r->startTimer(200); | 191 | r->timerId =r->startTimer(200); |
191 | } | 192 | } |
192 | } | 193 | } |
193 | 194 | ||
194 | void ResultIndicator::center() | 195 | void ResultIndicator::center() |
195 | { | 196 | { |
196 | QWidget *w = parentWidget(); | 197 | QWidget *w = parentWidget(); |
197 | 198 | ||
198 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); | 199 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); |
199 | QSize s = sizeHint()*3; | 200 | QSize s = sizeHint()*3; |
200 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, | 201 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, |
201 | pp.y() + w->height()/ 2 - s.height()/2 ); | 202 | pp.y() + w->height()/ 2 - s.height()/2 ); |
202 | 203 | ||
203 | setGeometry( QRect(pp, s) ); | 204 | setGeometry( QRect(pp, s) ); |
204 | 205 | ||
205 | } | 206 | } |
206 | 207 | ||
207 | void ResultIndicator::timerEvent( QTimerEvent *te ) | 208 | void ResultIndicator::timerEvent( QTimerEvent *te ) |
208 | { | 209 | { |
209 | if ( te->timerId() != timerId ) | 210 | if ( te->timerId() != timerId ) |
210 | return; | 211 | return; |
211 | killTimer( timerId ); | 212 | killTimer( timerId ); |
212 | if ( twoStage ) { | 213 | if ( twoStage ) { |
213 | center(); | 214 | center(); |
214 | twoStage = FALSE; | 215 | twoStage = FALSE; |
215 | timerId = startTimer( 1000 ); | 216 | timerId = startTimer( 1000 ); |
216 | } else { | 217 | } else { |
217 | delete this; | 218 | delete this; |
218 | } | 219 | } |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | class MineFrame : public QFrame | 223 | class MineFrame : public QFrame |
223 | { | 224 | { |
224 | public: | 225 | public: |
225 | MineFrame( QWidget *parent, const char *name = 0 ) | 226 | MineFrame( QWidget *parent, const char *name = 0 ) |
226 | :QFrame( parent, name ) {} | 227 | :QFrame( parent, name ) {} |
227 | void setField( MineField *f ) { field = f; } | 228 | void setField( MineField *f ) { field = f; } |
228 | protected: | 229 | protected: |
229 | void resizeEvent( QResizeEvent *e ) { | 230 | void resizeEvent( QResizeEvent *e ) { |
230 | field->setAvailableRect( contentsRect()); | 231 | field->setAvailableRect( contentsRect()); |
231 | QFrame::resizeEvent(e); | 232 | QFrame::resizeEvent(e); |
232 | } | 233 | } |
233 | private: | 234 | private: |
234 | MineField *field; | 235 | MineField *field; |
235 | }; | 236 | }; |
236 | 237 | ||
237 | 238 | ||
238 | 239 | ||
239 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) | 240 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) |
240 | : QMainWindow( parent, name, f ) | 241 | : QMainWindow( parent, name, f ) |
241 | { | 242 | { |
243 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); | ||
242 | srand(::time(0)); | 244 | srand(::time(0)); |
243 | setCaption( tr("Mine Hunt") ); | 245 | setCaption( tr("Mine Hunt") ); |
244 | setIcon( Resource::loadPixmap( "minesweep_icon" ) ); | 246 | setIcon( Resource::loadPixmap( "minesweep_icon" ) ); |
245 | 247 | ||
246 | QToolBar *toolBar = new QToolBar( this ); | 248 | QToolBar *toolBar = new QToolBar( this ); |
247 | toolBar->setHorizontalStretchable( TRUE ); | 249 | toolBar->setHorizontalStretchable( TRUE ); |
248 | 250 | ||
249 | QMenuBar *menuBar = new QMenuBar( toolBar ); | 251 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
250 | 252 | ||
251 | QPopupMenu *gameMenu = new QPopupMenu( this ); | 253 | QPopupMenu *gameMenu = new QPopupMenu( this ); |
252 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); | 254 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); |
253 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); | 255 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); |
254 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); | 256 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); |
255 | 257 | ||
256 | menuBar->insertItem( tr("Game"), gameMenu ); | 258 | menuBar->insertItem( tr("Game"), gameMenu ); |
257 | 259 | ||
258 | guessLCD = new QLCDNumber( toolBar ); | 260 | guessLCD = new QLCDNumber( toolBar ); |
259 | toolBar->setStretchableWidget( guessLCD ); | 261 | toolBar->setStretchableWidget( guessLCD ); |
260 | 262 | ||
261 | QPalette lcdPal( red ); | 263 | QPalette lcdPal( red ); |
262 | lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); | 264 | lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); |
263 | lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); | 265 | lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); |
264 | 266 | ||
265 | // guessLCD->setPalette( lcdPal ); | 267 | // guessLCD->setPalette( lcdPal ); |
266 | guessLCD->setSegmentStyle( QLCDNumber::Flat ); | 268 | guessLCD->setSegmentStyle( QLCDNumber::Flat ); |
267 | guessLCD->setFrameStyle( QFrame::NoFrame ); | 269 | guessLCD->setFrameStyle( QFrame::NoFrame ); |
268 | guessLCD->setNumDigits( 2 ); | 270 | guessLCD->setNumDigits( 2 ); |
269 | guessLCD->setBackgroundMode( PaletteButton ); | 271 | guessLCD->setBackgroundMode( PaletteButton ); |
270 | newGameButton = new QPushButton( toolBar ); | 272 | newGameButton = new QPushButton( toolBar ); |
271 | newGameButton->setPixmap( QPixmap( pix_new ) ); | 273 | newGameButton->setPixmap( QPixmap( pix_new ) ); |
272 | newGameButton->setFocusPolicy(QWidget::NoFocus); | 274 | newGameButton->setFocusPolicy(QWidget::NoFocus); |
273 | connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); | 275 | connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); |
274 | 276 | ||
275 | timeLCD = new QLCDNumber( toolBar ); | 277 | timeLCD = new QLCDNumber( toolBar ); |
276 | // timeLCD->setPalette( lcdPal ); | 278 | // timeLCD->setPalette( lcdPal ); |
277 | timeLCD->setSegmentStyle( QLCDNumber::Flat ); | 279 | timeLCD->setSegmentStyle( QLCDNumber::Flat ); |
278 | timeLCD->setFrameStyle( QFrame::NoFrame ); | 280 | timeLCD->setFrameStyle( QFrame::NoFrame ); |
279 | timeLCD->setNumDigits( 5 ); // "mm:ss" | 281 | timeLCD->setNumDigits( 5 ); // "mm:ss" |
280 | timeLCD->setBackgroundMode( PaletteButton ); | 282 | timeLCD->setBackgroundMode( PaletteButton ); |
281 | 283 | ||
282 | setToolBarsMovable ( FALSE ); | 284 | setToolBarsMovable ( FALSE ); |
283 | 285 | ||
284 | addToolBar( toolBar ); | 286 | addToolBar( toolBar ); |
285 | 287 | ||
286 | MineFrame *mainframe = new MineFrame( this ); | 288 | MineFrame *mainframe = new MineFrame( this ); |
287 | mainframe->setFrameShape( QFrame::Box ); | 289 | mainframe->setFrameShape( QFrame::Box ); |
288 | mainframe->setFrameShadow( QFrame::Raised ); | 290 | mainframe->setFrameShadow( QFrame::Raised ); |
289 | 291 | ||
290 | mainframe->setLineWidth(2); | 292 | mainframe->setLineWidth(2); |
291 | 293 | ||
292 | field = new MineField( mainframe ); | 294 | field = new MineField( mainframe ); |
293 | mainframe->setField( field ); | 295 | mainframe->setField( field ); |
294 | QFont fnt = field->font(); | 296 | QFont fnt = field->font(); |
295 | fnt.setBold( TRUE ); | 297 | fnt.setBold( TRUE ); |
296 | field->setFont( QFont( fnt ) ); | 298 | field->setFont( QFont( fnt ) ); |
297 | field->setFocus(); | 299 | field->setFocus(); |
298 | setCentralWidget( mainframe ); | 300 | setCentralWidget( mainframe ); |
299 | 301 | ||
300 | connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); | 302 | connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); |
301 | connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); | 303 | connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); |
302 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); | 304 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); |
303 | 305 | ||
304 | timer = new QTimer( this ); | 306 | timer = new QTimer( this ); |
305 | 307 | ||
306 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); | 308 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); |
307 | 309 | ||
308 | readConfig(); | 310 | readConfig(); |
309 | } | 311 | } |
310 | 312 | ||
311 | MineSweep::~MineSweep() | 313 | MineSweep::~MineSweep() |
312 | { | 314 | { |
313 | writeConfig(); | 315 | writeConfig(); |
314 | } | 316 | } |
315 | 317 | ||
316 | void MineSweep::gameOver( bool won ) | 318 | void MineSweep::gameOver( bool won ) |
317 | { | 319 | { |
318 | field->showMines(); | 320 | field->showMines(); |
319 | if ( won ) { | 321 | if ( won ) { |
320 | newGameButton->setPixmap( QPixmap( happy_xpm ) ); | 322 | newGameButton->setPixmap( QPixmap( happy_xpm ) ); |
321 | } else { | 323 | } else { |
322 | newGameButton->setPixmap( QPixmap( dead_xpm ) ); | 324 | newGameButton->setPixmap( QPixmap( dead_xpm ) ); |
323 | } | 325 | } |
324 | ResultIndicator::showResult( this, won ); | 326 | ResultIndicator::showResult( this, won ); |
325 | timer->stop(); | 327 | timer->stop(); |
326 | } | 328 | } |
327 | 329 | ||
328 | void MineSweep::newGame() | 330 | void MineSweep::newGame() |
329 | { | 331 | { |
330 | newGame(field->level()); | 332 | newGame(field->level()); |
331 | } | 333 | } |
332 | 334 | ||
333 | void MineSweep::newGame(int level) | 335 | void MineSweep::newGame(int level) |
334 | { | 336 | { |
335 | timeLCD->display( "0:00" ); | 337 | timeLCD->display( "0:00" ); |
336 | field->setup( level ); | 338 | field->setup( level ); |
337 | newGameButton->setPixmap( QPixmap( pix_new ) ); | 339 | newGameButton->setPixmap( QPixmap( pix_new ) ); |
338 | timer->stop(); | 340 | timer->stop(); |
339 | } | 341 | } |
340 | 342 | ||
341 | void MineSweep::startPlaying() | 343 | void MineSweep::startPlaying() |
342 | { | 344 | { |
343 | newGameButton->setPixmap( QPixmap( worried_xpm ) ); | 345 | newGameButton->setPixmap( QPixmap( worried_xpm ) ); |
344 | starttime = QDateTime::currentDateTime(); | 346 | starttime = QDateTime::currentDateTime(); |
345 | timer->start( 1000 ); | 347 | timer->start( 1000 ); |
346 | } | 348 | } |
347 | 349 | ||
348 | void MineSweep::beginner() | 350 | void MineSweep::beginner() |
349 | { | 351 | { |
350 | newGame(1); | 352 | newGame(1); |
351 | } | 353 | } |
352 | 354 | ||
353 | void MineSweep::advanced() | 355 | void MineSweep::advanced() |
354 | { | 356 | { |
355 | newGame(2); | 357 | newGame(2); |
356 | } | 358 | } |
357 | 359 | ||
358 | void MineSweep::expert() | 360 | void MineSweep::expert() |
359 | { | 361 | { |
360 | newGame(3); | 362 | newGame(3); |
361 | } | 363 | } |
362 | 364 | ||
363 | void MineSweep::setCounter( int c ) | 365 | void MineSweep::setCounter( int c ) |
diff --git a/noncore/games/minesweep/minesweep.h b/noncore/games/minesweep/minesweep.h index e860573..527dc9e 100644 --- a/noncore/games/minesweep/minesweep.h +++ b/noncore/games/minesweep/minesweep.h | |||
@@ -1,67 +1,68 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
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 | #ifndef MINESWEEP_H | 20 | #ifndef MINESWEEP_H |
21 | #define MINESWEEP_H | 21 | #define MINESWEEP_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | class MineField; | 26 | class MineField; |
27 | class QLCDNumber; | 27 | class QLCDNumber; |
28 | class QPushButton; | 28 | class QPushButton; |
29 | 29 | ||
30 | class MineSweep : public QMainWindow | 30 | class MineSweep : public QMainWindow |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | static QString appName() { return QString::fromLatin1("minesweep"); } | ||
34 | MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); | 35 | MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); |
35 | ~MineSweep(); | 36 | ~MineSweep(); |
36 | 37 | ||
37 | public slots: | 38 | public slots: |
38 | void gameOver( bool won ); | 39 | void gameOver( bool won ); |
39 | void newGame(); | 40 | void newGame(); |
40 | 41 | ||
41 | protected slots: | 42 | protected slots: |
42 | void setCounter( int ); | 43 | void setCounter( int ); |
43 | void updateTime(); | 44 | void updateTime(); |
44 | 45 | ||
45 | void beginner(); | 46 | void beginner(); |
46 | void advanced(); | 47 | void advanced(); |
47 | void expert(); | 48 | void expert(); |
48 | 49 | ||
49 | private slots: | 50 | private slots: |
50 | void startPlaying(); | 51 | void startPlaying(); |
51 | 52 | ||
52 | private: | 53 | private: |
53 | void readConfig(); | 54 | void readConfig(); |
54 | void writeConfig() const; | 55 | void writeConfig() const; |
55 | 56 | ||
56 | void newGame(int); | 57 | void newGame(int); |
57 | MineField* field; | 58 | MineField* field; |
58 | QLCDNumber* guessLCD; | 59 | QLCDNumber* guessLCD; |
59 | QLCDNumber* timeLCD; | 60 | QLCDNumber* timeLCD; |
60 | QPushButton* newGameButton; | 61 | QPushButton* newGameButton; |
61 | 62 | ||
62 | QDateTime starttime; | 63 | QDateTime starttime; |
63 | QTimer* timer; | 64 | QTimer* timer; |
64 | }; | 65 | }; |
65 | 66 | ||
66 | #endif // MINESWEEP_H | 67 | #endif // MINESWEEP_H |
67 | 68 | ||
diff --git a/noncore/games/minesweep/minesweep.pro b/noncore/games/minesweep/minesweep.pro index 8e4001e..9746651 100644 --- a/noncore/games/minesweep/minesweep.pro +++ b/noncore/games/minesweep/minesweep.pro | |||
@@ -1,15 +1,13 @@ | |||
1 | TEMPLATE= app | 1 | CONFIG = qt warn_on release quick-app |
2 | CONFIG = qt warn_on release | 2 | HEADERS = minefield.h \ |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | minesweep.h |
4 | HEADERS = minefield.h \ | 4 | SOURCES = main.cpp \ |
5 | minesweep.h | 5 | minefield.cpp \ |
6 | SOURCES = main.cpp \ | 6 | minesweep.cpp |
7 | minefield.cpp \ | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | minesweep.cpp | 8 | DEPENDPATH+= $(OPIEDIR)/include |
9 | INCLUDEPATH += $(OPIEDIR)/include | 9 | LIBS += -lqpe |
10 | DEPENDPATH+= $(OPIEDIR)/include | 10 | INTERFACES= |
11 | LIBS += -lqpe | 11 | TARGET = minesweep |
12 | INTERFACES= | 12 | |
13 | TARGET = minesweep | 13 | include ( $(OPIEDIR)/include.pro ) |
14 | |||
15 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/noncore/games/minesweep/opie-minesweep.control b/noncore/games/minesweep/opie-minesweep.control index 32f0352..91343ea 100644 --- a/noncore/games/minesweep/opie-minesweep.control +++ b/noncore/games/minesweep/opie-minesweep.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-minesweep | 1 | Package: opie-minesweep |
2 | Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep | 2 | Files: plugins/application/libminesweep.so* bin/minesweep apps/Games/minesweep.desktop pics/minesweep |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/games | 4 | Section: opie/games |
5 | Maintainer: Martin Imobersteg <imm@gmx.ch> | 5 | Maintainer: Martin Imobersteg <imm@gmx.ch> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal |
8 | Description: Game: find the mines | 8 | Description: Game: find the mines |
9 | A game for the Opie environment. | 9 | A game for the Opie environment. |
10 | Version: $QPE_VERSION$EXTRAVERSION | 10 | Version: $QPE_VERSION$EXTRAVERSION |