diff options
| author | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-10-19 21:36:44 +0300 |
|---|---|---|
| committer | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-10-19 21:36:44 +0300 |
| commit | fe15901cad4ccc90b5702cf5061849c1ab1fd40d (patch) | |
| tree | 0148609d571ae7bc93a04acf8fc45647d057aaf1 /src/BarDisplay.cpp | |
| parent | a0f7ab0f77fa81b77d03de751e4a5f4e07c49d25 (diff) | |
| download | prism-fe15901cad4ccc90b5702cf5061849c1ab1fd40d.tar.gz prism-fe15901cad4ccc90b5702cf5061849c1ab1fd40d.zip | |
HUD improvement
Added
- some placeholder graphics for HUD elements
- just to demonstrate how HUD may be implemented with drawForeground of
ActionScene
Diffstat (limited to 'src/BarDisplay.cpp')
| -rw-r--r-- | src/BarDisplay.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/BarDisplay.cpp b/src/BarDisplay.cpp index 4b27b55..b3e6260 100644 --- a/src/BarDisplay.cpp +++ b/src/BarDisplay.cpp @@ -1,3 +1,5 @@ +#include <QPainter> + #include "BarDisplay.h" BarDisplay::BarDisplay(int w, int h) : @@ -7,17 +9,41 @@ BarDisplay::BarDisplay(int w, int h) : m_maxValue = 50; m_value = 50; - /* TODO: - initialize this item with some kind of rectangle graphics - that supports partitioning, e.g. - [ / / ] or such - */ + fill(QColor(Qt::transparent)); } BarDisplay::~BarDisplay() { } +void BarDisplay::initShape() +{ + QPainter p(this); + QPen pen(QColor(0, 0, 0, 255)); + pen.setWidth(1); + + QBrush brush(m_displayColor); + + p.setPen(pen); + p.fillRect(0, 0, width(), height(), brush); + + // left side + p.drawLine(0, 0, 0, height() - 1); + p.drawLine(0, 0, 20, 0); + p.drawLine(0, height() - 1, 20, height() - 1); + + // right side + p.drawLine(width() - 1, 0, width() - 1, height() - 1); + p.drawLine(width() - 1, 0, width() -1 - 20, 0); + p.drawLine(width() - 1, height() - 1, width() - 1 - 20, height() - 1); + + pen.setWidth(2); + p.setPen(pen); + // the | -lines + for (int i = 1; i < 4; i++) + p.drawLine((160 / 3) * i, 0, (160 / 3) * i - 15, height() - 1); +} + void BarDisplay::collected(int amount) { m_value += amount; |
