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

0001 /******************************************************************************
0002 *   KBlocks, a falling blocks game by KDE                                     *
0003 *   SPDX-FileCopyrightText: 2010-2021 Zhongjie Cai <squall.leonhart.cai@gmail.com>      *
0004 *                           Julian Helfferich <julian.helfferich@mailbox.org> *
0005 *                                                                             *
0006 *   SPDX-License-Identifier: GPL-2.0-or-later
0007 ******************************************************************************/
0008 #ifndef KBLOCKSDISPLAY_H
0009 #define KBLOCKSDISPLAY_H
0010 
0011 #include <string>
0012 
0013 #include <KMainWindow>
0014 #include <QTimer>
0015 
0016 #include "KBlocksScene.h"
0017 #include "KBlocksView.h"
0018 
0019 #include "KBlocksGameLogic.h"
0020 #include "KBlocksNetClient.h"
0021 
0022 using std::string;
0023 
0024 class QLabel;
0025 class GraphicsInterface;
0026 class SoundInterface;
0027 
0028 class KBlocksDisplay : public KMainWindow
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     KBlocksDisplay(
0034         GraphicsInterface* graphics,
0035         SoundInterface* sound,
0036         int gameCount,
0037         const std::string& serverIP,
0038         int localPort
0039     );
0040     ~KBlocksDisplay() override;
0041 
0042 public:
0043     void setGamesPerLine(int count);
0044     void setUpdateInterval(int interval);
0045 
0046 public:
0047     void startDisplay();
0048     void stopDisplay();
0049 
0050 private:
0051     int  formIntFromByte(char *data);
0052     void updateScore();
0053 
0054 private Q_SLOTS:
0055     void updateEvent();
0056     void updateGameDisplay(int size);
0057 
0058 private:
0059     int mGameCount;
0060     //int mGamesPerWidth;
0061 
0062     int mUpdateInterval;
0063     QTimer mUpdateTimer;
0064 
0065     int maScoreList[8];
0066 
0067     KBlocksScene *mpGameScene = nullptr;
0068     KBlocksView  *mpGameView = nullptr;
0069 
0070     KBlocksGameLogic *mpGameLogic = nullptr;
0071     KBlocksNetClient *mpNetClient = nullptr;
0072     QLabel *mScore = nullptr;
0073 };
0074 
0075 #endif
0076