blob: edab1c9536ee9ba854cbe3fe3c609c1833d610d9 (
plain)
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
|
#include "BarDisplay.h"
BarDisplay::BarDisplay(QGraphicsItem* parent) :
QGraphicsItem(parent)
{
m_partCount = 4;
m_maxValue = 50;
m_value = 50;
/* TODO:
initialize this item with some kind of rectangle graphics
that supports partitioning, e.g.
[ / / ] or such
*/
}
BarDisplay::~BarDisplay()
{
}
void BarDisplay::collected(int amount)
{
m_value += amount;
if (m_value > m_maxValue)
m_value = m_maxValue;
updateDisplay();
}
void BarDisplay::consumed(int amount)
{
m_value -= amount;
if (m_value < 0)
m_value = 0;
updateDisplay();
}
void BarDisplay::setDisplayColor(QColor col)
{
m_displayColor = col;
}
void BarDisplay::updateDisplay()
{
// TODO: update graphics so user knows he is hit
}
QRectF BarDisplay::boundingRect() const
{
return QRectF();
}
void BarDisplay::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
}
|