-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOakBoard.cpp
43 lines (37 loc) · 1004 Bytes
/
OakBoard.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
#include "OakBoard.h"
OakBoard::OakBoard(QGraphicsItem* parent) : QObject(), PlantBoard (150, false, false, parent)
{
setPixmap(QPixmap(":/images/OakUnSelected.jpg"));
setPos(275,8);
}
void OakBoard::slotPlayerScore(int playerScore)
{
if (price <= playerScore){
isSelectable = true;
setPixmap(QPixmap(":/images/OakSelectable.jpg"));
}
else{
isSelectable = false;
setPixmap(QPixmap(":/images/OakUnSelected.jpg"));
}
}
void OakBoard::isPlaced()
{
isSelected = false;
emit UnselectOak();
}
void OakBoard::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
//first we check that plant is selectable
if(isSelectable && !(isSelected) ){
isSelected = true;
//set selected picture
setPixmap(QPixmap(":/images/OakSelected.jpg"));
emit OakSellected();
}
else if ( isSelected ){
isSelected = false;
setPixmap(QPixmap(":/images/OakSelectable.jpg"));
emit UnselectOak();
}
}