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