add restart button to game over screen

This commit is contained in:
2026-04-21 20:38:18 +02:00
parent 043aaf774a
commit b7f2005504
5 changed files with 76 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
#include <QHBoxLayout>
#include <QMessageBox>
#include <QPushButton>
#include <QResizeEvent>
#include <QVBoxLayout>
@@ -106,7 +107,17 @@ void MainWindow::onGameOver()
box.setText(QString("HQ destroyed!\nSurvival time: %1:%2")
.arg(minutes, 2, 10, QChar('0'))
.arg(seconds, 2, 10, QChar('0')));
QPushButton* restartBtn = box.addButton("Restart", QMessageBox::AcceptRole);
box.addButton("Quit", QMessageBox::RejectRole);
box.exec();
close();
if (box.clickedButton() == restartBtn)
{
m_sim->reset();
m_gameWorldView->resetForNewGame();
}
else
{
close();
}
}