All menu items in place. Still do nothing.
[ghostsoverboard] / seascene.cpp
index 866fae1..28ad362 100644 (file)
@@ -55,6 +55,12 @@ SeaScene::SeaScene(QObject *parent) :
 
 
 
+
+
+
+
+
+
 }
 
 void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
@@ -63,6 +69,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
 
     clear();
 
+    createMenuItems();
+
     //empty the list of moving items
 
     movingItems_.clear();
@@ -308,13 +316,22 @@ void SeaScene::pause(bool paused)
      //       qDebug() << "starting to move again";
             emit pauseOff();
             screenLitKeeper_.keepScreenLit(true);
+            if (pPausetextItem_)
+                pPausetextItem_->hide();
         }
 
         else
         {
-     //       qDebug("about to stop movement");
+         qDebug("about to stop movement");
             emit pauseOn();
             screenLitKeeper_.keepScreenLit(false);
+            if (pPausetextItem_ != NULL)
+            {
+                qDebug() << "about to show the pause text";
+                pPausetextItem_->show();
+                qDebug() << "showing pause text";
+            }
+                else qDebug() << "No pause text available";
         }
 }
 
@@ -332,26 +349,32 @@ void SeaScene::menuClicked()
     if (items.isEmpty())
         return;
 
+    //Tapping the screen unpaused the game, pause it again!
+
+
+
     //Menu functions
 
-    QString menuitem = items.at(0)->data(0).toString();
+    QGraphicsItem* pItem = items.at(0);
 
-    if (menuitem == "restart game")
-    {
 
+    if (pItem == pRestartGameItem_)
+    {
+        qDebug() << "game restart requested";
     }
 
-    else if (menuitem == "restart level")
+    else if (pItem == pRestartLevelItem_)
     {
+        qDebug() << "Level restart requested";
 
     }
 
-    else if (menuitem == "vibration effects")
+    else if (pItem == pSettingsItem_)
     {
 
     }
 
-    else if (menuitem == "about")
+    else if (pItem == pAboutItem_)
     {
 
     }
@@ -363,12 +386,43 @@ void SeaScene::menuClicked()
 
 }
 
-void SeaScene::showMenu()
+
+
+void SeaScene::createMenuItems()
 {
-    menuItems_.show();
+
+    pPausetextItem_ =  addSimpleText("Game paused. Tap to continue.");
+    pPausetextItem_->setZValue(1000);
+    pPausetextItem_->setPos(250,50);
+    pPausetextItem_->hide();
+
+    menuItemCount_ = 0;
+
+    pRestartGameItem_ = new QGraphicsSimpleTextItem("Restart game");
+    prepareForMenu(pRestartGameItem_);
+
+    pRestartLevelItem_ = new QGraphicsSimpleTextItem("Restart level");
+    prepareForMenu(pRestartLevelItem_);
+
+    pSettingsItem_ = new QGraphicsSimpleTextItem("Settings");
+    prepareForMenu(pSettingsItem_);
+
+    pAboutItem_ = new QGraphicsSimpleTextItem("About");
+    prepareForMenu(pAboutItem_);
+
 }
 
-void::SeaScene::hideMenu()
+void SeaScene::prepareForMenu(QGraphicsItem * pItem)
 {
-    menuItems_.hide();
-}
+
+    //Menu items have pause text item as their parent and are thus added to scene automatically
+    //They are also shown and hidden with it, resulting in the menu being visble when the game is paused
+    //Their coordinates are given relative to the parent.
+
+    pItem->setParentItem(pPausetextItem_);
+    pItem->setZValue(1000);
+    pItem->setFlag(QGraphicsItem::ItemIsSelectable);
+    pItem->setY(150);
+    pItem->setX(menuItemCount_++*150-250);
+ }
+