#include <QMenuBar>
#include <QMessageBox>
#include <QApplication>
+#include <QLabel>
+#include <QPushButton>
+ #include <QVBoxLayout>
setWindowIcon(QIcon(":/pix/laiva_10aave.png"));
pScene_ = new SeaScene ();
- pView_ = new QGraphicsView ();
-
+ connect(pScene_,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()));
+ pView_ = new QGraphicsView ();
pView_->setScene(pScene_);
setCentralWidget(pView_);
qDebug() << "Initialized boundaries" << rectangle.right() << rectangle.bottom() << pView_->width() << pView_->height();
- pScene_->setupMap(11,5,5);
+ restartLevel();
}
void MainWindow::pause(bool paused)
}
+
+void MainWindow::nextLevel()
+{
+
+ //for now, just the handling of last level is implemented, and there is just one level
+
+ qDebug() << "starting game over";
+ QPixmap victoryIcon (":/pix/aavesaari.png");
+// QMessageBox victoryBox(QMessageBox::Information, tr("You won1"), tr("Congratulations! You have saved all the ghosts."));
+
+// victoryBox.setIconPixmap(victoryIcon);
+// victoryBox.addButton("Start a new game",QMessageBox::YesRole);
+// victoryBox.addButton("Quit",QMessageBox::NoRole);
+
+// victoryBox.exec();
+
+
+ QDialog* pVictoryDialog = new QDialog(this);
+ pVictoryDialog->setWindowTitle(tr("You won!"));
+
+
+ QPushButton* pPlayAgainButton = new QPushButton(tr("Play again"));
+ QPushButton* pQuitButton = new QPushButton(tr("Quit game"));
+ QLabel* pVictoryLabel = new QLabel();
+ pVictoryLabel->setPixmap(victoryIcon);
+ QLabel* pTextLabel = new QLabel(tr("Congratulations! <p>You have saved all the ghosts."));
+
+
+ QVBoxLayout* pMainLayout = new QVBoxLayout;
+
+ QHBoxLayout* pTopLayout = new QHBoxLayout;
+ pMainLayout->addLayout(pTopLayout);
+
+ pTopLayout->addWidget(pVictoryLabel);
+ pTopLayout->addWidget(pTextLabel);
+
+
+
+ QHBoxLayout* pButtonLayout = new QHBoxLayout();
+ pMainLayout->addLayout(pButtonLayout);
+
+
+ // pButtonLayout->addWidget(pQuitButton);
+ pButtonLayout->addWidget(pPlayAgainButton);
+
+
+
+ pVictoryDialog->setLayout(pMainLayout);
+
+ connect(pPlayAgainButton, SIGNAL(clicked()),pVictoryDialog,SLOT(accept()));
+
+ pVictoryDialog->exec();
+
+ restartLevel();
+
+
+
+}