1/***************************************************************************
2* KBlocks, a falling blocks game for KDE *
3* Copyright (C) 2009 Mauricio Piacentini <mauricio@tabuleiro.com> *
4* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
5* *
6* This program is free software; you can redistribute it and/or modify *
7* it under the terms of the GNU General Public License as published by *
8* the Free Software Foundation; either version 2 of the License, or *
9* (at your option) any later version. *
10***************************************************************************/
11#ifndef KBLOCKSWIN_H
12#define KBLOCKSWIN_H
13
14#include <KXmlGuiWindow>
15
16#include "KBlocksScene.h"
17#include "KBlocksView.h"
18
19#include "KBlocksKeyboardPlayer.h"
20#include "AI/KBlocksAIPlayer.h"
21
22#include "KBlocksGameLogic.h"
23#include "KBlocksPlayManager.h"
24
25class KBlocksWin : public KXmlGuiWindow
26{
27 Q_OBJECT
28
29 public:
30 KBlocksWin(KBlocksGameLogic * p, KBlocksPlayManager * pM, int capacity, int gamecount);
31 ~KBlocksWin();
32
33 public:
34 void setGamesPerLine(int count);
35 void setGameAnimEnabled(bool flag);
36 void setWaitForAllUpdate(bool flag);
37 void setUpdateInterval(int interval);
38
39 void addScore(int gameIndex, int lineCount);
40
41 private slots:
42 void startGame();
43 void stopGame();
44 void pauseGame();
45
46 void singleGame();
47 void pveStepGame();
48
49 void focusEvent(bool flag);
50
51 void configureSettings();
52 void showHighscore();
53 void onScoreChanged(int index, int points, int lines, int level);
54 void onIsHighscore(int index, int points, int level);
55 void levelChanged();
56 void setSoundsEnabled(bool enabled);
57
58 private:
59 void setupGUILayout();
60
61 protected:
62 virtual void closeEvent(QCloseEvent *event);
63
64 private:
65 int mMaxGameCapacity;
66 int mGameCount;
67
68 bool mFirstInit;
69
70 bool mGameAnim;
71 bool mWaitForAll;
72
73 KBlocksScene* mpGameScene;
74 KBlocksView* mpGameView;
75
76 KBlocksGameLogic* mpGameLogic;
77 KBlocksPlayManager* mpPlayManager;
78
79 KBlocksKeyboardPlayer* mpKBPlayer;
80 KBlocksAIPlayer* mpAIPlayer;
81
82 QAction* m_pauseAction;
83};
84
85#endif
86