File indexing completed on 2024-04-14 03:59:24

0001 /***************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                *
0003 *   SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com>       *
0004 *                                                                         *
0005 *   SPDX-License-Identifier: GPL-2.0-or-later
0006 ***************************************************************************/
0007 #ifndef KBLOCKSLAYOUT_H
0008 #define KBLOCKSLAYOUT_H
0009 
0010 #include "FieldInterface.h"
0011 #include "PieceInterface.h"
0012 
0013 #include "KBlocksDefine.h"
0014 
0015 #include <QPoint>
0016 #include <QList>
0017 
0018 enum KBlocks_Layout_Update_Type {
0019     KBlocksLayout_Update_FreezePiece = 0,
0020     KBlocksLayout_Update_RemoveLine,
0021     KBlocksLayout_Update_PunishLine,
0022     KBlocksLayout_Update_Max_Count
0023 };
0024 
0025 class KBlocksLayout
0026 {
0027 public:
0028     KBlocksLayout(FieldInterface *pF, PieceInterface *pA, PieceInterface *pN);
0029     ~KBlocksLayout();
0030 
0031     void beginUpdate(QList<int> *list);
0032     void updateLayout(int type, const QList<int> &dataList);
0033     void endUpdate();
0034 
0035     void updateSnapshot();
0036 
0037     int getFieldColor(int posX, int posY);
0038     int getPrepareColor(int posX, int posY);
0039 
0040 private:
0041     void updatePrepareArea();
0042     void updateFreezePiece(const QList<int> &dataList);
0043     void updateRemoveLine(const QList<int> &dataList);
0044     void updatePunishLine(const QList<int> &dataList);
0045 
0046 private:
0047     FieldInterface *mpGameField = nullptr;
0048     PieceInterface *mpActivePiece = nullptr;
0049     PieceInterface *mpNextPiece = nullptr;
0050 
0051     int **boardInfo;
0052     int **prepareInfo;
0053 
0054     int mPieceCellCount;
0055     QPoint **mpLastPiecePos;
0056 
0057     int mWidth;
0058     int mHeight;
0059 };
0060 
0061 #endif
0062