Compiles again
[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 #include <QTime>
35
36 class SeaScene : public QGraphicsScene
37 {
38     Q_OBJECT
39 public:
40     explicit SeaScene(QObject *parent = 0);
41
42 signals:
43
44     void allGhostsPicked();
45     void pauseOn();
46     void pauseOff();
47     void vibrationActivated(bool on);
48
49 public slots:
50
51     /*! Places all needed items for a level to (re)start.
52     Relies on the scene size to be explicitly set to a a value that will persist troughout play.
53     @param ghosts the number of ghosts to be placed on the map
54     @param rocks the number of rocks to be placed on the map
55     @param octopuses number of octopuses to be placed on the map
56     */
57     void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
58
59     void setupMap(Level level);
60
61     void spreadGhosts(int ghosts);
62
63     void removeGhost(QGraphicsItem * pGhost);
64
65     void ghostsDropped(int ghosts);
66
67     void pause (bool paused);
68
69     void vibrationActivate(bool);
70
71     void handleScreenTapped();
72
73     void about();
74
75     void restartLevel();
76
77     void nextLevel();
78
79     void restartGame();
80
81     void forcePause();
82
83     void softContinue();
84
85     void setItemPointersNull();
86
87     void turnPauseOn();
88
89
90
91 protected:
92
93     /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
94         The position is the upper left corner of a free 40x40 pixels slot.
95     */
96
97     QPointF* findRandomFreeSlot();
98
99     void createMenuItems();
100     void prepareForMenu(QGraphicsItem * pItem);
101     void createAboutBoxItems();
102     void createVictoryItems();
103     void createLevelCompletedItems();
104
105     const QString ghostImageFilename_;
106     const QString rockImageFilename_;
107     const QString octopusImageFilename_;
108     const QStringList shipImageFilenames_;
109
110     QList<QPointF> freeTiles_;
111
112     int ghostsLeft_;
113
114     QList<QGraphicsItem*> movingItems_;
115
116     bool paused_;
117
118     ScreenLitKeeper screenLitKeeper_;
119
120
121     int menuItemCount_;
122
123     QGraphicsTextItem * pPausetextItem_;
124
125     QGraphicsTextItem * pRestartLevelItem_;
126     QGraphicsTextItem * pRestartGameItem_;
127     QGraphicsTextItem * pSettingsItem_;
128     QGraphicsTextItem * pAboutItem_;
129     QGraphicsTextItem * pQuitItem_;
130
131     QGraphicsTextItem * pVictoryScoreItem_;
132     QGraphicsTextItem * pAboutBoxItem_;
133     QGraphicsTextItem * pVictoryCongratulationsItem_;
134
135     QGraphicsTextItem * pLevelCompletedItem_;
136
137
138     Levelset levelset_;
139
140     int currentLevel_;
141
142
143     QAction* pVibrateAction_;
144
145     QAction* pPauseAction_;
146
147     bool pauseForced_;
148
149     QTimer autopauseTimer;
150
151
152     QTime scoreCounter_;
153     int totalScore_;
154     int levelScore_;
155 };
156
157 #endif // SEASCENE_H