-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstone.cpp
More file actions
69 lines (52 loc) · 1.55 KB
/
Copy pathstone.cpp
File metadata and controls
69 lines (52 loc) · 1.55 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
#include <board.h>
#include <stdio.h>
extern bool userStatus;
extern int userColor;
int cnt = 1;
stone::stone(QWidget *parent, int i, int k) : QWidget(parent){
this->i = i;
this->k = k;
state = 0;
}
void stone::paintEvent(QPaintEvent*){
QPainter painter(this);
if(userStatus){
if(userColor == 1){
QPen myPen(Qt::black, Qt::SolidLine);
painter.setPen(myPen);
painter.setBrush(QBrush(Qt::black, Qt::SolidPattern));
state = 1;
}
else{
QPen myPen(Qt::white, Qt::SolidLine);
painter.setPen(myPen);
painter.setBrush(QBrush(Qt::white, Qt::SolidPattern));
state = 2;
}
this->setUpdatesEnabled(false);
QTimer::singleShot(0, (board*)this->parentWidget(), SLOT(emptyLabel()));
}
else{
if(userColor == 2){
QPen myPen(Qt::black, Qt::SolidLine);
painter.setPen(myPen);
painter.setBrush(QBrush(Qt::black, Qt::SolidPattern));
state = 1;
}
else{
QPen myPen(Qt::white, Qt::SolidLine);
painter.setPen(myPen);
painter.setBrush(QBrush(Qt::white, Qt::SolidPattern));
state = 2;
}
this->setUpdatesEnabled(false);
QTimer::singleShot(0, (board*)this->parentWidget(), SLOT(changeLabel()));
}
painter.drawEllipse(0, 0, 40, 40);
}
void stone::mousePressEvent(QMouseEvent*){
if( userStatus && state == 0 ){
cnt++;
this->setUpdatesEnabled(true);
}
}