1 /**************************************************************************
2 Ghosts Overboard - a game for 'Meego 1.2 Harmattan'
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 **************************************************************************/
26 #include <QGraphicsPixmapItem>
28 #include <QMessageBox>
30 #include <QApplication>
32 #include <QPushButton>
34 #include <QVBoxLayout>
39 const QString ghostImageFilename_ = ":/pix/aave.png";
40 const QString rockImageFilename_ =":/pix/kari.png";
41 const QString octopusImageFilename_= ":/pix/tursas.png";
44 SeaScene::SeaScene(QObject *parent) :
45 QGraphicsScene(parent)
48 setItemPointersNull();
51 screenLitKeeper_.keepScreenLit(true);
55 QPixmap waves (":/pix/meri.png");
57 setBackgroundBrush(QBrush(waves));
61 qsrand(QTime::currentTime().msec()+2); //+2 to avoid setting it to 1
65 //Setup the level list
67 QList<Level> levelList;
69 levelList.append(level1);
70 Level level2(5,10,2,50);
71 levelList.append(level2);
72 Level level3(5,15,2,50);
73 levelList.append(level3);
74 Level level4(5,15,4,50);
75 levelList.append(level4);
76 Level level5(5,15,5,100);
77 levelList.append(level5);
79 Levelset set ("Original",levelList);
81 availableLevelsets_.append(set);
87 //Create another set of levels and place it in the available levelsets list
89 Level set2level1(8,15,4,50);
90 levelList.append(set2level1);
91 Level set2level2(8,20,4,50);
92 levelList.append(set2level2);
93 Level set2level3(8,20,5,80);
94 levelList.append(set2level3);
95 Level set2level4(8,20,6,120);
96 levelList.append(set2level4);
97 Level set2level5(8,25,8,150);
98 levelList.append(set2level5);
100 Levelset set2("Difficult",levelList);
101 availableLevelsets_.append(set2);
104 //This ensures that nextlevel will not be called until its safe to delete the Ship object.
105 //Leaving out Qt::QueuedConnection or calling nextlevel directly instead of emitting the signal will CRASH
106 connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
111 pVibrateAction_ = new QAction(tr("Vibration effects"),this);
112 pVibrateAction_->setCheckable(true);
113 connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));
115 pVibrateAction_->setChecked(settings.value("vibration",false).toBool());
118 pPauseAction_ = new QAction(tr("Pause"),this);
119 pPauseAction_->setCheckable(true);
120 connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
123 autopauseTimer.setSingleShot(true);
124 autopauseTimer.setInterval(15*60*1000);
125 connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn()));
127 vibrationAllowed_ = false;
128 pResourceSet_ = new ResourcePolicy::ResourceSet("game",this);
129 ResourcePolicy::VibraResource * pVibraResource = new ResourcePolicy::VibraResource();
130 pVibraResource->setOptional(false); //The only resource of the set, so no sense for it to be optional
131 pResourceSet_->addResourceObject(pVibraResource);
133 connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),this,SLOT(resourcesAvailable()));
134 connect(pResourceSet_,SIGNAL(lostResources()),this,SLOT(resourcesLost()));
136 //To test whether resources were succesfully asked but not given
137 connect(pResourceSet_,SIGNAL(resourcesDenied()),this,SLOT(resourcesLost()));
138 pResourceSet_->setAlwaysReply();
140 pResourceSet_->acquire();
144 void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
150 setItemPointersNull();
154 createAboutBoxItems();
156 createSelectLevelsetFromListItems();
158 createVictoryItems();
160 createLevelCompletedItems();
163 //empty the list of moving items
165 movingItems_.clear();
167 //empty the list of free slots
170 //fill the list of free slots
172 int numberOfXTiles = width() / 40;
173 int numberOfYTiles = height() /40;
175 // qDebug() << numberOfXTiles << " slots in x direction";
176 // qDebug() << numberOfYTiles << " slots in y rirection";
178 for (int i = 0; i < numberOfXTiles; i++ )
180 for (int j = 0; j < numberOfYTiles; j++)
182 freeTiles_.append(QPointF(i*40,j*40));
189 for (int i = 0; i < rocks; i++)
191 QPointF * pPosition = findRandomFreeSlot();
193 //If there was no room no point to continue
194 if (pPosition == NULL)
197 QPixmap rockPixmap (":/pix/kari.png");
198 QGraphicsPixmapItem * pRock = addPixmap(rockPixmap);
199 pRock->setData(0,"rock");
200 pRock->setPos(*pPosition);
207 ghostsLeft_ = ghosts;
208 spreadGhosts(ghosts);
212 //spread the octopuses
214 QList <Octopus*> octopusList;
216 for (int i=0; i < octopuses; i++)
218 QPointF * pPosition = findRandomFreeSlot();
220 //If there was no room no point to continue
221 if (pPosition == NULL)
224 QPixmap octopusPixmap (":/pix/tursas.png");
225 Octopus * pOctopus = new Octopus(octopusPixmap,octopusSpeed);
226 pOctopus->setData(0,"octopus");
227 pOctopus->setPos(*pPosition);
229 pOctopus->startMoving();
230 movingItems_.append(pOctopus);
231 connect(this,SIGNAL(pauseOn()),pOctopus,SLOT(stopMoving()));
232 connect(this,SIGNAL(pauseOff()),pOctopus,SLOT(startMoving()));
233 octopusList.append(pOctopus);
241 QPointF * pPosition = findRandomFreeSlot();
242 if (pPosition == NULL)
244 // Game cannot begin without a free position for ship, so give an error message and return
246 QMessageBox::critical(NULL,"Error! Too many objects on screen","No free space to place the ship. The game cannot start. Please choose another level.");
250 QList<QPixmap> shipImages;
251 shipImages.append(QPixmap(":/pix/laiva.png"));
252 shipImages.append(QPixmap(":/pix/laiva_1aave.png"));
253 shipImages.append(QPixmap(":/pix/laiva_2aave.png"));
254 shipImages.append(QPixmap(":/pix/laiva_3aave.png"));
255 shipImages.append(QPixmap(":/pix/laiva_4aave.png"));
256 shipImages.append(QPixmap(":/pix/laiva_5aave.png"));
257 shipImages.append(QPixmap(":/pix/laiva_6aave.png"));
258 shipImages.append(QPixmap(":/pix/laiva_7aave.png"));
259 shipImages.append(QPixmap(":/pix/laiva_8aave.png"));
260 shipImages.append(QPixmap(":/pix/laiva_9aave.png"));
261 shipImages.append(QPixmap(":/pix/laiva_10aave.png"));
263 Ship * pShip = new Ship (shipImages);
264 pShip->setData(0,"ship");
265 pShip->setPos(*pPosition);
267 connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
268 connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
269 connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
270 if (vibrationAllowed_)
271 pShip->allowVibration(); //Vibration is disallowed by default so only allowing needs to be done explicitly
272 connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),pShip,SLOT(allowVibration()));
273 connect(pResourceSet_,SIGNAL(lostResources()),pShip,SLOT(disallowVibration()));
274 pShip->startMoving();
275 movingItems_.append(pShip);
276 connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
277 connect(this,SIGNAL(pauseOff()),pShip,SLOT(startMoving()));
278 foreach (Octopus* pOctopus, octopusList)
280 connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
285 void SeaScene::setupMap(Level level)
287 setupMap(level.getNumberOfGhosts(),level.getNumberOfRocks(),level.getNumberOfOctopuses(),level.getOctopusSpeed());
290 void SeaScene::spreadGhosts(int ghosts)
294 //the octopuses and the ship may have moved from their original positions,
295 //so the list of free slots must be adjusted to exclude their current positions
297 QList<QPointF> temporarilyReservedSlots;
299 foreach (QGraphicsItem* pItem, movingItems_)
303 // qDebug() << "NULL item in movingItems_";
307 //round x and y down to fit the slot size
317 QPointF position (x,y);
319 //remove the tiles (potentially) occupied by the item from free slots and place in temp list if was in the list before
321 if (freeTiles_.removeOne(position))
322 temporarilyReservedSlots.append(position);
327 if (freeTiles_.removeOne(position))
328 temporarilyReservedSlots.append(position);
332 if (freeTiles_.removeOne(position))
333 temporarilyReservedSlots.append(position);
337 if (freeTiles_.removeOne(position))
338 temporarilyReservedSlots.append(position);
343 //spread ghosts in random free slots
345 for (int i=0; i < ghosts; i++)
347 QPointF * pPosition = findRandomFreeSlot();
349 //If there was no room no point to continue
350 if (pPosition == NULL)
353 QPixmap ghostPixmap(":/pix/aave.png");
354 QGraphicsPixmapItem * pGhost = addPixmap(ghostPixmap);
355 pGhost->setData(0,"ghost");
356 pGhost->setPos(*pPosition);
360 //return the slots occupied by moving items to free slots
361 freeTiles_.append(temporarilyReservedSlots);
363 //clear temp for the next round
364 temporarilyReservedSlots.clear();
367 QPointF* SeaScene::findRandomFreeSlot()
369 if (freeTiles_.isEmpty())
372 int index = qrand()%freeTiles_.size();
374 // qDebug() << index << " index";
375 return new QPointF (freeTiles_.takeAt(index));
379 void SeaScene::removeGhost(QGraphicsItem *pGhost)
381 removeItem(pGhost); //remove the item from scene
382 freeTiles_.append(pGhost->scenePos()); //add the item's position to free slots
385 if (ghostsLeft_ == 0)
387 emit allGhostsPicked();
388 // qDebug() << "All ghosts picked!";
392 void SeaScene::ghostsDropped(int ghosts)
394 ghostsLeft_ += ghosts;
396 spreadGhosts(ghosts);
399 void SeaScene::pause(bool paused)
401 // qDebug() << "pause pressed " << paused;
402 if (paused_ == paused)
409 // qDebug() << "starting to move again";
410 // emit fullscreenRequested(); fremantle specific (since no "show statusbar" action in harmattan version)
412 screenLitKeeper_.keepScreenLit(true);
414 pPausetextItem_->hide();
416 scoreCounter_.start();
418 autopauseTimer.start(); //Start counting towards autopause
423 // qDebug("about to stop movement");
425 screenLitKeeper_.keepScreenLit(false);
426 if (pPausetextItem_ != NULL)
428 // qDebug() << "about to show the pause text";
429 pPausetextItem_->show();
430 // qDebug() << "showing pause text";
432 // else qDebug() << "No pause text available";
434 levelScore_ += scoreCounter_.elapsed();
436 autopauseTimer.stop(); //No need to count toward autopause when already paused
440 void SeaScene::vibrationActivate(bool on)
442 emit vibrationActivated(on);
445 void SeaScene::handleScreenTapped()
448 //If the game is going just pause it
451 pPauseAction_->setChecked(true);
455 //If the game is paused and about box is shown, close it and show the pause text and menu again
459 if(pAboutBoxItem_->isVisible())
461 pAboutBoxItem_->hide();
462 pPausetextItem_->show();
467 //If the game is paused, check if the level completed item is shown
469 if (pLevelCompletedItem_)
471 if (pLevelCompletedItem_->isVisible())
473 pLevelCompletedItem_->hide();
474 restartLevel(); //Current level has already been set to the next one before showing the level completed item
475 pPauseAction_->setChecked(false); //unpause
480 //If the game is paused, check if the victory item is being shown
481 if(pVictoryCongratulationsItem_)
483 if (pVictoryCongratulationsItem_->isVisibleTo(NULL)) //returns visibility to scene
485 pVictoryCongratulationsItem_->hide();
487 pPauseAction_->setChecked(false); // unpause
493 //If the game is paused and no victory or about box, check if menu item was selected
495 QList<QGraphicsItem *> items = selectedItems();
497 //if nothing selected resume play
501 pSelectLevelsetFromListItem_->hide();
502 pPauseAction_->setChecked(false);
508 //If something was selected check if it was one of the menu items and act on it
509 //(Nothing else should be made selectable anyway)
513 QGraphicsItem* pItem = items.at(0); //Selecting an item brings here, thus only selecting one item should be possible
514 //... so we can just take the first one
516 //Selection is just used to get notice of a menu item being clicked, removed after use
521 //Act upon the selected item
524 if (pItem == pRestartGameItem_)
526 // qDebug() << "game restart requested";
528 pPauseAction_->setChecked(false); //unpause game
532 else if (pItem == pRestartLevelItem_)
534 // qDebug() << "Level restart requested";
536 pPauseAction_->setChecked(false); //unpause game
540 else if (pItem == pSettingsItem_)
542 pVibrateAction_->toggle();
545 settings.setValue("vibration",pVibrateAction_->isChecked());
547 QString text = pSettingsItem_->toHtml();
548 if (pVibrateAction_->isChecked())
549 text.replace(" on"," off"); //don't remove spaces or you get vibratioff...
551 text.replace(" off"," on");
552 pSettingsItem_->setHtml(text);
555 else if (pItem == pAboutItem_)
560 else if (pItem == pQuitItem_)
565 else if (pItem == pChooseLevelsetItem_)
567 pPausetextItem_->hide();
568 pSelectLevelsetFromListItem_->show();
573 foreach (QGraphicsItem* pLevelItem, levelsetItems_)
575 if (pItem == pLevelItem)
577 QVariant variant = pLevelItem->data(0);
579 if (variant.canConvert<Levelset>())
581 levelset_ = variant.value<Levelset>();
583 pPauseAction_->setChecked(false); //unpause game
593 void SeaScene::createMenuItems()
597 font.setPixelSize(35);
601 pPausetextItem_ = new QGraphicsTextItem;
603 // This is for fremantle
604 // pPausetextItem_->setHtml("<font size = \"5\" color = darkorange> Game paused. Tap to continue.");
606 //Harmattan needs bigger font
607 pPausetextItem_->setHtml("<font size = \"7\" color = darkorange> Game paused. Tap to continue.");
610 pPausetextItem_->setZValue(1000);
611 pPausetextItem_->setPos(200,50);
612 addItem(pPausetextItem_);
613 pPausetextItem_->hide();
617 // This is for fremantle
618 // QString menufonthtml = "<font size = \"4\" color = darkorange>";
621 //Harmattan needs bigger font
622 QString menufonthtml = "<font size = \"6\" color = darkorange>";
625 pRestartGameItem_ = new QGraphicsTextItem;
626 pRestartGameItem_->setHtml(tr("Restart <br> game").prepend(menufonthtml));
627 prepareForMenu(pRestartGameItem_);
629 pRestartLevelItem_ = new QGraphicsTextItem;
630 pRestartLevelItem_->setHtml(tr("Restart <br> level").prepend(menufonthtml));
631 prepareForMenu(pRestartLevelItem_);
633 pChooseLevelsetItem_ = new QGraphicsTextItem;
634 pChooseLevelsetItem_->setHtml(tr("Choose <br> levelset").prepend(menufonthtml));
635 prepareForMenu(pChooseLevelsetItem_);
637 pSettingsItem_ = new QGraphicsTextItem;
638 QString vibraText(tr("Turn vibration <br> effects "));
640 if (pVibrateAction_->isChecked())
648 vibraText.append(statusText);
649 pSettingsItem_->setHtml(vibraText.prepend(menufonthtml));
650 prepareForMenu(pSettingsItem_);
652 pAboutItem_ = new QGraphicsTextItem;
653 pAboutItem_->setHtml(tr("About <br> game").prepend(menufonthtml));
654 prepareForMenu(pAboutItem_);
656 pQuitItem_ = new QGraphicsTextItem;
657 pQuitItem_->setHtml(tr("Quit <br> game").prepend(menufonthtml));
658 prepareForMenu(pQuitItem_);
662 void SeaScene::prepareForMenu(QGraphicsItem * pItem)
665 //Menu items have pause text item as their parent and are thus added to scene automatically
666 //They are also shown and hidden with it, resulting in the menu being visble when the game is paused
667 //Their coordinates are given relative to the parent.
671 pItem->setParentItem(pPausetextItem_);
672 pItem->setZValue(1000);
673 pItem->setFlag(QGraphicsItem::ItemIsSelectable);
675 if (menuItemCount_< itemsPerRow)
679 else pItem->setY(240);
682 pItem->setX((menuItemCount_++%itemsPerRow)*180-10);
686 void SeaScene::about()
688 pPausetextItem_->hide();
689 pAboutBoxItem_->show();
693 void SeaScene::restartLevel()
698 setupMap(levelset_.getLevel(currentLevel_)); //getLevel() returns default constructor Level if index is invalid, so no risk of crash
700 scoreCounter_.start();
702 vibrationActivate(pVibrateAction_->isChecked()); //Vibration effects are lost without this
703 // qDebug() << pVibrateAction_->isChecked();
705 autopauseTimer.start(); //reset counting towards autopause
712 void SeaScene::nextLevel()
715 //get score for previous level
716 levelScore_ += scoreCounter_.elapsed();
717 totalScore_ += levelScore_;
718 int highscore = levelset_.getLevelHighScore(currentLevel_);
720 qDebug() << highscore;
724 if (levelScore_ >= highscore)
726 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);
729 else //New high score!
732 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);
733 levelset_.setLevelHighScore(currentLevel_,levelScore_);
736 //pause to show the highscore or victory screen
739 pPausetextItem_->hide();
742 //Go to the next level if available
745 if ( currentLevel_ < levelset_.numberOfLevels() )
748 pLevelCompletedItem_->setHtml(scoretext);
749 pLevelCompletedItem_->show();
755 int totalHighsore = levelset_.getTotalHighScore();
756 if (totalScore_ >= totalHighsore)
758 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));
760 else //new total high score
762 scoretext.append(tr("<br>Your total time %1.%2 s is<br>the new best time").arg(totalScore_/1000).arg((totalScore_%1000)/100));
763 levelset_.setTotalHighScore(totalScore_);
766 pVictoryScoreItem_->setHtml(scoretext);
767 pVictoryCongratulationsItem_->show();
772 void SeaScene::restartGame()
780 void SeaScene::forcePause()
782 //Pause without setting the pause action state
786 void SeaScene::softContinue()
788 //Continue if not being paused by the user
789 // Reverts forcePause()
791 pause(pPauseAction_->isChecked());
795 void SeaScene::createVictoryItems()
797 pVictoryCongratulationsItem_ = new QGraphicsTextItem;
798 pVictoryCongratulationsItem_->setHtml("<font size=\"7\" color = darkorange> <b> Victory!");
799 pVictoryCongratulationsItem_->hide();
800 pVictoryCongratulationsItem_->setPos(315,30);
801 pVictoryCongratulationsItem_->setZValue(1000);
802 addItem(pVictoryCongratulationsItem_);
805 //coordinates are relative to the parent
807 QGraphicsTextItem * pTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
808 pTextItem->setHtml("<font size=\"7\" color = darkorange> Congratulations!");
809 pTextItem->setPos(-50,80);
810 pTextItem->setZValue(1000);
812 QGraphicsTextItem * pMiddleTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
813 pMiddleTextItem->setHtml("<font size=\"7\" color = darkorange> You have saved all the ghosts.");
814 pMiddleTextItem->setPos(-145,120);
815 pMiddleTextItem->setZValue(1000);
818 pVictoryScoreItem_ = new QGraphicsTextItem(pVictoryCongratulationsItem_);
819 pVictoryScoreItem_->setPos(-50,180);
820 pMiddleTextItem->setZValue(1000);
821 //Text is set at usetime!
823 QGraphicsTextItem * pLowestTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_);
824 pLowestTextItem->setHtml("<font size=\"7\" color = darkorange> Tap to play again");
825 pLowestTextItem->setPos(-50,360);
826 pLowestTextItem->setZValue(1000);
830 void SeaScene::createAboutBoxItems()
832 pAboutBoxItem_ = new QGraphicsTextItem;
833 addItem(pAboutBoxItem_);
834 pAboutBoxItem_->setPos(25,50);
835 pAboutBoxItem_->setZValue(1000);
836 pAboutBoxItem_->hide();
838 pAboutBoxItem_->setHtml(tr("<font color = darkorange size = \"7\"><b>"
840 "<p><font size = \"6\"> Copyright 2011 Heli Hyvättinen"
841 "<p><font size = \"6\"> License: GNU General Public License v2"
842 "<p><font size = \"6\"> The source code of this game is available trough it's web pages."
843 "<p><font size = \"6\"> Web: http://ghostsoverboard.garage.maemo.org/<br>"
844 "Bug Reports: <br> https://bugs.maemo.org/"
845 "enter_bug.cgi?product=Ghosts%20Overboard"
846 ).arg(QApplication::applicationName(),QApplication::applicationVersion()));
850 void SeaScene::setItemPointersNull()
852 pPausetextItem_ = NULL;
853 pRestartLevelItem_ = NULL;
854 pRestartGameItem_ = NULL;
855 pSettingsItem_ = NULL;
858 // pMinimizeItem_ = NULL; //Fremantle spesific
859 pChooseLevelsetItem_ = NULL;
861 pAboutBoxItem_ = NULL;
862 pLevelCompletedItem_ = NULL;
863 pVictoryCongratulationsItem_ = NULL;
864 pVictoryScoreItem_ = NULL;
868 void SeaScene::turnPauseOn()
870 pPauseAction_->setChecked(true);
875 void SeaScene::createLevelCompletedItems()
877 pLevelCompletedItem_ = new QGraphicsTextItem;
878 addItem(pLevelCompletedItem_);
879 pLevelCompletedItem_->setPos(240,100);
880 pLevelCompletedItem_->setZValue(1000);
881 pLevelCompletedItem_->hide();
882 //The text is set at usetime
884 QGraphicsTextItem * pTapForNextLevelItem = new QGraphicsTextItem(pLevelCompletedItem_);
885 pTapForNextLevelItem->setPos(-60,100);
886 pTapForNextLevelItem->setZValue(1000);
887 pTapForNextLevelItem->setHtml("<font size=\"7\" color = darkorange>Tap to start the next level");
890 void SeaScene::createSelectLevelsetFromListItems()
893 if (availableLevelsets_.isEmpty()) //Something is badly wrong in code if this is true...
897 pSelectLevelsetFromListItem_ = new QGraphicsTextItem;
898 addItem(pSelectLevelsetFromListItem_);
899 pSelectLevelsetFromListItem_->setPos(295,60);
900 pSelectLevelsetFromListItem_->setZValue(1000);
901 pSelectLevelsetFromListItem_->hide();
904 QString fontstring ("<font color = darkorange size = \"7\">");
906 pSelectLevelsetFromListItem_->setHtml(tr("Choose a levelset").prepend(fontstring));
910 levelsetItems_.clear();
913 foreach (Levelset set, availableLevelsets_)
915 QGraphicsTextItem * pItem = new QGraphicsTextItem(pSelectLevelsetFromListItem_);
916 QString text (fontstring);
917 if (levelset_.getName() == set.getName())
919 text.append(set.getName());
920 pItem->setHtml(text);
921 pItem->setPos(65,yPos);
923 pItem->setZValue(1000);
924 pItem->setFlag(QGraphicsItem::ItemIsSelectable);
925 pItem->setData(0,QVariant::fromValue(set));
926 levelsetItems_.append(pItem);
933 void SeaScene::resourcesAvailable()
935 qDebug() << "Resources available";
936 vibrationAllowed_ = true;
940 void SeaScene::resourcesLost()
942 qDebug() << "Resources lost";
943 vibrationAllowed_ = false;