1 /**************************************************************************
2 Ghosts Overboard - a game for Maemo 5
4 Copyright (C) 2011 Heli Hyvättinen
6 This file is part of Ghosts Overboard
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.
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.
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/>.
21 **************************************************************************/
27 #include <QGraphicsScene>
28 #include<QGraphicsItemGroup>
29 #include "screenlitkeeper.h"
34 #include <QSystemDeviceInfo>
37 using namespace QtMobility;
39 class SeaScene : public QGraphicsScene
43 explicit SeaScene(QObject *parent = 0);
47 void allGhostsPicked();
50 void vibrationActivated(bool on);
51 void minimizeRequested();
52 void fullscreenRequested();
53 void deviceJustLocked();
57 /*! Places all needed items for a level to (re)start.
58 Relies on the scene size to be explicitly set to a a value that will persist troughout play.
59 @param ghosts the number of ghosts to be placed on the map
60 @param rocks the number of rocks to be placed on the map
61 @param octopuses number of octopuses to be placed on the map
63 void setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed);
65 void setupMap(Level level);
67 void spreadGhosts(int ghosts);
69 void removeGhost(QGraphicsItem * pGhost);
71 void ghostsDropped(int ghosts);
73 void pause (bool paused);
75 void vibrationActivate(bool);
77 void handleScreenTapped();
91 void setItemPointersNull();
95 void handleDeviceLocked(bool isLocked);
97 void pollDeviceLocked();
103 /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
104 The position is the upper left corner of a free 40x40 pixels slot.
107 QPointF* findRandomFreeSlot();
109 void createMenuItems();
110 void prepareForMenu(QGraphicsItem * pItem);
111 void createAboutBoxItems();
112 void createVictoryItems();
113 void createLevelCompletedItem();
115 const QString ghostImageFilename_;
116 const QString rockImageFilename_;
117 const QString octopusImageFilename_;
118 const QStringList shipImageFilenames_;
120 QList<QPointF> freeTiles_;
124 QList<QGraphicsItem*> movingItems_;
128 ScreenLitKeeper screenLitKeeper_;
132 QGraphicsTextItem * pPausetextItem_;
134 QGraphicsTextItem * pRestartLevelItem_;
135 QGraphicsTextItem * pRestartGameItem_;
136 QGraphicsTextItem * pSettingsItem_;
137 QGraphicsTextItem * pAboutItem_;
138 QGraphicsTextItem * pQuitItem_;
139 QGraphicsTextItem * pMinimizeItem_;
141 QGraphicsTextItem * pVictoryCongratulationsItem_;
142 QGraphicsTextItem * pAboutBoxItem_;
144 QGraphicsTextItem * pLevelCompletedItem_;
152 QAction* pVibrateAction_;
154 QAction* pPauseAction_;
156 QTimer autopauseTimer;
158 QSystemDeviceInfo deviceInfo_;
162 QTimer deviceLockPollTimer_;