-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
92 lines (84 loc) · 2.59 KB
/
menu.cpp
File metadata and controls
92 lines (84 loc) · 2.59 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "menu.h"
#include "ui_menu.h"
#include <QPainter>
#include <QMessageBox>
#include <QInputDialog>
Menu::Menu(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Menu)
{
ui->setupUi(this);
}
Menu::~Menu()
{
delete ui;
}
void Menu::paintEvent(QPaintEvent* e){
QWidget::paintEvent(e);
QPainter painter(this);
painter.drawPixmap(0,0,400,225, QPixmap(":/images/data/PNG/logo.jpeg"));
}
void Menu::on_Jouer_clicked()
{
int reponse, reponse2, reponse3,reponse4;
string line;
mainwindow.setPerso(option.getPerso());
mainwindow.setDeco(option.getDeco());
reponse= QMessageBox::question(this, "Titre de la fenêtre", "Avez vous déjà au sokoban?", QMessageBox::Yes | QMessageBox::No);
if (reponse == QMessageBox::Yes)
{
reponse2 = QMessageBox::question(this, "Titre de la fenêtre", "Première partie?", QMessageBox::Yes | QMessageBox::No);
if (reponse2 == QMessageBox::Yes)
{
hide();
mainwindow.gestionPlateau(1);
mainwindow.show();
}
else if (reponse2 == QMessageBox::No){
bool ok;
QString text = QInputDialog::getText(this, tr("Recherche du niveau"),tr("Code niveau:"), QLineEdit::Normal,"Stays", &ok);
if (ok && !text.isEmpty()){
ok = false;
reponse3 = 0;
string file = "../Projet_2021_2022_Sokoban_0.3/data/LVL/level.txt";
cout << file<< endl;
cout << text.toStdString() << endl;
ifstream fichier(file.c_str(), ios::in);
if(!fichier.fail())
{
while (fichier.eof() == false and !ok){
fichier>>line;
ok = (text.toStdString() == line);
reponse3++;
}
if (ok){
hide();
mainwindow.setNiveau(reponse3);
mainwindow.gestionPlateau(reponse3);
mainwindow.show();
}
else {
reponse4 = QMessageBox::warning(this, "Code erroné", "Renvoi premier niveau");
hide();
mainwindow.gestionPlateau(1);
mainwindow.show();
}
}
}
}
}
else if (reponse == QMessageBox::No)
{
aide.show();
}
//hide();
//gn.show();
}
void Menu::on_Quitter_clicked()
{
close();
}
void Menu::on_pushButton_clicked()
{
option.show();
}