All menu items in place. Still do nothing.
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 16 Jul 2011 21:00:02 +0000 (00:00 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sat, 16 Jul 2011 21:00:02 +0000 (00:00 +0300)
Substituted vibrate with settings, as togglable hard to implement and
other settings will come later. Must make it to open a dialog where
vibrate can be changed and the settings are saved.

seascene.cpp
seascene.h

index 81e4ace..28ad362 100644 (file)
@@ -369,7 +369,7 @@ void SeaScene::menuClicked()
 
     }
 
-    else if (pItem == pVibrateItem_)
+    else if (pItem == pSettingsItem_)
     {
 
     }
@@ -386,44 +386,43 @@ void SeaScene::menuClicked()
 
 }
 
-void SeaScene::showMenu()
-{
-    menuItems_.show();
-}
 
-void::SeaScene::hideMenu()
-{
-    menuItems_.hide();
-}
 
 void SeaScene::createMenuItems()
 {
 
     pPausetextItem_ =  addSimpleText("Game paused. Tap to continue.");
     pPausetextItem_->setZValue(1000);
+    pPausetextItem_->setPos(250,50);
+    pPausetextItem_->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
+    menuItemCount_ = 0;
 
-    pRestartGameItem_ = new QGraphicsSimpleTextItem("Restart game",pPausetextItem_);
-    pRestartGameItem_->setPos(0,200);
-    pRestartGameItem_->setZValue(1000);
-    pRestartGameItem_->setFlag(QGraphicsItem::ItemIsSelectable);
+    pRestartGameItem_ = new QGraphicsSimpleTextItem("Restart game");
+    prepareForMenu(pRestartGameItem_);
 
-    pRestartLevelItem_ = new QGraphicsSimpleTextItem("Restart level",pPausetextItem_);
-    pRestartLevelItem_->setPos(150,200);
-    pRestartLevelItem_->setZValue(1000);
-    pRestartLevelItem_->setFlag(QGraphicsItem::ItemIsSelectable);
+    pRestartLevelItem_ = new QGraphicsSimpleTextItem("Restart level");
+    prepareForMenu(pRestartLevelItem_);
 
-    QGraphicsRectItem * item = new QGraphicsRectItem(100,100,50,50,pPausetextItem_);
-    item->setFlag(QGraphicsItem::ItemIsSelectable);
-    QBrush brush;
-    brush.setStyle(Qt::SolidPattern);
-    item->setBrush(brush);
+    pSettingsItem_ = new QGraphicsSimpleTextItem("Settings");
+    prepareForMenu(pSettingsItem_);
 
+    pAboutItem_ = new QGraphicsSimpleTextItem("About");
+    prepareForMenu(pAboutItem_);
 
+}
 
+void SeaScene::prepareForMenu(QGraphicsItem * pItem)
+{
 
+    //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);
+ }
 
-}
index c9d9a54..7690d57 100644 (file)
@@ -66,9 +66,6 @@ public slots:
 
     void menuClicked();
 
-    void showMenu();
-
-    void hideMenu();
 
 protected:
 
@@ -79,6 +76,7 @@ protected:
     QPointF* findRandomFreeSlot();
 
     void createMenuItems();
+    void prepareForMenu(QGraphicsItem * pItem);
 
     const QString ghostImageFilename_;
     const QString rockImageFilename_;
@@ -96,13 +94,13 @@ protected:
     ScreenLitKeeper screenLitKeeper_;
 
 
-    QGraphicsItemGroup menuItems_;
+    int menuItemCount_;
 
     QGraphicsSimpleTextItem * pPausetextItem_;
 
     QGraphicsSimpleTextItem * pRestartLevelItem_;
     QGraphicsSimpleTextItem * pRestartGameItem_;
-    QGraphicsSimpleTextItem * pVibrateItem_;
+    QGraphicsSimpleTextItem * pSettingsItem_;
     QGraphicsSimpleTextItem * pAboutItem_;