File indexing completed on 2024-04-21 07:49:13

0001 /*
0002     KBlackBox - A simple game inspired by an emacs module
0003 
0004     SPDX-FileCopyrightText: 1999-2000 Robert Cimrman <cimrman3@students.zcu.cz>
0005     SPDX-FileCopyrightText: 2007 Nicolas Roffet <nicolas-kde@roffet.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef KBLACKBOX_KBBMAINWINDOW_H
0011 #define KBLACKBOX_KBBMAINWINDOW_H
0012 
0013 class QAction;
0014 class QWidget;
0015 
0016 class KGameClock;
0017 #include <kxmlguiwindow.h>
0018 #include <KGameDifficulty>
0019 
0020 class KBBGameDoc;
0021 class KBBLevelConfigurationWidget;
0022 class KBBScalableGraphicWidget;
0023 class KBBThemeManager;
0024 class KBBTutorial;
0025 
0026 /**
0027 * @brief Main window of the game KBlackBox
0028 */
0029 class KBBMainWindow : public KXmlGuiWindow
0030 {
0031     Q_OBJECT
0032 
0033 
0034     public:
0035         KBBMainWindow();
0036         ~KBBMainWindow() override;
0037 
0038 
0039     public Q_SLOTS:
0040         /**
0041          * @brief Player changed the level
0042          */
0043         void levelChanged();
0044 
0045         /**
0046          * @brief Set if the game is running
0047          */
0048         void setRunning(bool r);
0049 
0050         /**
0051          * @brief Displays game statistics on the status bar
0052          */
0053         void updateStats();
0054 
0055     private Q_SLOTS:
0056         /**
0057          * @brief Ends the current game
0058          *
0059          * This function is used when the player is done.
0060          * @see solve()
0061          */
0062         void done();
0063 
0064         /**
0065          * @brief Start a new game.
0066          */
0067         void newGame();
0068 
0069         /**
0070          * @brief Pause the game.
0071          */
0072         void pause(bool state);
0073 
0074         /**
0075          * @brief Settings changed
0076          */
0077         void settingsChanged();
0078 
0079         /**
0080          * @brief Show the settings dialog
0081          */
0082         void settingsDialog();
0083 
0084         /**
0085          * @brief Show the highscores
0086          */
0087         void showHighscores();
0088 
0089         /**
0090          * @brief Give up the current game
0091          *
0092          * This function is used when the player is giving up.
0093          * @see check()
0094          */
0095         void solve();
0096 
0097         /**
0098          * @brief Start a game in the sandbox mode
0099          */
0100         void startSandbox();
0101 
0102         /**
0103          * @brief Start tutorial mode
0104          */
0105         void startTutorial();
0106 
0107         void toggleCursor();
0108 
0109     private:
0110         /**
0111          * Statusbar IDs.
0112          */
0113         static const int SRUN = 0;
0114         static const int STIME = 1;
0115         static const int SSIZE = 2;
0116 
0117 
0118         /**
0119          * @brief If needed, ask the player if he agrees to end the current game.
0120          *
0121          * @return if the current game may be aborted
0122          */
0123         bool mayAbortGame();
0124 
0125         void solving();
0126 
0127         /**
0128          * @brief Start a new game.
0129          */
0130         void startGame(bool newSandboxModeMode);
0131 
0132 
0133         // Actions
0134         QAction *m_doneAction;
0135         QAction *m_pauseAction;
0136         QAction *m_solveAction;
0137         QAction *m_toggleCursorAction;
0138 
0139 
0140         /**
0141          * @brief The game document
0142          */
0143         KBBGameDoc* m_gameDoc;
0144 
0145         /**
0146          * @brief The game main widget
0147          */
0148         KBBScalableGraphicWidget* m_gameWidget;
0149 
0150 
0151         // Custom difficulty level
0152         int m_customBallNumber;
0153         int m_customColumns;
0154         int m_customRows;
0155 
0156         // Various member variables
0157         int m_ballNumber;
0158         QWidget* m_centralWidget;
0159         int m_columns;
0160         KGameClock* m_gameClock;
0161         KGameDifficultyLevel::StandardLevel m_level;
0162         KBBLevelConfigurationWidget* m_levelConfig;
0163         int m_rows;
0164         bool m_boardEnabled;
0165         bool m_sandboxMode;
0166         KBBThemeManager* m_themeManager;
0167         KBBTutorial* m_tutorial;
0168 };
0169 
0170 #endif // KBLACKBOX_KBBMAINWINDOW_H