-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
70 lines (62 loc) · 1.76 KB
/
Copy pathmenu.cpp
File metadata and controls
70 lines (62 loc) · 1.76 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "menu.h"
#include "ui_menu.h"
#include <QPalette>
Menu::Menu(QWidget *parent):
QMainWindow(parent),
ui(new Ui::Menu)
{
ui->setupUi(this);
setFixedSize(700, 900);
gWindow = new GamePlay();
dWindow = new GameDesighn();
ui->comboBox->addItem("Choose level",Qt::AlignCenter);
ui->comboBox->addItem("1 level",Qt::AlignCenter);
ui->comboBox->addItem("2 level",Qt::AlignCenter);
ui->comboBox->addItem("3 level",Qt::AlignCenter);
ui->comboBox->addItem("4 level",Qt::AlignCenter);
ui->comboBox->addItem("5 level",Qt::AlignCenter);
ui->comboBox->addItem("User level",Qt::AlignCenter);
connect(gWindow, &GamePlay::firstWindow, this, &Menu::show);
connect(dWindow, &GameDesighn::firstWindow, this, &Menu::show);
connect(ui->pushButton_3, SIGNAL(clicked()), qApp, SLOT(quit()));
setWindowFlags(Qt::FramelessWindowHint);
setFocusPolicy(Qt::NoFocus);
}
Menu::~Menu()
{
delete ui;
}
void Menu::on_pushButton_clicked()
{
QString str = QCoreApplication::applicationDirPath()+"/levels/0.json";
QFile file(str);
if (ui->comboBox->currentIndex()!=6 || file.exists()){
gWindow->start();
gWindow->show();
this->close();
}else{
QErrorMessage* mes = new QErrorMessage;
mes->showMessage("User level data not founded. Use designer first!");
}
}
void Menu::on_comboBox_currentIndexChanged(int index)
{
if (index == 0){
gWindow->setUserLvl(-1);
} else if (index == 6){
gWindow->setUserLvl(0);
} else{
gWindow->setUserLvl(index);
}
}
void Menu::on_pushButton_2_clicked()
{
dWindow->show();
dWindow->start();
this->close();
}
void Menu::keyPressEvent(QKeyEvent *e){
if(e->key()==Qt::Key_E){
qApp->quit();
}
}