File indexing completed on 2024-10-13 03:44:25

0001 /*
0002     SPDX-FileCopyrightText: 2013 Ashwin Rajeev <ashwin_rajeev@hotmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef GAMEVIEW_H
0008 #define GAMEVIEW_H
0009 
0010 // game
0011 #include "abstractgrid.h"
0012 // KDEGames
0013 #include <KGameThemeProvider>
0014 // Qt
0015 #include <QQuickWidget>
0016 #include <QVariant>
0017 #include <QQuickItem>
0018 
0019 class KGameSound;
0020 
0021 class GameView : public QQuickWidget
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit GameView(QWidget *parent=nullptr);
0026     ~GameView() override;
0027     void startNewGame(uint width, uint height, Wrapping w);
0028     int minimumMoves() {return grid->minimumMoves();}
0029     int cellCount() {return grid->cellCount();}
0030     KGameThemeProvider* getProvider() {return m_provider;}
0031     
0032 
0033 
0034 public Q_SLOTS:
0035     void updateSettings();
0036     void solve();
0037 
0038 Q_SIGNALS:
0039     void newCell(const QVariant &cable, const QVariant &type);
0040     void setSprite(const QVariant &pos, const QVariant &cable, const QVariant &type);
0041     void setSize(const QVariant &width, const QVariant &height);
0042     void rotationStarted();
0043     void lock(const QVariant&);
0044     void gameOver(const QVariant &msg);
0045 
0046 private Q_SLOTS:
0047     void clicked(int index);
0048     void rotated(int index, int angle);
0049 
0050 private:
0051     QString getCableCode(int cables);
0052     void updateSprite(int index);
0053     void checkCompleted();
0054 
0055     AbstractGrid *grid;
0056     KGameThemeProvider* m_provider;
0057     KGameSound *m_soundTurn;
0058     KGameSound *m_soundClick;
0059     KGameSound *m_soundConnect;
0060     QSet<int> rotatingCells;
0061 };
0062 
0063 #endif //GAMEVIEW_H