-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodechoosepage.cpp
More file actions
128 lines (114 loc) · 4.02 KB
/
Copy pathmodechoosepage.cpp
File metadata and controls
128 lines (114 loc) · 4.02 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "modechoosepage.h"
#include <QPushButton>
#include <QDesktopWidget>
#include <QApplication>
#include <QLabel>
#include <QDebug>
ModeChoosePage::ModeChoosePage(QWidget *parent):
QWidget(parent)
{
this->setFixedSize(900,720);
QDesktopWidget *deskdop=QApplication::desktop();
move((deskdop->width()-this->width())/2, (deskdop->height()-this->height())/2);
this->setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":/snakeIcon/snake.png"));
QLabel *title = new QLabel(this);
title->setText("S");
title->setFixedSize(600,300);
title->move(150,50);
title->setAlignment(Qt::AlignTop);title->setAlignment(Qt::AlignHCenter);
title->setStyleSheet("QLabel{font-family:'Gigi';font-size:200px;color:rgb(46,139,87);}");
title->show();
QPushButton *Single = new QPushButton;
Single->setText("Single");
Single->setParent(this);
Single->setFixedSize(350,60);
Single->move(275,360);
Single->setStyleSheet(
"QPushButton{font-family:'Bauhaus 93';font-size:32px;color:rgb(255,250,250);}\
QPushButton{background-color:rgb(170,200,50)}\
QPushButton:hover{background-color:rgb(50, 170, 200)}");
Single->show();
QPushButton *PvP = new QPushButton;
PvP->setText("Player VS Player");
PvP->setParent(this);
PvP->setFixedSize(350,60);
PvP->move(275,440);
PvP->setStyleSheet(
"QPushButton{font-family:'Bauhaus 93';font-size:32px;color:rgb(255,250,250);}\
QPushButton{background-color:rgb(170,200,50)}\
QPushButton:hover{background-color:rgb(50, 170, 200)}");
PvP->show();
QPushButton *AI = new QPushButton("Player VS AI",this);
AI->setFixedSize(350,60);
AI->move(275,520);
AI->setStyleSheet(
"QPushButton{font-family:'Bauhaus 93';font-size:32px;color:rgb(255,250,250);}\
QPushButton{background-color:rgb(170,200,50)}\
QPushButton:hover{background-color:rgb(50, 170, 200)}");
AI->show();
QPushButton *ExitButton = new QPushButton("Back",this);
ExitButton->setFixedSize(350,60);
ExitButton->move(275,600);
ExitButton->setStyleSheet(
"QPushButton{font-family:'Bauhaus 93';font-size:32px;color:rgb(255,250,250);}\
QPushButton{background-color:rgb(170,200,50)}\
QPushButton:hover{background-color:rgb(50, 170, 200)}");
ExitButton->show();
connect(Single,&QPushButton::clicked,this,[=](){
sub = new subWidget;
this->hide();
sub->show();
startNormal(sub);
});
connect(PvP,&QPushButton::clicked,this,[=](){
sub = new subWidget(2);
this->hide();
sub->show();
startTwoPlayer(sub);
});
connect(AI,&QPushButton::clicked,this,[=](){
sub = new subWidget(1,true);
this->hide();
sub->show();
startAI(sub);
});
connect(ExitButton,&QPushButton::clicked,this,[=](){
this->close();
emit back();
});
}
void ModeChoosePage::startNormal(subWidget* &sub){
if(sub!=nullptr){
connect(sub,&subWidget::closeMe,this,&QWidget::show);
connect(sub,&subWidget::startNewGame,this,[=,&sub](){
delete sub;
sub = new subWidget(1);
startNormal(sub);
sub->show();
});
}
}
void ModeChoosePage::startTwoPlayer(subWidget* &sub){
if(sub!=nullptr){
connect(sub,&subWidget::closeMe,this,&QWidget::show);
connect(sub,&subWidget::startNewGame,this,[=,&sub](){
delete sub;
sub = new subWidget(2);
startTwoPlayer(sub);
sub->show();
});
}
}
void ModeChoosePage::startAI(subWidget* &sub){
if(sub!=nullptr){
connect(sub,&subWidget::closeMe,this,&QWidget::show);
connect(sub,&subWidget::startNewGame,this,[=,&sub](){
delete sub;
sub = new subWidget(1,true);
startAI(sub);
sub->show();
});
}
}