File indexing completed on 2024-05-12 05:46:33
0001 // 0002 // KBlackBox 0003 // 0004 // A simple game inspired by an emacs module 0005 // 0006 /*************************************************************************** 0007 * Copyright (c) 1999-2000, Robert Cimrman * 0008 * cimrman3@students.zcu.cz * 0009 * * 0010 * Copyright (c) 2007, Nicolas Roffet * 0011 * nicolas-kde@roffet.com * 0012 * * 0013 * * 0014 * This program is free software; you can redistribute it and/or modify * 0015 * it under the terms of the GNU General Public License as published by * 0016 * the Free Software Foundation; either version 2 of the License, or * 0017 * (at your option) any later version. * 0018 * * 0019 * This program is distributed in the hope that it will be useful, * 0020 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0022 * GNU General Public License for more details. * 0023 * * 0024 * You should have received a copy of the GNU General Public License * 0025 * along with this program; if not, write to the * 0026 * Free Software Foundation, Inc., * 0027 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * 0028 ***************************************************************************/ 0029 0030 #ifndef KBLACKBOX_KBBMAINWINDOW_H 0031 #define KBLACKBOX_KBBMAINWINDOW_H 0032 0033 class QAction; 0034 class QWidget; 0035 0036 class KGameClock; 0037 #include <kxmlguiwindow.h> 0038 #include <KgDifficulty> 0039 0040 class KBBGameDoc; 0041 class KBBLevelConfigurationWidget; 0042 class KBBScalableGraphicWidget; 0043 class KBBThemeManager; 0044 class KBBTutorial; 0045 0046 /** 0047 * @brief Main window of the game KBlackBox 0048 */ 0049 class KBBMainWindow : public KXmlGuiWindow 0050 { 0051 Q_OBJECT 0052 0053 0054 public: 0055 KBBMainWindow(); 0056 ~KBBMainWindow(); 0057 0058 0059 public Q_SLOTS: 0060 /** 0061 * @brief Player changed the level 0062 */ 0063 void levelChanged(); 0064 0065 /** 0066 * @brief Set if the game is running 0067 */ 0068 void setRunning(bool r); 0069 0070 /** 0071 * @brief Displays game statistics on the status bar 0072 */ 0073 void updateStats(); 0074 0075 private Q_SLOTS: 0076 /** 0077 * @brief Ends the current game 0078 * 0079 * This function is used when the player is done. 0080 * @see solve() 0081 */ 0082 void done(); 0083 0084 /** 0085 * @brief Start a new game. 0086 */ 0087 void newGame(); 0088 0089 /** 0090 * @brief Pause the game. 0091 */ 0092 void pause(bool state); 0093 0094 /** 0095 * @brief Settings changed 0096 */ 0097 void settingsChanged(); 0098 0099 /** 0100 * @brief Show the settings dialog 0101 */ 0102 void settingsDialog(); 0103 0104 /** 0105 * @brief Show the highscores 0106 */ 0107 void showHighscores(); 0108 0109 /** 0110 * @brief Give up the current game 0111 * 0112 * This function is used when the player is giving up. 0113 * @see check() 0114 */ 0115 void solve(); 0116 0117 /** 0118 * @brief Start a game in the sandbox mode 0119 */ 0120 void startSandbox(); 0121 0122 /** 0123 * @brief Start tutorial mode 0124 */ 0125 void startTutorial(); 0126 0127 void toggleCursor(); 0128 0129 private: 0130 /** 0131 * Statusbar IDs. 0132 */ 0133 static const int SRUN = 0; 0134 static const int STIME = 1; 0135 static const int SSIZE = 2; 0136 0137 0138 /** 0139 * @brief If needed, ask the player if he agrees to end the current game. 0140 * 0141 * @return if the current game may be aborted 0142 */ 0143 bool mayAbortGame(); 0144 0145 void solving(); 0146 0147 /** 0148 * @brief Start a new game. 0149 */ 0150 void startGame(bool newSandboxModeMode); 0151 0152 0153 // Actions 0154 QAction *m_doneAction; 0155 QAction *m_pauseAction; 0156 QAction *m_solveAction; 0157 QAction *m_toggleCursorAction; 0158 0159 0160 /** 0161 * @brief The game document 0162 */ 0163 KBBGameDoc* m_gameDoc; 0164 0165 /** 0166 * @brief The game main widget 0167 */ 0168 KBBScalableGraphicWidget* m_gameWidget; 0169 0170 0171 // Custom difficulty level 0172 int m_customBallNumber; 0173 int m_customColumns; 0174 int m_customRows; 0175 0176 // Various member variables 0177 int m_ballNumber; 0178 QWidget* m_centralWidget; 0179 int m_columns; 0180 KGameClock* m_gameClock; 0181 KgDifficultyLevel::StandardLevel m_level; 0182 KBBLevelConfigurationWidget* m_levelConfig; 0183 int m_rows; 0184 bool m_boardEnabled; 0185 bool m_sandboxMode; 0186 KBBThemeManager* m_themeManager; 0187 KBBTutorial* m_tutorial; 0188 }; 0189 0190 #endif // KBLACKBOX_KBBMAINWINDOW_H