#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
+#include <QSettings>
const QString ghostImageFilename_ = ":/pix/aave.png";
const QString rockImageFilename_ =":/pix/kari.png";
pVibrateAction_ = new QAction(tr("Vibration effects"),this);
pVibrateAction_->setCheckable(true);
connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool)));
+ QSettings settings;
+ pVibrateAction_->setChecked(settings.value("vibration",false).toBool());
pPauseAction_ = new QAction(tr("Pause"),this);
else if (pItem == pSettingsItem_)
{
- //Temporary code for settings, likely to be turned into a QML dialog
-
- QMessageBox::StandardButton buttonpressed = QMessageBox::question(NULL,"Settings","Do you wish to have vibration effects enabled?", QMessageBox::Yes | QMessageBox::No);
-
- if (buttonpressed == QMessageBox::Yes)
- pVibrateAction_->setChecked(true);
- if (buttonpressed == QMessageBox::No)
- pVibrateAction_->setChecked(false);
+ pVibrateAction_->toggle();
+ QSettings settings;
+ {
+ settings.setValue("vibration",true);
+ }
+ {
+ settings.setValue("vibration",false);
+ }
}
else if (pItem == pAboutItem_)
about();
}
+ else if (pItem == pQuitItem_)
+ {
+ 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
+
+ pPauseAction_->setChecked(false);
+
}
void SeaScene::createMenuItems()
{
- pPausetextItem_ = addSimpleText("Game paused. Tap to continue.");
+ QFont font;
+ font.setPixelSize(35);
+
+
+
+ pPausetextItem_ = new QGraphicsTextItem;
+ pPausetextItem_->setHtml("<font size = \"5\" color = darkorange> Game paused. Tap to continue.");
pPausetextItem_->setZValue(1000);
- pPausetextItem_->setPos(250,50);
+ pPausetextItem_->setPos(200,50);
+ addItem(pPausetextItem_);
pPausetextItem_->hide();
menuItemCount_ = 0;
- pRestartGameItem_ = new QGraphicsSimpleTextItem("Restart game");
+ QString menufonthtml = "<font size = \"4\" color = darkorange>";
+
+ pRestartGameItem_ = new QGraphicsTextItem;
+ pRestartGameItem_->setHtml(tr("Restart <br> game").prepend(menufonthtml));
prepareForMenu(pRestartGameItem_);
- pRestartLevelItem_ = new QGraphicsSimpleTextItem("Restart level");
+ pRestartLevelItem_ = new QGraphicsTextItem;
+ pRestartLevelItem_->setHtml(tr("Restart <br> level").prepend(menufonthtml));
prepareForMenu(pRestartLevelItem_);
- pSettingsItem_ = new QGraphicsSimpleTextItem("Settings");
+ pSettingsItem_ = new QGraphicsTextItem;
+ QString vibraText(tr("Vibration <br> effects"));
+ QString statusText;
+ if (pVibrateAction_->isChecked())
+ {
+ statusText = "off";
+ }
+ else
+ {
+ statusText = "on";
+ }
+ vibraText.append(statusText);
+ pSettingsItem_->setHtml(vibraText.prepend(menufonthtml));
prepareForMenu(pSettingsItem_);
- pAboutItem_ = new QGraphicsSimpleTextItem("About");
+ pAboutItem_ = new QGraphicsTextItem;
+ pAboutItem_->setHtml(tr("About <br> game").prepend(menufonthtml));
prepareForMenu(pAboutItem_);
+ pQuitItem_ = new QGraphicsTextItem;
+ pQuitItem_->setHtml(tr("Quit <br> game").prepend(menufonthtml));
+ prepareForMenu(pQuitItem_);
+
}
void SeaScene::prepareForMenu(QGraphicsItem * pItem)
//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);
+ pItem->setX(menuItemCount_++*160-150);
}