Attempt to animate ship movement
[ghostsoverboard] / seascene.cpp
index 175d4fc..6dfa748 100644 (file)
@@ -42,6 +42,9 @@ const QString octopusImageFilename_= ":/pix/tursas.png";
 SeaScene::SeaScene(QObject *parent) :
     QGraphicsScene(parent)
 {
+
+    setItemPointersNull();
+
     paused_ = false;
     screenLitKeeper_.keepScreenLit(true);
 
@@ -100,8 +103,12 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
 
     clear();
 
+    setItemPointersNull();
+
     createMenuItems();
 
+    createAboutBoxItems();
+
     //empty the list of moving items
 
     movingItems_.clear();
@@ -387,7 +394,18 @@ void SeaScene::handleScreenTapped()
         return;
     }
 
-    //If the game is paused, chacl if menu item was selected
+    //If the game is paused and about box is shown, close it and show the pause text and menu again
+
+    if(pAboutBoxItem_)
+    {
+        if(pAboutBoxItem_->isVisible())
+        {
+            pAboutBoxItem_->hide();
+            pPausetextItem_->show();
+        }
+    }
+
+    //If the game is paused, check if menu item was selected
 
     QList<QGraphicsItem *> items = selectedItems();
 
@@ -408,17 +426,27 @@ void SeaScene::handleScreenTapped()
     QGraphicsItem* pItem = items.at(0); //Selecting an item brings here, thus only selecting one item should be possible
                                        //... so we can just take the first one
 
+    //Selection is just used to get notice of a menu item being clicked, removed after use
+
+    clearSelection();
+
+
+    //Act upon the selected item
+
 
     if (pItem == pRestartGameItem_)
     {
         qDebug() << "game restart requested";
         restartGame();
+        pPauseAction_->setChecked(false); //unpause game
+
     }
 
     else if (pItem == pRestartLevelItem_)
     {
         qDebug() << "Level restart requested";
         restartLevel();
+        pPauseAction_->setChecked(false); //unpause game
 
     }
 
@@ -447,17 +475,6 @@ void SeaScene::handleScreenTapped()
         qApp->quit();
     }
 
-
-    //Selection is just used to get notice of a menu item being clicked, removed after use
-
-    clearSelection();
-
-    //The user propably went to paused state just to access menu, so unpause unless vibration set (so the user sees its changed)
-
-    if (pItem != pSettingsItem_)
-    {
-        pPauseAction_->setChecked(false);
-    }
 }
 
 
@@ -545,16 +562,8 @@ void SeaScene::prepareForMenu(QGraphicsItem * pItem)
 
 void SeaScene::about()
 {
-    QMessageBox::about(NULL, tr("About %1").arg(QApplication::applicationName()),
-                       tr("Version %1"
-                          "<p>Copyright 2011 Heli Hyv&auml;ttinen"
-                          "<p>License: General Public License v2"
-                          "<p>Bug Reports: https://bugs.maemo.org/ "
-                          "enter_bug.cgi?product=Ghosts%20Overboard"
-                          ).arg(QApplication::applicationVersion()));
-
-
-
+    pPausetextItem_->hide();
+    pAboutBoxItem_->show();
 }
 
 
@@ -650,3 +659,34 @@ void::SeaScene::softContinue()
 
     pause(pPauseAction_->isChecked());
 }
+
+void SeaScene::createAboutBoxItems()
+{
+    pAboutBoxItem_ = new QGraphicsTextItem;
+    addItem(pAboutBoxItem_);
+    pAboutBoxItem_->setPos(25,50);
+    pAboutBoxItem_->setZValue(1000);
+    pAboutBoxItem_->hide();
+
+    pAboutBoxItem_->setHtml(tr("<font color = darkorange size = \"7\">"
+                          "%1 <br> <font size = \"7\"> Version %2"
+                          "<p><font size = \"6\"> Copyright 2011 Heli Hyv&auml;ttinen"
+                          "<p><font size = \"6\"> License: General Public License v2"
+                          "<p><font size = \"5\"> Bug Reports: <br> https://bugs.maemo.org/ "
+                          "enter_bug.cgi?product=Ghosts%20Overboard"
+                          ).arg(QApplication::applicationName(),QApplication::applicationVersion()));
+
+}
+
+void SeaScene::setItemPointersNull()
+{
+    pPausetextItem_ = NULL;
+    pRestartLevelItem_ = NULL;
+    pRestartGameItem_ = NULL;
+    pSettingsItem_ = NULL;
+    pAboutItem_ = NULL;
+    pQuitItem_ = NULL ;
+//    pMinimizeItem_ = NULL; //Fremantle spesific
+
+    pAboutBoxItem_ = NULL;
+}