1 | // |
2 | // KBlackBox |
3 | // |
4 | // A simple game inspired by an emacs module |
5 | // |
6 | /*************************************************************************** |
7 | * Copyright (c) 1999-2000, Robert Cimrman * |
8 | * cimrman3@students.zcu.cz * |
9 | * * |
10 | * Copyright (c) 2007, Nicolas Roffet * |
11 | * nicolas-kde@roffet.com * |
12 | * * |
13 | * * |
14 | * This program is free software; you can redistribute it and/or modify * |
15 | * it under the terms of the GNU General Public License as published by * |
16 | * the Free Software Foundation; either version 2 of the License, or * |
17 | * (at your option) any later version. * |
18 | * * |
19 | * This program is distributed in the hope that it will be useful, * |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
22 | * GNU General Public License for more details. * |
23 | * * |
24 | * You should have received a copy of the GNU General Public License * |
25 | * along with this program; if not, write to the * |
26 | * Free Software Foundation, Inc., * |
27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * |
28 | ***************************************************************************/ |
29 | |
30 | #ifndef KBLACKBOX_KBBMAINWINDOW_H |
31 | #define KBLACKBOX_KBBMAINWINDOW_H |
32 | |
33 | class QAction; |
34 | class QWidget; |
35 | |
36 | class KGameClock; |
37 | #include <kxmlguiwindow.h> |
38 | #include <KgDifficulty> |
39 | |
40 | class KBBGameDoc; |
41 | class KBBLevelConfigurationWidget; |
42 | class KBBScalableGraphicWidget; |
43 | class KBBThemeManager; |
44 | class KBBTutorial; |
45 | |
46 | /** |
47 | * @brief Main window of the game KBlackBox |
48 | */ |
49 | class KBBMainWindow : public KXmlGuiWindow |
50 | { |
51 | Q_OBJECT |
52 | |
53 | |
54 | public: |
55 | KBBMainWindow(); |
56 | ~KBBMainWindow(); |
57 | |
58 | |
59 | public slots: |
60 | /** |
61 | * @brief Player changed the level |
62 | */ |
63 | void levelChanged(); |
64 | |
65 | /** |
66 | * @brief Set if the game is running |
67 | */ |
68 | void setRunning(bool r); |
69 | |
70 | /** |
71 | * @brief Displays game statistics on the status bar |
72 | */ |
73 | void updateStats(); |
74 | |
75 | |
76 | private slots: |
77 | /** |
78 | * @brief Ends the current game |
79 | * |
80 | * This function is used when the player is done. |
81 | * @see solve() |
82 | */ |
83 | void done(); |
84 | |
85 | /** |
86 | * @brief Start a new game. |
87 | */ |
88 | void newGame(); |
89 | |
90 | /** |
91 | * @brief Pause the game. |
92 | */ |
93 | void pause(bool state); |
94 | |
95 | /** |
96 | * @brief Settings changed |
97 | */ |
98 | void settingsChanged(); |
99 | |
100 | /** |
101 | * @brief Show the settings dialog |
102 | */ |
103 | void settingsDialog(); |
104 | |
105 | /** |
106 | * @brief Show the highscores |
107 | */ |
108 | void showHighscores(); |
109 | |
110 | /** |
111 | * @brief Give up the current game |
112 | * |
113 | * This function is used when the player is giving up. |
114 | * @see check() |
115 | */ |
116 | void solve(); |
117 | |
118 | /** |
119 | * @brief Start a game in the sandbox mode |
120 | */ |
121 | void startSandbox(); |
122 | |
123 | /** |
124 | * @brief Start tutorial mode |
125 | */ |
126 | void startTutorial(); |
127 | |
128 | |
129 | private: |
130 | /** |
131 | * Statusbar IDs. |
132 | */ |
133 | static const int SRUN = 0; |
134 | static const int STIME = 1; |
135 | static const int SSIZE = 2; |
136 | |
137 | |
138 | /** |
139 | * @brief If needed, ask the player if he agrees to end the current game. |
140 | * |
141 | * @return if the current game may be aborted |
142 | */ |
143 | bool mayAbortGame(); |
144 | |
145 | void solving(); |
146 | |
147 | /** |
148 | * @brief Start a new game. |
149 | */ |
150 | void startGame(bool newSandboxModeMode); |
151 | |
152 | |
153 | // Actions |
154 | QAction *m_doneAction; |
155 | QAction *m_pauseAction; |
156 | QAction *m_solveAction; |
157 | |
158 | |
159 | /** |
160 | * @brief The game document |
161 | */ |
162 | KBBGameDoc* m_gameDoc; |
163 | |
164 | /** |
165 | * @brief The game main widget |
166 | */ |
167 | KBBScalableGraphicWidget* m_gameWidget; |
168 | |
169 | |
170 | // Custom difficulty level |
171 | int m_customBallNumber; |
172 | int m_customColumns; |
173 | int m_customRows; |
174 | |
175 | // Various member variables |
176 | int m_ballNumber; |
177 | QWidget* m_centralWidget; |
178 | int m_columns; |
179 | KGameClock* m_gameClock; |
180 | KgDifficultyLevel::StandardLevel m_level; |
181 | KBBLevelConfigurationWidget* m_levelConfig; |
182 | int m_rows; |
183 | bool m_boardEnabled; |
184 | bool m_sandboxMode; |
185 | KBBThemeManager* m_themeManager; |
186 | KBBTutorial* m_tutorial; |
187 | }; |
188 | |
189 | #endif // KBLACKBOX_KBBMAINWINDOW_H |
190 | |