1 | /*************************************************************************** |
---|---|
2 | * KBlocks, a falling blocks game for KDE * |
3 | * Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | ***************************************************************************/ |
10 | #ifndef KBLOCKSDISPLAY_H |
11 | #define KBLOCKSDISPLAY_H |
12 | |
13 | #include <string> |
14 | |
15 | #include <KMainWindow> |
16 | #include <QTimer> |
17 | |
18 | #include "KBlocksScene.h" |
19 | #include "KBlocksView.h" |
20 | |
21 | #include "KBlocksGameLogic.h" |
22 | #include "KBlocksNetClient.h" |
23 | |
24 | using std::string; |
25 | |
26 | class KBlocksDisplay : public KMainWindow |
27 | { |
28 | Q_OBJECT |
29 | |
30 | public: |
31 | KBlocksDisplay(int gameCount, const string& serverIP, int localPort); |
32 | ~KBlocksDisplay(); |
33 | |
34 | public: |
35 | void setGamesPerLine(int count); |
36 | void setUpdateInterval(int interval); |
37 | |
38 | public: |
39 | void startDisplay(); |
40 | void stopDisplay(); |
41 | |
42 | private: |
43 | int formIntFromByte(char * data); |
44 | void updateScore(); |
45 | |
46 | private slots: |
47 | void updateEvent(); |
48 | void updateGameDisplay(int size); |
49 | |
50 | private: |
51 | int mGameCount; |
52 | int mGamesPerWidth; |
53 | |
54 | int mUpdateInterval; |
55 | QTimer mUpdateTimer; |
56 | |
57 | int maScoreList[8]; |
58 | |
59 | KBlocksScene* mpGameScene; |
60 | KBlocksView* mpGameView; |
61 | |
62 | KBlocksGameLogic* mpGameLogic; |
63 | KBlocksNetClient* mpNetClient; |
64 | }; |
65 | |
66 | #endif |
67 | |
68 |