-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
53 lines (50 loc) · 1.45 KB
/
mainwindow.cpp
File metadata and controls
53 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Size.h"
#include "Game.h"
#include "GameLoop.h"
#include <QDesktopWidget>
#include <QVBoxLayout>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//this->setMinimumSize (QApplication::desktop ()->width () / 2, QApplication::desktop ()->height () / 2);
this->game = new Game(this->width (), this->height ());
this->canvas = new Canvas(game,this);
this->gloop = new GameLoop(game, canvas);
this->gloop->setParent (this);
canvas->setGeometry (0 , 0, this->width (), this->height ());
canvas->setMaximumSize (this->width (), this->height ());
canvas->setVisible (false);
// this->layout ()->addWidget (canvas);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::hideMenu() {
ui->StartButton->setVisible (false);
ui->SettingsButton->setVisible(false);
ui->ScoreButton->setVisible(false);
ui->ExitButton->setVisible (false);
}
void MainWindow::showMenu() {
ui->StartButton->setVisible (true);
ui->SettingsButton->setVisible(true);
ui->ScoreButton->setVisible(true);
ui->ExitButton->setVisible (true);
this->canvas->setVisible (false);
}
void MainWindow::on_ExitButton_clicked()
{
exit(EXIT_SUCCESS);
}
void MainWindow::on_StartButton_clicked()
{
hideMenu();
canvas->show ();
gloop->start ();
connect(gloop, SIGNAL(finished()), this, SLOT(showMenu()));
}