1/*
2 Copyright 2007 Dmitry Suzdalev <dimsuz@gmail.com>
3 Copyright 2010 Brian Croom <brian.s.croom@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 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19#ifndef SCENE_H
20#define SCENE_H
21
22#include <QGraphicsView>
23#include <QGraphicsScene>
24#include <KGameRenderer>
25
26class MineFieldItem;
27class KGamePopupItem;
28
29/**
30 * Graphics scene for KMines game
31 */
32class KMinesScene : public QGraphicsScene
33{
34 Q_OBJECT
35public:
36 /**
37 * Constructs scene
38 */
39 explicit KMinesScene( QObject* parent );
40 /**
41 * Resizes scene to given dimensions
42 */
43 void resizeScene(int width, int height);
44 /**
45 * @return total number of mines in field
46 */
47 int totalMines() const;
48 /**
49 * Starts new game
50 */
51 void startNewGame(int rows, int cols, int numMines);
52 /**
53 * Toggles paused state for all cells in the field item
54 */
55 void setGamePaused(bool paused);
56
57 KGameRenderer& renderer() {return m_renderer;}
58signals:
59 void minesCountChanged(int);
60 void gameOver(bool);
61 void firstClickDone();
62private slots:
63 void onGameOver(bool);
64private:
65 KGameRenderer m_renderer;
66 /**
67 * Game field graphics item
68 */
69 MineFieldItem* m_fieldItem;
70 KGamePopupItem* m_messageItem;
71 KGamePopupItem* m_gamePausedMessageItem;
72};
73
74class QResizeEvent;
75
76class KMinesView : public QGraphicsView
77{
78public:
79 KMinesView( KMinesScene* scene, QWidget *parent );
80private:
81 virtual void resizeEvent( QResizeEvent *ev );
82
83 KMinesScene* m_scene;
84};
85#endif
86