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

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 KBLOCKSREPWIN_H
0009 #define KBLOCKSREPWIN_H
0010 
0011 #include <KMainWindow>
0012 #include <QTimer>
0013 #include <QString>
0014 #include <QPixmap>
0015 
0016 #include "KBlocksScene.h"
0017 #include "KBlocksView.h"
0018 #include "KBlocksGameLogic.h"
0019 #include "KBlocksGameReplayer.h"
0020 
0021 using std::string;
0022 
0023 class GraphicsInterface;
0024 class SoundInterface;
0025 
0026 class KBlocksRepWin : public KMainWindow
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     explicit KBlocksRepWin(
0032         GraphicsInterface *graphics,
0033         SoundInterface *sound,
0034         const char *replayFile,
0035         bool binaryMode = true
0036     );
0037     ~KBlocksRepWin() override;
0038 
0039 public:
0040     void setGamesPerLine(int count);
0041 
0042     void setUpdateInterval(int interval);
0043     void setReplayStepLength(int stepLen);
0044 
0045     void setSnapshotFolder(const QString &folder);
0046     void setSnapshotFilename(const QString &fileName);
0047 
0048     bool replayLoaded();
0049 
0050 public:
0051     void startReplay();
0052     void stopReplay();
0053 
0054 private:
0055     QString getTimeString();
0056     void snapshotView();
0057 
0058 private Q_SLOTS:
0059     void replayOneStep();
0060 
0061 private:
0062     int mGameCount;
0063     //int mGamesPerWidth;
0064 
0065     int mUpdateInterval;
0066     QTimer mUpdateTimer;
0067 
0068     QString mSnapshotFolder;
0069     QString mSnapshotFilename;
0070     QPixmap mSnapshoter;
0071 
0072     KBlocksScene *mpGameScene = nullptr;
0073     KBlocksView  *mpGameView = nullptr;
0074 
0075     KBlocksGameLogic *mpGameLogic = nullptr;
0076     KBlocksGameReplayer *mpGameReplayer = nullptr;
0077 };
0078 
0079 #endif