-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenuforgames.cpp
More file actions
65 lines (53 loc) · 1.57 KB
/
menuforgames.cpp
File metadata and controls
65 lines (53 loc) · 1.57 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
#include "menuforgames.h"
#include <QPushButton>
#include "game/racing/racing.h"
#include "game/feeding/feeding.h"
#include <QVBoxLayout>
#include <stdlib.h>
#include <time.h>
Racing * rc;
Feeding * fd;
MenuForGames::MenuForGames(QWidget *parent) :
QWidget(parent)
{
srand(time(NULL));
QVBoxLayout * myLayout = new QVBoxLayout(this);
myLayout->setMargin(0);
setLayout(myLayout);
QPushButton * racingBtn = new QPushButton("Racing",this);
QPushButton * feedingBtn = new QPushButton("Feeding",this);
QPushButton * exitBtn = new QPushButton("Return to tamagochi",this);
myLayout->addWidget(racingBtn);
myLayout->addWidget(feedingBtn);
myLayout->addWidget(exitBtn);
racingBtn->setFixedSize(300,100);
feedingBtn->setFixedSize(300,100);
exitBtn->setFixedSize(300,100);
setFixedSize(300,300);
connect(racingBtn,SIGNAL(clicked()),this,SLOT(newRacing()));
connect(feedingBtn,SIGNAL(clicked()),this,SLOT(newFeeding()));
connect(exitBtn,SIGNAL(clicked()),this,SLOT(close()));
setFocusPolicy(Qt::ClickFocus);
}
void MenuForGames::newRacing()
{
rc = new Racing();
rc->show();
rc->setFocus();
rc->setAttribute(Qt::WA_DeleteOnClose);
this->hide();
connect(rc,SIGNAL(addHappy(int)),this,SLOT(addHappySgn(int)));
}
void MenuForGames::newFeeding()
{
fd = new Feeding();
fd->show();
fd->setFocus();
fd->setAttribute(Qt::WA_DeleteOnClose);
this->hide();
connect(fd,SIGNAL(addHappy(int)),this,SLOT(addHappySgn(int)));
}
void MenuForGames::addHappySgn(int points)
{
emit addHappy(points);
}