-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwin_menu.cpp
More file actions
75 lines (61 loc) · 2.24 KB
/
win_menu.cpp
File metadata and controls
75 lines (61 loc) · 2.24 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
//AUTHORS: Alan Leung, Matt Dumford
#include "win_menu.h"
#include "mainmenu.h"
#include <QSize>
#include <QFont>
#include <QPushButton>
#include <QDebug>
// the win menu is displayed when you win the game. It shows an animated .gif
// and has buttons to go back to the main menu and to quit the app.
win_menu::win_menu(MainWindow *mainWindow, QWidget *parent) : QWidget(parent)
{
this->mainWindow = mainWindow;
}
void win_menu::display (int sw, int sh)
{
screen_height = sh;
screen_width = sw;
QSize size(screen_width, screen_width);
//QMovie is required for animated pic
QMovie *win_movie = new QMovie(":/animated-fireworks.gif");
win_movie->setScaledSize(size);
//Sets up the moving pic into the label
QLabel *win_pic = new QLabel(this);
win_pic->setMovie(win_movie);
win_pic->resize(size);
win_movie->start();
QLabel *you_win_label = new QLabel("Congratulations, \nyou win!");
you_win_label->setFixedWidth(screen_width);
QFont you_win_font("Helvectica", 16, QFont::Bold);
you_win_label->setFont(you_win_font);
you_win_label->setAlignment(Qt::AlignCenter);
QFont buttonFont("Helvetica", 13);
QPushButton *main_menu = new QPushButton("Main Menu");
main_menu->setFont(buttonFont);
QPushButton *quit = new QPushButton("Quit");
quit->setFont(buttonFont);
//Puts all the label into a layout
QGridLayout *win_layout = new QGridLayout;
win_layout->addWidget(win_pic, 0, 0, 1, 2);
win_layout->addWidget(you_win_label, 1, 0, 1, 2);
win_layout->addWidget(main_menu, 2, 0, 1, 1);
win_layout->addWidget(quit, 2, 1, 1, 1);
//Puts the layout into a widget for future use
QWidget *win_widget = new QWidget;
win_widget->setLayout(win_layout);
//connect buttons
connect(main_menu, SIGNAL(clicked()), this, SLOT(mainMenuClicked()));
connect(quit, SIGNAL(clicked()), this, SLOT(quitClicked()));
win_widget->show();
}
void win_menu::mainMenuClicked()
{
qDebug() << "main menu clicked.";
MainMenu *mm = new MainMenu(mainWindow, mainWindow);
mm->display(screen_width, screen_height);
}
void win_menu::quitClicked()
{
qDebug() << "quit clicked.";
exit(EXIT_FAILURE);
}