forked from Rescator7/Hearts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccardsplayed.cpp
99 lines (76 loc) · 2 KB
/
ccardsplayed.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
95
96
97
98
99
#ifdef DEBUG
#include "ccardsplayed.h"
CCardsPlayed::CCardsPlayed(CDeck *d)
{
setWindowTitle(tr("Cards played"));
setAttribute( Qt::WA_QuitOnClose, false );
deck = d;
box_clubs = new QHBoxLayout;
box_spade = new QHBoxLayout;
box_diamond = new QHBoxLayout;
box_hearts = new QHBoxLayout;
for (int i=0; i<DECK_SIZE; i++) {
labels[i] = new QLabel(this);
labels[i]->resize(55, 100);
labels[i]->setPixmap(QPixmap::fromImage(deck->get_img_card(i)->scaledToHeight(100)));
if (i <= 12)
box_clubs->addWidget(labels[i]);
else
if (i <= 25)
box_spade->addWidget(labels[i]);
else
if (i <= 38)
box_diamond->addWidget(labels[i]);
else
box_hearts->addWidget(labels[i]);
}
QGroupBox *grp1 = new QGroupBox;
grp1->setLayout(box_clubs);
QGroupBox *grp2 = new QGroupBox;
grp2->setLayout(box_spade);
QGroupBox *grp3 = new QGroupBox;
grp3->setLayout(box_diamond);
QGroupBox *grp4 = new QGroupBox;
grp4->setLayout(box_hearts);
layout = new QVBoxLayout();
layout->addWidget(grp1);
layout->addWidget(grp2);
layout->addWidget(grp3);
layout->addWidget(grp4);
setLayout(layout);
QPalette pal = palette();
pal.setColor(QPalette::Window, QColor(63, 159, 82));
pal.setColor(QPalette::WindowText, Qt::black);
setPalette(pal);
resize(800, 600);
}
CCardsPlayed::~CCardsPlayed()
{
for (int i=0; i<DECK_SIZE; i++)
delete labels[i];
delete box_clubs;
delete box_spade;
delete box_diamond;
delete box_hearts;
delete layout;
}
void CCardsPlayed::play(int card)
{
if ((card < 0) || (card >= DECK_SIZE)) return;
labels[card]->setDisabled(true);
}
void CCardsPlayed::reset()
{
for (int i=0; i<DECK_SIZE; i++)
labels[i]->setDisabled(false);
}
void CCardsPlayed::set_deck()
{
for (int i=0; i<DECK_SIZE; i++)
labels[i]->setPixmap(QPixmap::fromImage(deck->get_img_card(i)->scaledToHeight(100)));
}
void CCardsPlayed::Translate()
{
setWindowTitle(tr("Cards played"));
}
#endif // DEBUG