diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-09-28 19:26:24 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-09-28 19:26:24 +0000 |
commit | 208e046a49a1b429dc6a58563874f478c5857778 (patch) | |
tree | defd0d6df51a5afe72139aba78a36e5381668ef6 /src/gui | |
parent | b1acdc8b5ebc1ab9506e5910c1d6c37504007653 (diff) | |
download | mana-208e046a49a1b429dc6a58563874f478c5857778.tar.gz mana-208e046a49a1b429dc6a58563874f478c5857778.tar.bz2 mana-208e046a49a1b429dc6a58563874f478c5857778.tar.xz mana-208e046a49a1b429dc6a58563874f478c5857778.zip |
HP and MP display in the mini status window.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatus.cpp | 31 | ||||
-rw-r--r-- | src/gui/ministatus.h | 1 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 2d834949..8814a5fd 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -23,7 +23,7 @@ #include "ministatus.h" -// #include <guichan/widgets/label.hpp> +#include <guichan/widgets/label.hpp> #include <sstream> #include "progressbar.h" @@ -38,15 +38,24 @@ MiniStatusWindow::MiniStatusWindow(): setMovable(false); hpBar = new ProgressBar(1.0f, - 0, 3, 80, 15, + 0, 3, 100, 20, 0, 171, 34); mpBar = new ProgressBar(1.0f, hpBar->getX() + hpBar->getWidth() + 3, - hpBar->getY(), 80, 15, 26, 102, 230); + hpBar->getY(), 100, 20, 26, 102, 230); + + hpLabel = new gcn::Label("/"); + mpLabel = new gcn::Label("/"); + hpLabel->setPosition(hpBar->getX() + int((hpBar->getWidth() / 2) - (hpLabel->getWidth() / 2)), + hpBar->getY() + int((hpBar->getHeight() / 2) - (hpLabel->getHeight() / 2))); + mpLabel->setPosition(mpBar->getX() + int((mpBar->getWidth() / 2) - (mpLabel->getWidth() / 2)), + mpBar->getY() + int((mpBar->getHeight() / 2) - (mpLabel->getHeight() / 2))); add(hpBar); add(mpBar); + add(hpLabel); + add(mpLabel); setContentSize(mpBar->getX() + mpBar->getWidth(), mpBar->getY() + mpBar->getHeight()); @@ -56,6 +65,8 @@ MiniStatusWindow::~MiniStatusWindow() { delete hpBar; delete mpBar; + delete hpLabel; + delete mpLabel; } void MiniStatusWindow::update() @@ -79,6 +90,20 @@ void MiniStatusWindow::update() hpBar->setProgress((float)player_info->hp / (float)player_info->maxHp); // mpBar->setProgress((float)player_info->mp / (float)player_info->maxMp); + + // Update and center labels + std::stringstream updatedText; + updatedText << player_info->hp << "/" << player_info->maxHp; + hpLabel->setCaption(updatedText.str()); + hpLabel->adjustSize(); + updatedText.str(""); + updatedText << player_info->mp << "/" << player_info->maxMp; + mpLabel->setCaption(updatedText.str()); + mpLabel->adjustSize(); + hpLabel->setPosition(hpBar->getX() + int((hpBar->getWidth() / 2) - (hpLabel->getWidth() / 2)), + hpBar->getY() + int((hpBar->getHeight() / 2) - (hpLabel->getHeight() / 2))); + mpLabel->setPosition(mpBar->getX() + int((mpBar->getWidth() / 2) - (mpLabel->getWidth() / 2)), + mpBar->getY() + int((mpBar->getHeight() / 2) - (mpLabel->getHeight() / 2))); } void MiniStatusWindow::draw(gcn::Graphics *graphics) diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index 27c51e42..07aa5d4a 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -72,6 +72,7 @@ class MiniStatusWindow : public Window, public gcn::ActionListener { * Mini Status Bars */ ProgressBar *hpBar, *mpBar; + gcn::Label *hpLabel, *mpLabel; }; extern MiniStatusWindow *miniStatusWindow; |