-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScore.cpp
More file actions
31 lines (22 loc) · 742 Bytes
/
Copy pathScore.cpp
File metadata and controls
31 lines (22 loc) · 742 Bytes
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
#include "Score.h"
#include "Consts.h"
#include "Values.h"
#include <QtWidgets/QGraphicsScene>
void scoreChanged(Score* score, int value)
{
score->setText(("Score : " + std::to_string(value)).c_str());
}
Score::Score(QGraphicsScene* scene, Values* values)
: _scene(scene)
, _values(values)
{
_scene->addItem(this);
setX(_scene->sceneRect().width() / 2 - Consts::BOARD_ITEM_SIZE * Consts::BOARD_SIZE / 2);
setY(_scene->sceneRect().height() / 2 + Consts::BOARD_ITEM_SIZE * Consts::BOARD_SIZE / 2);
_values->score.observe([this](int value) {
scoreChanged(this, value);
});
std::string msg = "Score : " + std::to_string(values->score.get());
setText(msg.c_str());
setScale(2.5);
}