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
|
#include <QPainter>
#include "CircularDisplay.h"
CircularDisplay::CircularDisplay(int w, int h) :
QPixmap(w, h)
{
m_partCount = 5;
m_maxValue = 50;
m_consumeSpeed = 5;
m_value = 10;
m_activated = false;
fill(QColor(Qt::transparent));
}
CircularDisplay::~CircularDisplay()
{
}
void CircularDisplay::initShape()
{
QPainter p(this);
QPen pen(QColor(0, 0, 0, 255));
QBrush brush(m_displayColor);
pen.setWidth(4);
p.setPen(pen);
// draw base ellipse
p.drawEllipse(QPointF(25, 35), 20, 20);
p.setBrush(brush);
// first 1/4th
//p.drawPie(5, 15, 40, 20, 0, 180 * 16);
// last 1/4th
//p.drawPie(25, 35, 40, 20, 0, -180 * 16);
// upper half
//p.drawPie(5, 15, 40, 40, 0, 180 * 16);
// lower half
pen.setWidth(2);
p.setPen(pen);
p.drawPie(5, 15, 40, 40, 0, -180 * 16);
// draw "tick" lines
//p.drawLine(25, 15, 25, 0); // 12 o'clock
//p.drawLine(45, 35, 60, 35); // 3 o'clock
//p.drawLine(25, 55, 25, 70); // 6 o'clock
}
void CircularDisplay::setDisplayColor(QColor col)
{
m_displayColor = col;
}
void CircularDisplay::collected(int amount)
{
m_value += amount;
if (m_value > m_maxValue)
m_value = m_maxValue;
updateDisplay();
}
void CircularDisplay::activate()
{
m_activated = true;
}
void CircularDisplay::unactivate()
{
m_activated = false;
}
void CircularDisplay::updateDisplay()
{
// TODO: update graphics so user knows collecting stuff does help
}
|