Pause/unpause by tapping the screen now works
[ghostsoverboard] / seascene.cpp
index 2adbb8c..866fae1 100644 (file)
@@ -49,6 +49,10 @@ SeaScene::SeaScene(QObject *parent) :
 
     qsrand(QTime::currentTime().msec()+2);  //+2 to avoid setting it to 1
 
+    //connect selecting to menu handling (only menu items selectable)
+
+    connect(this,SIGNAL(selectionChanged()),this,SLOT(menuClicked()));
+
 
 
 }
@@ -165,6 +169,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
     addItem(pShip);
     connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
     connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
+    connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
     pShip->startMoving();
     movingItems_.append(pShip);
     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
@@ -312,3 +317,58 @@ void SeaScene::pause(bool paused)
             screenLitKeeper_.keepScreenLit(false);
         }
 }
+
+void SeaScene::vibrationActivate(bool on)
+{
+    emit vibrationActivated(on);
+}
+
+void SeaScene::menuClicked()
+{
+    QList<QGraphicsItem *> items = selectedItems();
+
+    //if nothing selected (selection was removed) do nothing
+
+    if (items.isEmpty())
+        return;
+
+    //Menu functions
+
+    QString menuitem = items.at(0)->data(0).toString();
+
+    if (menuitem == "restart game")
+    {
+
+    }
+
+    else if (menuitem == "restart level")
+    {
+
+    }
+
+    else if (menuitem == "vibration effects")
+    {
+
+    }
+
+    else if (menuitem == "about")
+    {
+
+    }
+
+
+    //Selection is just used to get notice of being clicked, removed after use
+
+    clearSelection();
+
+}
+
+void SeaScene::showMenu()
+{
+    menuItems_.show();
+}
+
+void::SeaScene::hideMenu()
+{
+    menuItems_.hide();
+}