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 KBLOCKSLAYOUT_H |
11 | #define KBLOCKSLAYOUT_H |
12 | |
13 | #include "FieldInterface.h" |
14 | #include "PieceInterface.h" |
15 | |
16 | #include "KBlocksDefine.h" |
17 | |
18 | #include <QPoint> |
19 | #include <QList> |
20 | |
21 | enum KBlocks_Layout_Update_Type |
22 | { |
23 | KBlocksLayout_Update_FreezePiece = 0, |
24 | KBlocksLayout_Update_RemoveLine, |
25 | KBlocksLayout_Update_PunishLine, |
26 | KBlocksLayout_Update_Max_Count |
27 | }; |
28 | |
29 | class KBlocksLayout |
30 | { |
31 | public: |
32 | KBlocksLayout(FieldInterface * pF, PieceInterface * pA, PieceInterface * pN); |
33 | ~KBlocksLayout(); |
34 | |
35 | void beginUpdate(QList<int> * list); |
36 | void updateLayout(int type, const QList<int> & dataList); |
37 | void endUpdate(); |
38 | |
39 | void updateSnapshot(); |
40 | |
41 | int getFieldColor(int posX, int posY); |
42 | int getPrepareColor(int posX, int posY); |
43 | |
44 | private: |
45 | void updatePrepareArea(); |
46 | void updateFreezePiece(const QList<int> & dataList); |
47 | void updateRemoveLine(const QList<int> & dataList); |
48 | void updatePunishLine(const QList<int> & dataList); |
49 | |
50 | private: |
51 | FieldInterface* mpGameField; |
52 | PieceInterface* mpActivePiece; |
53 | PieceInterface* mpNextPiece; |
54 | |
55 | int** boardInfo; |
56 | int** prepareInfo; |
57 | |
58 | int mPieceCellCount; |
59 | QPoint** mpLastPiecePos; |
60 | |
61 | int mWidth; |
62 | int mHeight; |
63 | }; |
64 | |
65 | #endif |
66 | |
67 | |