The levels are now stored in the Levelset class
[ghostsoverboard] / seascene.h
1 /**************************************************************************
2         Ghosts Overboard - a game for 'Meego 1.2 Harmattan'
3
4         Copyright (C) 2011  Heli Hyvättinen
5
6         This file is part of Ghosts Overboard
7
8         Ghosts Overboard is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 2 of the License, or
11         (at your option) any later version.
12
13         This program is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 **************************************************************************/
22
23
24 #ifndef SEASCENE_H
25 #define SEASCENE_H
26
27 #include <QGraphicsScene>
28 #include<QGraphicsItemGroup>
29 #include "screenlitkeeper.h"
30 #include "level.h"
31 #include "levelset.h"
32 #include <QAction>
33 #include <QTimer>
34
35 class SeaScene : public QGraphicsScene
36 {
37     Q_OBJECT
38 public:
39     explicit SeaScene(QObject *parent = 0);
40
41 signals:
42
43     void allGhostsPicked();
44     void pauseOn();
45     void pauseOff();
46     void vibrationActivated(bool on);
47
48 public slots:
49
50     /*! Places all needed items for a level to (re)start.
51     Relies on the scene size to be explicitly set to a a value that will persist troughout play.
52     @param ghosts the number of ghosts to be placed on the map
53     @param rocks the number of rocks to be placed on the map
54     @param octopuses number of octopuses to be placed on the map
55     */
56     void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
57
58     void setupMap(Level level);
59
60     void spreadGhosts(int ghosts);
61
62     void removeGhost(QGraphicsItem * pGhost);
63
64     void ghostsDropped(int ghosts);
65
66     void pause (bool paused);
67
68     void vibrationActivate(bool);
69
70     void handleScreenTapped();
71
72     void about();
73
74     void restartLevel();
75
76     void nextLevel();
77
78     void restartGame();
79
80     void forcePause();
81
82     void softContinue();
83
84     void createAboutBoxItems();
85     void createVictoryItems();
86
87     void setItemPointersNull();
88
89     void turnPauseOn();
90
91
92
93 protected:
94
95     /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
96         The position is the upper left corner of a free 40x40 pixels slot.
97     */
98
99     QPointF* findRandomFreeSlot();
100
101     void createMenuItems();
102     void prepareForMenu(QGraphicsItem * pItem);
103
104     const QString ghostImageFilename_;
105     const QString rockImageFilename_;
106     const QString octopusImageFilename_;
107     const QStringList shipImageFilenames_;
108
109     QList<QPointF> freeTiles_;
110
111     int ghostsLeft_;
112
113     QList<QGraphicsItem*> movingItems_;
114
115     bool paused_;
116
117     ScreenLitKeeper screenLitKeeper_;
118
119
120     int menuItemCount_;
121
122     QGraphicsTextItem * pPausetextItem_;
123
124     QGraphicsTextItem * pRestartLevelItem_;
125     QGraphicsTextItem * pRestartGameItem_;
126     QGraphicsTextItem * pSettingsItem_;
127     QGraphicsTextItem * pAboutItem_;
128     QGraphicsTextItem * pQuitItem_;
129
130     QGraphicsTextItem * pAboutBoxItem_;
131     QGraphicsTextItem * pVictoryCongratulationsItem_;
132
133
134     Levelset levelset_;
135
136     int currentLevel_;
137
138
139     QAction* pVibrateAction_;
140
141     QAction* pPauseAction_;
142
143     bool pauseForced_;
144
145     QTimer autopauseTimer;
146
147 };
148
149 #endif // SEASCENE_H