Compiles again
[ghostsoverboard] / seascene.cpp
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 #include "seascene.h"
24 #include "octopus.h"
25 #include "ship.h"
26 #include <QGraphicsPixmapItem>
27 #include <QDebug>
28 #include <QMessageBox>
29 #include <QTime>
30 #include <QApplication>
31 #include <QAction>
32 #include <QPushButton>
33 #include <QLabel>
34 #include <QVBoxLayout>
35 #include <QSettings>
36 #include <QPixmap>
37
38 const QString ghostImageFilename_ = ":/pix/aave.png";
39 const QString rockImageFilename_ =":/pix/kari.png";
40 const QString octopusImageFilename_= ":/pix/tursas.png";
41
42
43 SeaScene::SeaScene(QObject *parent) :
44     QGraphicsScene(parent)
45 {
46
47     setItemPointersNull();
48
49     paused_ = false;
50     screenLitKeeper_.keepScreenLit(true);
51
52     //set background
53
54     QPixmap waves (":/pix/meri.png");
55     waves.scaled(20,20);
56     setBackgroundBrush(QBrush(waves));
57
58     //set random seed
59
60     qsrand(QTime::currentTime().msec()+2);  //+2 to avoid setting it to 1
61
62 //Setup the level list
63
64     QList<Level> levelList;
65     Level level1(5,10);
66     levelList.append(level1);
67     Level level2(5,10,2,50);
68     levelList.append(level2);
69     Level level3(5,15,2,50);
70     levelList.append(level3);
71     Level level4(5,15,4,50);
72     levelList.append(level4);
73     Level level5(5,15,5,100);
74     levelList.append(level5);
75
76     Levelset set ("Original",levelList);
77     levelset_ = set;
78
79     currentLevel_ = 0;
80
81     totalScore_ = 0;
82
83     //This ensures that nextlevel will not be called until its safe to delete the Ship object.
84     //Leaving out Qt::QueuedConnection or calling nextlevel directly instead of emitting the signal will CRASH
85     connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
86
87
88     pVibrateAction_ = new QAction(tr("Vibration effects"),this);
89     pVibrateAction_->setCheckable(true);
90     connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));
91     QSettings settings;
92     pVibrateAction_->setChecked(settings.value("vibration",false).toBool());
93
94
95     pPauseAction_ = new QAction(tr("Pause"),this);
96     pPauseAction_->setCheckable(true);
97     connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
98
99
100     autopauseTimer.setSingleShot(true);
101     autopauseTimer.setInterval(15*60*1000);
102     connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
103
104
105 }
106
107 void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
108 {
109     //empty the map
110
111     clear();
112
113     setItemPointersNull();
114
115     createMenuItems();
116
117     createAboutBoxItems();
118     createVictoryItems();
119
120     createLevelCompletedItems();
121
122
123     //empty the list of moving items
124
125     movingItems_.clear();
126
127     //empty the list of free slots
128     freeTiles_.clear();
129
130     //fill the list of free slots
131
132     int numberOfXTiles  = width() / 40;
133     int numberOfYTiles = height() /40;
134
135 //    qDebug() << numberOfXTiles << " slots in x direction";
136 //    qDebug() << numberOfYTiles << " slots in y rirection";
137
138     for (int i = 0; i < numberOfXTiles; i++ )
139     {
140         for (int j = 0; j < numberOfYTiles; j++)
141         {
142             freeTiles_.append(QPointF(i*40,j*40));
143         }
144     }
145
146
147     //spread the rocks
148
149     for (int i = 0; i < rocks; i++)
150     {
151         QPointF * pPosition = findRandomFreeSlot();
152
153         //If there was no room no point to continue
154         if (pPosition == NULL)
155             break;
156
157         QPixmap rockPixmap (":/pix/kari.png");
158         QGraphicsPixmapItem * pRock = addPixmap(rockPixmap);
159         pRock->setData(0,"rock");
160         pRock->setPos(*pPosition);
161         delete pPosition;
162
163     }
164
165     //spread the ghosts
166
167     ghostsLeft_ = ghosts;
168     spreadGhosts(ghosts);
169
170
171
172     //spread the octopuses
173
174     QList <Octopus*> octopusList;
175
176     for (int i=0; i < octopuses; i++)
177     {
178         QPointF * pPosition = findRandomFreeSlot();
179
180         //If there was no room no point to continue
181         if (pPosition == NULL)
182             break;
183
184     QPixmap octopusPixmap (":/pix/tursas.png");
185     Octopus * pOctopus = new Octopus(octopusPixmap,octopusSpeed);
186     pOctopus->setData(0,"octopus");
187     pOctopus->setPos(*pPosition);
188     addItem(pOctopus);
189     pOctopus->startMoving();
190     movingItems_.append(pOctopus);
191     connect(this,SIGNAL(pauseOn()),pOctopus,SLOT(stopMoving()));
192     connect(this,SIGNAL(pauseOff()),pOctopus,SLOT(startMoving()));
193     octopusList.append(pOctopus);
194     delete pPosition;
195
196     }
197
198
199     //place the ship
200
201     QPointF * pPosition = findRandomFreeSlot();
202     if (pPosition == NULL)
203     {
204         // Game cannot begin without a free position for ship, so give an error message and return
205
206         QMessageBox::critical(NULL,"Error! Too many objects on screen","No free space to place the ship. The game cannot start. Please choose another level.");
207         return;
208     }
209
210     QList<QPixmap> shipImages;
211     shipImages.append(QPixmap(":/pix/laiva.png"));
212     shipImages.append(QPixmap(":/pix/laiva_1aave.png"));
213     shipImages.append(QPixmap(":/pix/laiva_2aave.png"));
214     shipImages.append(QPixmap(":/pix/laiva_3aave.png"));
215     shipImages.append(QPixmap(":/pix/laiva_4aave.png"));
216     shipImages.append(QPixmap(":/pix/laiva_5aave.png"));
217     shipImages.append(QPixmap(":/pix/laiva_6aave.png"));
218     shipImages.append(QPixmap(":/pix/laiva_7aave.png"));
219     shipImages.append(QPixmap(":/pix/laiva_8aave.png"));
220     shipImages.append(QPixmap(":/pix/laiva_9aave.png"));
221     shipImages.append(QPixmap(":/pix/laiva_10aave.png"));
222
223     Ship * pShip = new Ship (shipImages);
224     pShip->setData(0,"ship");
225     pShip->setPos(*pPosition);
226     addItem(pShip);
227     connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
228     connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
229     connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
230     pShip->startMoving();
231     movingItems_.append(pShip);
232     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
233     connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
234     foreach (Octopus* pOctopus, octopusList)
235     {
236         connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
237     }
238     delete pPosition;
239 }
240
241 void SeaScene::setupMap(Level level)
242 {
243     setupMap(level.getNumberOfGhosts(),level.getNumberOfRocks(),level.getNumberOfOctopuses(),level.getOctopusSpeed());
244 }
245
246 void SeaScene::spreadGhosts(int ghosts)
247 {
248
249
250     //the octopuses and the ship may have moved from their original positions,
251     //so the list of free slots must be adjusted to exclude their current positions
252
253     QList<QPointF> temporarilyReservedSlots;
254
255     foreach (QGraphicsItem* pItem, movingItems_)
256     {
257         if (pItem == NULL)
258         {
259  //           qDebug() << "NULL item in movingItems_";
260             continue;
261         }
262
263         //round x and y down to fit the slot size
264         int x = pItem->x();
265         x = x/40;
266         x = x*40;
267
268         int y = pItem->y();
269         y = y/40;
270         y=y*40;
271
272
273         QPointF position (x,y);
274
275         //remove the tiles (potentially) occupied by the item from free slots and place in temp list if was in the list before
276
277         if (freeTiles_.removeOne(position))
278             temporarilyReservedSlots.append(position);
279
280
281         position.setX(x+40);
282
283         if (freeTiles_.removeOne(position))
284             temporarilyReservedSlots.append(position);
285
286         position.setY(y+40);
287
288         if (freeTiles_.removeOne(position))
289             temporarilyReservedSlots.append(position);
290
291         position.setX(x);
292
293         if (freeTiles_.removeOne(position))
294             temporarilyReservedSlots.append(position);
295
296     }
297
298
299     //spread ghosts in random free slots
300
301     for (int i=0; i < ghosts; i++)
302     {
303         QPointF * pPosition = findRandomFreeSlot();
304
305         //If there was no room no point to continue
306         if (pPosition == NULL)
307             return;
308
309         QPixmap ghostPixmap(":/pix/aave.png");
310         QGraphicsPixmapItem * pGhost = addPixmap(ghostPixmap);
311         pGhost->setData(0,"ghost");
312         pGhost->setPos(*pPosition);
313         delete pPosition;
314     }
315
316     //return the slots occupied by moving items to free slots
317     freeTiles_.append(temporarilyReservedSlots);
318
319     //clear temp for the next round
320     temporarilyReservedSlots.clear();
321 }
322
323 QPointF* SeaScene::findRandomFreeSlot()
324 {
325     if (freeTiles_.isEmpty())
326         return NULL;
327
328     int index = qrand()%freeTiles_.size();
329
330 //    qDebug()  << index << " index";
331     return new QPointF (freeTiles_.takeAt(index));
332
333 }
334
335 void SeaScene::removeGhost(QGraphicsItem *pGhost)
336 {
337     removeItem(pGhost);  //remove the item from scene
338     freeTiles_.append(pGhost->scenePos()); //add the item's position to free slots
339     delete pGhost;
340     ghostsLeft_--;
341     if (ghostsLeft_ == 0)
342     {
343         emit allGhostsPicked();
344  //       qDebug() << "All ghosts picked!";
345     }
346 }
347
348 void SeaScene::ghostsDropped(int ghosts)
349 {
350     ghostsLeft_ += ghosts;
351
352     spreadGhosts(ghosts);
353 }
354
355 void SeaScene::pause(bool paused)
356 {
357     //    qDebug() << "pause pressed " << paused;
358         if (paused_ == paused)
359                 return;
360
361         paused_ = paused;
362
363         if (paused == false)
364         {
365      //       qDebug() << "starting to move again";
366 //            emit fullscreenRequested();   fremantle specific (since no "show statusbar" action in harmattan version)
367             emit pauseOff();
368             screenLitKeeper_.keepScreenLit(true);
369             if (pPausetextItem_)
370                 pPausetextItem_->hide();
371
372             scoreCounter_.start();
373
374             autopauseTimer.start(); //Start counting towards autopause
375         }
376
377         else
378         {
379 //         qDebug("about to stop movement");
380             emit pauseOn();
381             screenLitKeeper_.keepScreenLit(false);
382             if (pPausetextItem_ != NULL)
383             {
384 //                qDebug() << "about to show the pause text";
385                 pPausetextItem_->show();
386 //                qDebug() << "showing pause text";
387             }
388 //                else qDebug() << "No pause text available";
389
390             levelScore_ += scoreCounter_.elapsed();
391
392             autopauseTimer.stop(); //No need to count toward autopause when already paused
393         }
394 }
395
396 void SeaScene::vibrationActivate(bool on)
397 {
398     emit vibrationActivated(on);
399 }
400
401 void SeaScene::handleScreenTapped()
402 {
403
404     //If the game is going just pause it
405     if (!paused_)
406     {
407         pPauseAction_->setChecked(true);
408         return;
409     }
410
411     //If the game is paused and about box is shown, close it and show the pause text and menu again
412
413     if(pAboutBoxItem_)
414     {
415         if(pAboutBoxItem_->isVisible())
416         {
417             pAboutBoxItem_->hide();
418             pPausetextItem_->show();
419             return;
420         }
421     }
422
423     //If the game is paused, check if the level completed item is shown
424
425     if (pLevelCompletedItem_)
426     {
427         if (pLevelCompletedItem_->isVisible())
428         {
429             pLevelCompletedItem_->hide();
430             restartLevel(); //Current level has already been set to the next one before showing the level completed item
431             pPauseAction_->setChecked(false); //unpause
432             return;
433         }
434     }
435    
436     //If the game is paused, check if the victory item is being shown
437     if(pVictoryCongratulationsItem_)
438     {
439         if (pVictoryCongratulationsItem_->isVisibleTo(NULL)) //returns visibility to scene
440         {
441             pVictoryCongratulationsItem_->hide();
442             restartGame();
443             pPauseAction_->setChecked(false); // unpause
444             return;
445         }
446     }
447
448
449     //If the game is paused and no victory or about box, check if menu item was selected
450
451     QList<QGraphicsItem *> items = selectedItems();
452
453     //if nothing selected resume play
454
455     if (items.isEmpty())
456     {
457         pPauseAction_->setChecked(false);
458         return;
459
460     }
461
462     //If something was selected check if it was one of the menu items and act on it
463     //(Nothing else should be made selectable anyway)
464
465     //Menu functions
466
467     QGraphicsItem* pItem = items.at(0); //Selecting an item brings here, thus only selecting one item should be possible
468                                        //... so we can just take the first one
469
470     //Selection is just used to get notice of a menu item being clicked, removed after use
471
472     clearSelection();
473
474
475     //Act upon the selected item
476
477
478     if (pItem == pRestartGameItem_)
479     {
480 //        qDebug() << "game restart requested";
481         restartGame();
482         pPauseAction_->setChecked(false); //unpause game
483
484     }
485
486     else if (pItem == pRestartLevelItem_)
487     {
488 //        qDebug() << "Level restart requested";
489         restartLevel();
490         pPauseAction_->setChecked(false); //unpause game
491
492     }
493
494     else if (pItem == pSettingsItem_)
495     {
496         pVibrateAction_->toggle();
497
498         QSettings settings;
499         settings.setValue("vibration",pVibrateAction_->isChecked());
500
501         QString text = pSettingsItem_->toHtml();
502         if (pVibrateAction_->isChecked())
503             text.replace(" on"," off"); //don't remove spaces or you get vibratioff...
504         else
505             text.replace(" off"," on");
506         pSettingsItem_->setHtml(text);
507     }
508
509     else if (pItem == pAboutItem_)
510     {
511         about();
512     }
513
514     else if (pItem == pQuitItem_)
515     {
516         qApp->quit();
517     }
518
519 }
520
521
522
523 void SeaScene::createMenuItems()
524 {
525
526     QFont font;
527     font.setPixelSize(35);
528
529
530
531     pPausetextItem_ = new QGraphicsTextItem;
532
533  // This is for fremantle
534 //    pPausetextItem_->setHtml("<font size = \"5\" color = darkorange> Game paused. Tap to continue.");
535
536 //Harmattan needs bigger font
537     pPausetextItem_->setHtml("<font size = \"7\" color = darkorange> Game paused. Tap to continue.");
538
539
540     pPausetextItem_->setZValue(1000);
541     pPausetextItem_->setPos(200,50);
542     addItem(pPausetextItem_);
543     pPausetextItem_->hide();
544
545     menuItemCount_ = 0;
546
547   // This is for fremantle
548  //   QString menufonthtml = "<font size = \"4\" color = darkorange>";
549
550
551  //Harmattan needs bigger font
552         QString menufonthtml = "<font size = \"6\" color = darkorange>";
553
554
555     pRestartGameItem_ = new QGraphicsTextItem;
556     pRestartGameItem_->setHtml(tr("Restart <br> game").prepend(menufonthtml));
557     prepareForMenu(pRestartGameItem_);
558
559     pRestartLevelItem_ = new QGraphicsTextItem;
560     pRestartLevelItem_->setHtml(tr("Restart <br> level").prepend(menufonthtml));
561     prepareForMenu(pRestartLevelItem_);
562
563     pSettingsItem_ = new QGraphicsTextItem;
564     QString vibraText(tr("Turn vibration <br> effects "));
565     QString statusText;
566     if (pVibrateAction_->isChecked())
567     {
568         statusText = "off";
569     }
570     else
571     {
572         statusText = "on";
573     }
574     vibraText.append(statusText);
575     pSettingsItem_->setHtml(vibraText.prepend(menufonthtml));
576     prepareForMenu(pSettingsItem_);
577
578     pAboutItem_ = new QGraphicsTextItem;
579     pAboutItem_->setHtml(tr("About <br> game").prepend(menufonthtml));
580     prepareForMenu(pAboutItem_);
581
582     pQuitItem_ = new QGraphicsTextItem;
583     pQuitItem_->setHtml(tr("Quit <br> game").prepend(menufonthtml));
584     prepareForMenu(pQuitItem_);
585
586 }
587
588 void SeaScene::prepareForMenu(QGraphicsItem * pItem)
589 {
590
591     //Menu items have pause text item as their parent and are thus added to scene automatically
592     //They are also shown and hidden with it, resulting in the menu being visble when the game is paused
593     //Their coordinates are given relative to the parent.
594
595
596     pItem->setParentItem(pPausetextItem_);
597     pItem->setZValue(1000);
598     pItem->setFlag(QGraphicsItem::ItemIsSelectable);
599     pItem->setY(150);
600     pItem->setX(menuItemCount_++*160-150);
601  }
602
603
604 void SeaScene::about()
605 {
606     pPausetextItem_->hide();
607     pAboutBoxItem_->show();
608 }
609
610
611 void SeaScene::restartLevel()
612 {
613
614     levelScore_ = 0;
615
616     setupMap(levelset_.getLevel(currentLevel_));  //getLevel() returns default constructor Level if index is invalid, so no risk of crash
617
618     scoreCounter_.start();
619
620     vibrationActivate(pVibrateAction_->isChecked());  //Vibration effects are lost without this
621    // qDebug() << pVibrateAction_->isChecked();
622     autopauseTimer.start();  //reset counting towards autopause
623
624
625 }
626
627
628
629 void SeaScene::nextLevel()
630 {
631
632     //get score for previous level
633     levelScore_ += scoreCounter_.elapsed();
634     totalScore_ += levelScore_;
635     int highscore = levelset_.getLevelHighScore(currentLevel_);
636
637     qDebug() << highscore;
638
639     QString scoretext;
640
641     if (levelScore_ >= highscore)
642     {
643         scoretext = tr("<font size=\"5\" color = darkorange>Your time: %1.%2 s<br>Best time: %3.%4 s").arg(levelScore_/1000).arg((levelScore_%1000)/100).arg(highscore/1000).arg((highscore%1000)/100);
644     }
645
646     else //New high score!
647
648     {
649         scoretext = tr("<font size=\"5\" color = darkorange>Your time %1.%2 s is<br>the new best time!").arg(levelScore_/1000).arg((levelScore_%1000)/100);
650         levelset_.setLevelHighScore(currentLevel_,levelScore_);
651     }
652
653     //pause to show the highscore or victory screen
654
655     turnPauseOn();
656     pPausetextItem_->hide();
657
658
659     //Go to the next level if available
660     currentLevel_++;
661
662     if ( currentLevel_ < levelset_.numberOfLevels() )
663     {
664
665        pLevelCompletedItem_->setHtml(scoretext);
666        pLevelCompletedItem_->show();
667 //       restartLevel();
668     }
669
670     else //Victory!
671     {
672         int totalHighsore = levelset_.getTotalHighScore();
673         if (totalScore_ >= totalHighsore)
674         {
675             scoretext.append(tr("<br>Your total time: %1.%2 s<br>Best total time:%3.%4 s").arg(totalScore_/1000).arg((totalScore_%1000)/100).arg(totalHighsore/1000).arg((totalHighsore%1000)/100));
676         }
677         else //new total high score
678         {
679             scoretext.append(tr("<br>Your total time %1.%2 s is<br>the new best time").arg(totalScore_/1000).arg((totalScore_%1000)/100));
680             levelset_.setTotalHighScore(totalScore_);
681         }
682
683         pVictoryScoreItem_->setHtml(scoretext);
684         pVictoryCongratulationsItem_->show();
685     }
686 }
687
688
689 void SeaScene::restartGame()
690 {
691     currentLevel_ = 0;
692     totalScore_ = 0;
693     restartLevel();
694 }
695
696
697 void SeaScene::forcePause()
698 {
699     //Pause without setting the pause action state
700     pause(true);
701 }
702
703 void SeaScene::softContinue()
704 {
705     //Continue if not being paused by the user
706     // Reverts forcePause()
707
708     pause(pPauseAction_->isChecked());
709 }
710
711
712 void SeaScene::createVictoryItems()
713 {
714     pVictoryCongratulationsItem_ = new QGraphicsTextItem;
715     pVictoryCongratulationsItem_->setHtml("<font size=\"7\" color = darkorange> <b> Victory!");
716     pVictoryCongratulationsItem_->hide();
717     pVictoryCongratulationsItem_->setPos(315,30);
718     pVictoryCongratulationsItem_->setZValue(1000);
719     addItem(pVictoryCongratulationsItem_);
720
721
722     //coordinates are relative to the parent
723
724     QGraphicsTextItem * pTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
725     pTextItem->setHtml("<font size=\"7\" color = darkorange> Congratulations!");
726     pTextItem->setPos(-50,80);
727     pTextItem->setZValue(1000);
728
729     QGraphicsTextItem * pMiddleTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
730     pMiddleTextItem->setHtml("<font size=\"7\" color = darkorange> You have saved all the ghosts.");
731     pMiddleTextItem->setPos(-145,120);
732     pMiddleTextItem->setZValue(1000);
733
734
735     pVictoryScoreItem_ = new QGraphicsTextItem(pVictoryCongratulationsItem_);
736     pVictoryScoreItem_->setPos(-50,180);
737     pMiddleTextItem->setZValue(1000);
738     //Text is set at usetime!
739
740     QGraphicsTextItem * pLowestTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
741     pLowestTextItem->setHtml("<font size=\"7\" color = darkorange> Tap to play again");
742     pLowestTextItem->setPos(-50,360);
743     pLowestTextItem->setZValue(1000);
744 }
745
746
747 void SeaScene::createAboutBoxItems()
748 {
749     pAboutBoxItem_ = new QGraphicsTextItem;
750     addItem(pAboutBoxItem_);
751     pAboutBoxItem_->setPos(25,50);
752     pAboutBoxItem_->setZValue(1000);
753     pAboutBoxItem_->hide();
754
755     pAboutBoxItem_->setHtml(tr("<font color = darkorange size = \"7\">"
756                           "%1 <br> <font size = \"7\"> Version %2"
757                           "<p><font size = \"6\"> Copyright 2011 Heli Hyv&auml;ttinen"
758                           "<p><font size = \"6\"> License: General Public License v2"
759                           "<p><font size = \"5\"> Web: http://ghostsoverboard.garage.maemo.org/<br>"
760                           "Bug Reports: <br> https://bugs.maemo.org/"
761                           "enter_bug.cgi?product=Ghosts%20Overboard"
762                           ).arg(QApplication::applicationName(),QApplication::applicationVersion()));
763
764 }
765
766 void SeaScene::setItemPointersNull()
767 {
768     pPausetextItem_ = NULL;
769     pRestartLevelItem_ = NULL;
770     pRestartGameItem_ = NULL;
771     pSettingsItem_ = NULL;
772     pAboutItem_ = NULL;
773     pQuitItem_ = NULL ;
774 //    pMinimizeItem_ = NULL; //Fremantle spesific
775
776     pAboutBoxItem_ = NULL;
777     pLevelCompletedItem_ = NULL;
778     pVictoryScoreItem_ = NULL;
779
780 }
781
782 void SeaScene::turnPauseOn()
783 {
784     pPauseAction_->setChecked(true);
785 }
786
787
788
789 void SeaScene::createLevelCompletedItems()
790 {
791     pLevelCompletedItem_ = new QGraphicsTextItem;
792     addItem(pLevelCompletedItem_);
793     pLevelCompletedItem_->setPos(240,100);
794     pLevelCompletedItem_->setZValue(1000);
795     pLevelCompletedItem_->hide();
796     //The text is set at usetime
797
798     QGraphicsTextItem * pTapForNextLevelItem = new QGraphicsTextItem(pLevelCompletedItem_);
799     pTapForNextLevelItem->setPos(-60,100);
800     pTapForNextLevelItem->setZValue(1000);
801     pTapForNextLevelItem->setHtml("<font size=\"5\" color = darkorange>Tap to start the next level");
802 }