forked from CpS209TeamOmega/TandemTechies
/
menu.cpp
94 lines (79 loc) · 2.07 KB
/
menu.cpp
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
93
94
//**********************************************************
// File: menu.cpp
// Desc: The game menu's implementation
//**********************************************************
#include "menu.h"
#include "ui_menu.h"
#include <QLabel>
#include <QDebug>
#include <QInputDialog>
Menu::Menu(QWidget *parent) :
QWidget(parent),
ui(new Ui::Menu)
{
ui->setupUi(this);
setWindowFlags(Qt::WindowStaysOnTopHint);
setWindowModality(Qt::ApplicationModal);
setWindowTitle("Tandem Techies");
setFixedSize(geometry().width(), geometry().height());
QIcon icon(":/images/player.png");
setWindowIcon(icon);
QLabel* background = new QLabel(this);
QPixmap backgroundImg(":/images/bg.png");
background->setPixmap(backgroundImg);
background->setGeometry(0, 0, geometry().width(), geometry().height());
background->setScaledContents(true);
background->lower();
background->show();
//Make the logo's background transparent
ui->lblLogo->setAttribute(Qt::WA_TranslucentBackground);
//Make the menu border invisible
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint);
setWindowFlags(Qt::CustomizeWindowHint);
setWindowFlags(Qt::FramelessWindowHint);
}
Menu::~Menu()
{
delete ui;
}
void Menu::on_btnStart_clicked()
{
QString server = "";
bool ok;
if(ui->btnMulti->isChecked()) {
server = QInputDialog::getText(this, "Server IP", "Server IP Address:", QLineEdit::Normal, "10.20.2.137", &ok);
if(!ok) return;
}
emit startGame(server);
hide();
}
void Menu::on_btnLoad_clicked()
{
emit loadGame();
hide();
}
void Menu::on_btnExit_clicked()
{
emit exitGame();
close();
}
void Menu::on_btnSingle_clicked()
{
if(ui->btnSingle->isChecked()) {
ui->btnMulti->setChecked(false);
} else {
ui->btnMulti->setChecked(true);
}
}
void Menu::on_btnMulti_clicked()
{
if(ui->btnMulti->isChecked()) {
ui->btnSingle->setChecked(false);
} else {
ui->btnSingle->setChecked(true);
}
}
void Menu::on_btnHighScores_clicked()
{
emit highScores();
}