File indexing completed on 2024-04-21 04:01:58

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0003     SPDX-FileCopyrightText: 2007-2008 Pierre-Benoit Bessse <besse@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KAPMANMAINWINDOW_H
0009 #define KAPMANMAINWINDOW_H
0010 
0011 #include "game.h"
0012 #include "gameview.h"
0013 
0014 #include <KXmlGuiWindow>
0015 #include <QGraphicsView>
0016 
0017 static const int initLives = 3;
0018 
0019 class KGameThemeSelector;
0020 class KGameThemeProvider;
0021 class KGameTheme;
0022 class QStatusBar;
0023 class QLabel;
0024 
0025 /**
0026  * @brief This class enables to create the main window for Kapman.
0027  */
0028 class KapmanMainWindow : public KXmlGuiWindow
0029 {
0030     Q_OBJECT
0031 
0032 private:
0033     /** The GameView instance that manages the game drawing and the collisions */
0034     GameView *m_view = nullptr;
0035 
0036     /** The Game instance that manages the main loop and events */
0037     Game *m_game = nullptr;
0038 
0039     KGameThemeProvider *m_themeProvider = nullptr;
0040     KGameThemeSelector *m_themeSelector = nullptr;
0041     QStatusBar *m_statusBar = nullptr;
0042     QLabel *mLevel = nullptr;
0043     QLabel *mScore = nullptr;
0044     QLabel *mLives = nullptr;
0045 
0046 public:
0047     /**
0048      * Creates a new KapmanMainWindow instance.
0049      */
0050     KapmanMainWindow();
0051 
0052     /**
0053      * Deletes the KapmanMainWindow instance.
0054      */
0055     ~KapmanMainWindow() override;
0056 
0057 private Q_SLOTS:
0058 
0059     /**
0060      * Initializes the KapmanMainWindow for a new game.
0061      * Creates a new Game instance and a new GameView instance that displays the game.
0062      */
0063     void initGame();
0064 
0065     void handleGameOver();
0066 
0067     /**
0068      * Starts a new game.
0069      */
0070     void newGame();
0071 
0072     /**
0073      * Shows the highscores dialog.
0074      */
0075     void showHighscores();
0076 
0077     /**
0078      * Shows a dialog enabling to change the current level.
0079      */
0080     void changeLevel();
0081 
0082     /**
0083      * Sets the sounds enabled / disabled.
0084      * @param p_enabled if true the sounds will be enabled, otherwise they will be disabled
0085      */
0086     void setSoundsEnabled(bool p_enabled);
0087 
0088     /**
0089      * Shows the settings dialog.
0090      */
0091     void showSettings();
0092 
0093     /**
0094      * Loads the theme.
0095      */
0096     void onThemeChanged(const KGameTheme *theme);
0097 
0098     /**
0099      * Closes the KapmanMainWindow.
0100      */
0101     void close();
0102 
0103     /**
0104      * Refreshes new level value on Status Bar.
0105      * @param p_level is level value
0106      */
0107     void displayLevel(unsigned int p_level);
0108 
0109     /**
0110      * Refreshes new score value on Status Bar.
0111      * @param p_score is score value
0112      */
0113     void displayScore(unsigned int p_score);
0114 
0115     /**
0116      * Refreshes new lives value on Status Bar.
0117      * @param p_lives is lives value
0118      */
0119     void displayLives(unsigned int p_lives);
0120 
0121     /**
0122      * Resets the status bar values altogether for convenience.
0123      */
0124     void resetStatusBar();
0125 
0126     void viewFullScreen(bool fullScreen);
0127 };
0128 
0129 #endif