Diffstat (limited to 'noncore/games/minesweep/minefield.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/minesweep/minefield.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/noncore/games/minesweep/minefield.h b/noncore/games/minesweep/minefield.h new file mode 100644 index 0000000..4ede435 --- a/dev/null +++ b/noncore/games/minesweep/minefield.h | |||
@@ -0,0 +1,87 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef MINEFIELD_H | ||
21 | #define MINEFIELD_H | ||
22 | |||
23 | #include <qtable.h> | ||
24 | |||
25 | class Mine; | ||
26 | class Config; | ||
27 | |||
28 | class MineField : public QTable | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | public: | ||
32 | MineField( QWidget* parent = 0, const char* name = 0 ); | ||
33 | ~MineField(); | ||
34 | |||
35 | enum State { Waiting, Playing, GameOver }; | ||
36 | |||
37 | State state() const { return stat; } | ||
38 | |||
39 | void readConfig(Config&); | ||
40 | void writeConfig(Config&) const; | ||
41 | |||
42 | int level() const { return lev; } | ||
43 | |||
44 | public slots: | ||
45 | void setup( int level ); | ||
46 | |||
47 | void showMines(); | ||
48 | |||
49 | signals: | ||
50 | void gameOver( bool won ); | ||
51 | void gameStarted(); | ||
52 | void mineCount( int ); | ||
53 | |||
54 | protected: | ||
55 | void paintFocus( QPainter*, const QRect& ); | ||
56 | void viewportMousePressEvent( QMouseEvent* ); | ||
57 | void viewportMouseReleaseEvent( QMouseEvent* ); | ||
58 | void keyPressEvent( QKeyEvent* ); | ||
59 | void keyReleaseEvent( QKeyEvent* ); | ||
60 | |||
61 | int getHint( int row, int col ); | ||
62 | void setHint( Mine* ); | ||
63 | void updateMine( int row, int col ); | ||
64 | void paletteChange( const QPalette & ); | ||
65 | |||
66 | protected slots: | ||
67 | void cellPressed( int row, int col ); | ||
68 | void cellClicked( int row, int col ); | ||
69 | void held(); | ||
70 | |||
71 | private: | ||
72 | State stat; | ||
73 | void MineField::setState( State st ); | ||
74 | void MineField::placeMines(); | ||
75 | enum FlagAction { NoAction, FlagOn, FlagNext }; | ||
76 | FlagAction flagAction; | ||
77 | bool ignoreClick; | ||
78 | int currRow; | ||
79 | int currCol; | ||
80 | int minecount; | ||
81 | int mineguess; | ||
82 | int nonminecount; | ||
83 | int lev; | ||
84 | QTimer *holdTimer; | ||
85 | }; | ||
86 | |||
87 | #endif // MINEFIELD_H | ||