File indexing completed on 2024-04-21 04:02:09

0001 /******************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                     *
0003 *   SPDX-FileCopyrightText: 2009-2021 Mauricio Piacentini <mauricio@tabuleiro.com>      *
0004 *                           Zhongjie Cai <squall.leonhart.cai@gmail.com>      *
0005 *                           Julian Helfferich <julian.helfferich@mailbox.org> *
0006 *                                                                             *
0007 *   SPDX-License-Identifier: GPL-2.0-or-later
0008 ******************************************************************************/
0009 #ifndef KBLOCKSWIN_H
0010 #define KBLOCKSWIN_H
0011 
0012 #include <KXmlGuiWindow>
0013 
0014 #include "KBlocksView.h"
0015 
0016 #include "KBlocksKeyboardPlayer.h"
0017 #include "AI/KBlocksAIPlayer.h"
0018 
0019 #include "KBlocksPlayManager.h"
0020 
0021 class KGameThemeSelector;
0022 class KGameThemeProvider;
0023 class KGameTheme;
0024 class QLabel;
0025 class GameLogicInterface;
0026 class GraphicsInterface;
0027 class SceneInterface;
0028 class SoundInterface;
0029 
0030 class KBlocksWin : public KXmlGuiWindow
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     KBlocksWin(
0036         GameLogicInterface *p,
0037         GraphicsInterface *graphics,
0038         SoundInterface *sound,
0039         KGameThemeProvider *themeProvider,
0040         KBlocksPlayManager *pM,
0041         int capacity,
0042         int gamecount
0043     );
0044     ~KBlocksWin() override;
0045 
0046 public:
0047     void setGamesPerLine(int count);
0048     void setGameAnimEnabled(bool flag);
0049     void setWaitForAllUpdate(bool flag);
0050     void setUpdateInterval(int interval);
0051 
0052     void addScore(int gameIndex, int lineCount);
0053 
0054     void setupGUILayout();
0055 
0056 protected Q_SLOTS:
0057     void stopGame();
0058 
0059 private Q_SLOTS:
0060     void startGame();
0061     void pauseGame();
0062 
0063     void singleGame();
0064     void pveStepGame();
0065 
0066     void focusEvent(bool flag);
0067 
0068     void configureSettings();
0069     void showHighscore();
0070     void onScoreChanged(int index, int points, int lines, int level);
0071     void onIsHighscore(int index, int points, int level);
0072     void onAllGamesStopped();
0073     void levelChanged();
0074     void setSoundsEnabled(bool enabled);
0075     void onThemeChanged(const KGameTheme *theme);
0076 
0077 protected:
0078     void closeEvent(QCloseEvent *event) override;
0079 
0080 protected:
0081     SceneInterface *mpGameScene = nullptr;
0082     KBlocksView  *mpGameView = nullptr;
0083 
0084     KBlocksKeyboardPlayer *mpKBPlayer = nullptr;
0085 
0086 private:
0087     int mMaxGameCapacity;
0088     int mGameCount;
0089 
0090     bool mGameAnim;
0091     bool mWaitForAll;
0092 
0093     GameLogicInterface *mpGameLogic = nullptr;
0094     KBlocksPlayManager *mpPlayManager = nullptr;
0095 
0096     KBlocksAIPlayer *mpAIPlayer = nullptr;
0097 
0098     KGameThemeSelector *m_themeSelector = nullptr;
0099     QAction *m_pauseAction = nullptr;
0100     QLabel *mScore = nullptr;
0101 };
0102 
0103 #endif