aboutsummaryrefslogtreecommitdiff
path: root/src/BarDisplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BarDisplay.cpp')
-rw-r--r--src/BarDisplay.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/BarDisplay.cpp b/src/BarDisplay.cpp
new file mode 100644
index 0000000..edab1c9
--- /dev/null
+++ b/src/BarDisplay.cpp
@@ -0,0 +1,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)
+{
+}