From: Heli Hyvättinen Date: Mon, 12 Sep 2011 17:14:32 +0000 (+0300) Subject: Added total highscore for levelset X-Git-Tag: v0.4.0_Maemo~14 X-Git-Url: http://vcs.maemo.org/git/?p=ghostsoverboard;a=commitdiff_plain;h=796e789ccba53302a279164449b9897830f0976e Added total highscore for levelset Also now shows the level score after the last level too. Better position for the level score text for other levels. --- diff --git a/seascene.cpp b/seascene.cpp index cf14094..8a96f77 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -122,7 +122,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed) createVictoryItems(); - createLevelCompletedItem(); + createLevelCompletedItems(); //empty the list of moving items @@ -643,19 +643,20 @@ void SeaScene::nextLevel() levelScore_ += scoreCounter_.elapsed(); totalScore_ += levelScore_; int highscore = levelset_.getLevelHighScore(currentLevel_); + qDebug() << highscore; QString scoretext; if (levelScore_ >= highscore) { - scoretext = tr("Your time: %1.%2 s
Best time: %3.%4 s

Tap to start the next level").arg(levelScore_/1000).arg((levelScore_%1000)/100).arg(highscore/1000).arg((highscore%1000)/100); + scoretext = tr("Your time: %1.%2 s
Best time: %3.%4 s").arg(levelScore_/1000).arg((levelScore_%1000)/100).arg(highscore/1000).arg((highscore%1000)/100); } else //New high score! { - scoretext = tr("Your time %1.%2 s is the new best time!
br> Tap to start the next level").arg(levelScore_/1000).arg((levelScore_%1000)/100); + scoretext = tr("Your time %1.%2 s is
the new best time!").arg(levelScore_/1000).arg((levelScore_%1000)/100); levelset_.setLevelHighScore(currentLevel_,levelScore_); } @@ -670,6 +671,7 @@ void SeaScene::nextLevel() if ( currentLevel_ < levelset_.numberOfLevels() ) { + pLevelCompletedItem_->setHtml(scoretext); pLevelCompletedItem_->show(); // restartLevel(); @@ -677,6 +679,18 @@ void SeaScene::nextLevel() else //Victory! { + int totalHighsore = levelset_.getTotalHighScore(); + if (totalScore_ >= totalHighsore) + { + scoretext.append(tr("
Your total time: %1.%2 s
Best total time:%3.%4 s").arg(totalScore_/1000).arg((totalScore_%1000)/100).arg(totalHighsore/1000).arg((totalHighsore%1000)/100)); + } + else //new total high score + { + scoretext.append(tr("
Your total time %1.%2 s is
the new best time").arg(totalScore_/1000).arg((totalScore_%1000)/100)); + levelset_.setTotalHighScore(totalScore_); + } + + pVictoryScoreItem_->setHtml(scoretext); pVictoryCongratulationsItem_->show(); } } @@ -710,7 +724,7 @@ void SeaScene::createVictoryItems() pVictoryCongratulationsItem_ = new QGraphicsTextItem; pVictoryCongratulationsItem_->setHtml(" Victory!"); pVictoryCongratulationsItem_->hide(); - pVictoryCongratulationsItem_->setPos(355,50); + pVictoryCongratulationsItem_->setPos(315,30); pVictoryCongratulationsItem_->setZValue(1000); addItem(pVictoryCongratulationsItem_); @@ -719,17 +733,23 @@ void SeaScene::createVictoryItems() QGraphicsTextItem * pTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pTextItem->setHtml(" Congratulations!"); - pTextItem->setPos(-50,100); + pTextItem->setPos(-50,80); pTextItem->setZValue(1000); QGraphicsTextItem * pMiddleTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pMiddleTextItem->setHtml(" You have saved all the ghosts."); - pMiddleTextItem->setPos(-145,140); + pMiddleTextItem->setPos(-145,120); pMiddleTextItem->setZValue(1000); + + pVictoryScoreItem_ = new QGraphicsTextItem(pVictoryCongratulationsItem_); + pVictoryScoreItem_->setPos(-50,180); + pMiddleTextItem->setZValue(1000); + //Text is set at usetime! + QGraphicsTextItem * pLowestTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pLowestTextItem->setHtml(" Tap to play again"); - pLowestTextItem->setPos(-50,220); + pLowestTextItem->setPos(-50,360); pLowestTextItem->setZValue(1000); } @@ -765,6 +785,7 @@ void SeaScene::setItemPointersNull() pAboutBoxItem_ = NULL; pVictoryCongratulationsItem_ = NULL; pLevelCompletedItem_ = NULL; + pVictoryScoreItem_ = NULL; } @@ -803,13 +824,18 @@ void SeaScene::pollDeviceLocked() } } -void SeaScene::createLevelCompletedItem() +void SeaScene::createLevelCompletedItems() { pLevelCompletedItem_ = new QGraphicsTextItem; addItem(pLevelCompletedItem_); - pLevelCompletedItem_->setPos(20,20); + pLevelCompletedItem_->setPos(240,100); pLevelCompletedItem_->setZValue(1000); pLevelCompletedItem_->hide(); //The text is set at usetime + QGraphicsTextItem * pTapForNextLevelItem = new QGraphicsTextItem(pLevelCompletedItem_); + pTapForNextLevelItem->setPos(-60,100); + pTapForNextLevelItem->setZValue(1000); + pTapForNextLevelItem->setHtml("Tap to start the next level"); + } diff --git a/seascene.h b/seascene.h index faa5360..5d4d35f 100644 --- a/seascene.h +++ b/seascene.h @@ -110,7 +110,7 @@ protected: void prepareForMenu(QGraphicsItem * pItem); void createAboutBoxItems(); void createVictoryItems(); - void createLevelCompletedItem(); + void createLevelCompletedItems(); const QString ghostImageFilename_; const QString rockImageFilename_; @@ -139,6 +139,7 @@ protected: QGraphicsTextItem * pMinimizeItem_; QGraphicsTextItem * pVictoryCongratulationsItem_; + QGraphicsTextItem * pVictoryScoreItem_; QGraphicsTextItem * pAboutBoxItem_; QGraphicsTextItem * pLevelCompletedItem_;