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