Diffstat (limited to 'noncore/games/mindbreaker/mindbreaker.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/mindbreaker/mindbreaker.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/noncore/games/mindbreaker/mindbreaker.h b/noncore/games/mindbreaker/mindbreaker.h new file mode 100644 index 0000000..fca649a --- a/dev/null +++ b/noncore/games/mindbreaker/mindbreaker.h | |||
@@ -0,0 +1,122 @@ | |||
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 | |||
21 | #ifndef MINDBREAKER_H | ||
22 | #define MINDBREAKER_H | ||
23 | |||
24 | #include <qwidget.h> | ||
25 | #include <qmainwindow.h> | ||
26 | #include <qimage.h> | ||
27 | #include <qvector.h> | ||
28 | #include <qcanvas.h> | ||
29 | #include <qlabel.h> | ||
30 | |||
31 | static const int panel_height = 26; | ||
32 | static const int panel_width = 180; | ||
33 | |||
34 | static const int title_height = 25; | ||
35 | static const int title_width = 180; | ||
36 | |||
37 | static const int bin_margin = 10; | ||
38 | static const int peg_size = 20; | ||
39 | static const int answerpeg_size = 13; | ||
40 | |||
41 | static const int first_peg_x_diff = 21; | ||
42 | static const int first_peg_y_diff = ((panel_height - peg_size) >> 1); | ||
43 | static const int peg_spacing = 30; | ||
44 | |||
45 | static const int answerpegx = 152; | ||
46 | static const int answerpegy = 2; | ||
47 | static const int answerpeg_diff = 9; | ||
48 | |||
49 | static const int board_height = (title_height + (panel_height * 9)); | ||
50 | static const int board_width = (panel_width + (bin_margin * 2) + peg_size); | ||
51 | |||
52 | class Peg; | ||
53 | class QToolButton; | ||
54 | |||
55 | class MindBreakerBoard : public QCanvasView // QWidget | ||
56 | { | ||
57 | Q_OBJECT | ||
58 | public: | ||
59 | MindBreakerBoard(QCanvas &c, QWidget *parent=0, const char *name=0, int wFlags=0 ); | ||
60 | ~MindBreakerBoard(); | ||
61 | |||
62 | void getScore(int *, int *); | ||
63 | signals: | ||
64 | void scoreChanged(int, int); | ||
65 | |||
66 | public slots: | ||
67 | void clear(); | ||
68 | void resetScore(); | ||
69 | |||
70 | protected: | ||
71 | void contentsMousePressEvent(QMouseEvent *); | ||
72 | void contentsMouseMoveEvent(QMouseEvent *); | ||
73 | void contentsMouseReleaseEvent(QMouseEvent *); | ||
74 | void resizeEvent(QResizeEvent *); | ||
75 | |||
76 | private: | ||
77 | void drawBackground(); | ||
78 | void checkGuess(); | ||
79 | void checkScores(); | ||
80 | void placeGuessPeg(int pos, int pegId); | ||
81 | |||
82 | QImage panelImage; | ||
83 | QImage titleImage; | ||
84 | |||
85 | Peg *moving; | ||
86 | Peg *current_highlight; | ||
87 | QPoint moving_pos; | ||
88 | |||
89 | // the game stuff | ||
90 | int answer[4]; | ||
91 | int current_guess[4]; | ||
92 | int past_guesses[4*9]; | ||
93 | int current_go; | ||
94 | |||
95 | int null_press; | ||
96 | QPoint null_point; | ||
97 | bool copy_press; | ||
98 | Peg *copy_peg; | ||
99 | bool game_over; | ||
100 | |||
101 | int total_turns; | ||
102 | int total_games; | ||
103 | }; | ||
104 | |||
105 | class MindBreaker : public QMainWindow // QWidget | ||
106 | { | ||
107 | Q_OBJECT | ||
108 | public: | ||
109 | MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 ); | ||
110 | |||
111 | public slots: | ||
112 | void setScore(int, int); | ||
113 | |||
114 | private: | ||
115 | QCanvas canvas; | ||
116 | MindBreakerBoard *board; | ||
117 | QToolButton *score; | ||
118 | |||
119 | }; | ||
120 | |||
121 | |||
122 | #endif | ||